app details (image list)
[ouya-imagestore.git] / src / imagestore / Controller / Api / Apps.php
1 <?php
2 namespace imagestore;
3
4 class Controller_Api_Apps extends Controller_Api_ImageBase
5 {
6     public function handle($data)
7     {
8         $path = str_replace('-.-', '/', $data);
9         $fullPath = $GLOBALS['imagestore']['basedir'] . $path;
10         if (!is_dir($fullPath)) {
11             return $this->error('404 Not Found', 'Path not found');
12         }
13
14         $dirInfo = new \SplFileInfo($fullPath);
15
16         $data = array(
17             'app' => array(
18                 'apkFileSize'   => 123456789,
19                 'contentRating' => 'Everyone',
20                 'description'   => 'Images from folder ' . $fullPath,
21                 'developer'     => 'Christian Weiske',
22                 'filepickerScreenshots' => $this->getScreenshots($dirInfo),
23                 'founder'       => false,
24                 'latestVersion' => '11111111-0000-1111-0000-111111111111',
25                 'likeCount'     => 1337,
26                 'mainImageFullUrl' => $this->getImageUrl($this->getFirstImage($dirInfo)),
27                 'overview'      => 'Images from a folder',
28                 'publishedAt'   => date('c', $dirInfo->getMTime()),
29                 'screenshots'   => array(),
30                 'supportEmailAddress' => 'cweiske+ouya@cweiske.de',
31                 'supportPhone'  => null,
32                 'title'         => $dirInfo->getBasename(),
33                 'uuid'          => $data,
34                 'versionNumber' => '0.0.1',
35                 'website'       => 'http://git.cweiske.de/ouya-imagestore.git/'
36             )
37         );
38
39         header('Content-Type: application/json');
40         echo json_encode($data, JSON_PRETTY_PRINT);
41     }
42
43     protected function getScreenshots(\SplFileInfo $dirInfo)
44     {
45         $lit = new \LimitIterator($this->getImageIterator($dirInfo), 0, 20);
46         $urls = array();
47         foreach ($lit as $file) {
48             $urls[] = $this->getImageUrl($file);
49         }
50         return $urls;
51     }
52 }
53 ?>