X-Git-Url: https://git.cweiske.de/ouya-imagestore.git/blobdiff_plain/331d593564ee818a3cc9e4cb6969b8d97fe62d1f..9cfd31d1aa1990a1ce4200678b20ec42dd43330f:/src/imagestore/Controller/Api/Playlists.php diff --git a/src/imagestore/Controller/Api/Playlists.php b/src/imagestore/Controller/Api/Playlists.php index 98d4974..5728efe 100644 --- a/src/imagestore/Controller/Api/Playlists.php +++ b/src/imagestore/Controller/Api/Playlists.php @@ -1,7 +1,7 @@ array() ); foreach ($arDirs as $dirInfo) { - //FIXME: uuid dots? - $uuid = $this->getRelPath($dirInfo->getPathname()); + $uuid = str_replace( + '/', '-.-', $this->getRelPath($dirInfo->getPathname()) + ); $playlists->games[] = (object) array( 'content_rating' => 'Everyone', 'image' => $this->getImageUrl($this->getFirstImage($dirInfo)), 'title' => basename($dirInfo->getPathname()), 'uuid' => $uuid, - 'version' => '11111111-0000-1111-0000-111111111111' + 'version' => '11111111-0000-1111-0000-111111111111', + '__details' => $this->getDetailsUrl($uuid), ); $playlists->playlists[$plnum]->tiles[] = (object) array( 'game' => $uuid @@ -67,24 +69,6 @@ class Controller_Api_Playlists return $it->valid(); } - protected function getImageIterator(\SplFileInfo $dirInfo) - { - $it = new \AppendIterator(); - $it->append( - new \LimitIterator( - new \GlobIterator($dirInfo->getPathName() . '/*.jpg'), - 0, 1 - ) - ); - $it->append( - new \LimitIterator( - new \GlobIterator($dirInfo->getPathName() . '/*.JPG'), - 0, 1 - ) - ); - return $it; - } - protected function groupByParent($dirs) { $arGroups = array(); @@ -94,26 +78,10 @@ class Controller_Api_Playlists return $arGroups; } - protected function getRelPath($path) + protected function getDetailsUrl($uuid) { - return substr($path, strlen($GLOBALS['imagestore']['basedir'])); - } - - protected function getImageUrl($path) - { - if (isset($_SERVER['HTTPS'])) { - } else { - $protocol = 'http'; - } - return $protocol . '://' . $_SERVER['HTTP_HOST'] - . '/image?path=' . urlencode($this->getRelPath($path)); - } - - protected function getFirstImage(\SplFileInfo $dirInfo) - { - $it = $this->getImageIterator($dirInfo); - $it->rewind(); - return $it->current(); + return $this->getBaseUrl() + . 'api/v1/apps/' . rawurlencode($uuid); } } ?>