+ public function latestSimfileAction()\r
+ {\r
+ $simfile = $this->_simfileRepository->findRange(0, -1);\r
+ $this->_response->setHeader('Content-Type', 'application/json')\r
+ ->setBody(json_encode($this->simfileToArray(reset($simfile))))\r
+ ->sendResponse();\r
+ }\r
+ \r
+ public function latestPackAction()\r
+ {\r
+ $pack = $this->_packRepository->findRange(0, -1);\r
+ $pack = reset($pack);\r
+ \r
+ $packArray = array(\r
+ 'title'=> $pack->getTitle(),\r
+ 'contributors' => $pack->getContributors(),\r
+ 'simfiles' => $this->getPackSimfilesArray($pack),\r
+ 'banner' => $pack->getBanner() ? 'files/banner/' . $pack->getBanner()->getHash() : 'files/banner/default',\r
+ 'mirrors' => $this->getPackMirrorsArray($pack),\r
+ 'size' => $pack->getFile() ? Util::bytesToHumanReadable($pack->getFile()->getSize()) : null,\r
+ 'uploaded' => $pack->getFile() ? date('F jS, Y', $pack->getFile()->getUploadDate()) : null\r
+ );\r
+ \r
+ $this->_response->setHeader('Content-Type', 'application/json')\r
+ ->setBody(json_encode($packArray))\r
+ ->sendResponse();\r
+ }\r
+ \r
+ public function popularAction()\r
+ {\r
+ $returnArray = array();\r
+ $popularDownloads = $this->_downloadRepository->findPopular();\r
+ $popularDownloads = reset($popularDownloads);\r
+ $packOrFileId = $popularDownloads->getFile()->getId();\r
+ \r
+ $simfile = $this->_simfileRepository->findByFileId($packOrFileId);\r
+ if($simfile)\r
+ {\r
+ $returnArray = $this->simfileToArray(reset($simfile));\r
+ } else {\r
+ $pack = $this->_packRepository->findByFileId($packOrFileId);\r
+ $pack = reset($pack);\r
+ $returnArray = array(\r
+ 'title'=> $pack->getTitle(),\r
+ 'contributors' => $pack->getContributors(),\r
+ 'simfiles' => $this->getPackSimfilesArray($pack),\r
+ 'banner' => $pack->getBanner() ? 'files/banner/' . $pack->getBanner()->getHash() : 'files/banner/default',\r
+ 'mirrors' => $this->getPackMirrorsArray($pack),\r
+ 'size' => $pack->getFile() ? Util::bytesToHumanReadable($pack->getFile()->getSize()) : null,\r
+ 'uploaded' => $pack->getFile() ? date('F jS, Y', $pack->getFile()->getUploadDate()) : null\r
+ );\r
+ }\r
+ \r
+ $this->_response->setHeader('Content-Type', 'application/json')\r
+ ->setBody(json_encode($returnArray))\r
+ ->sendResponse();\r
+ \r
+ }\r
+ \r