From af8b933281de0014df2593c662b283380f5e3cfe Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 11 Sep 2013 23:05:02 +0200 Subject: [PATCH] fix https bug, add main playlists --- src/imagestore/Controller/Api/ImageBase.php | 1 + src/imagestore/Controller/Api/Playlists.php | 31 +++++++++++++++++---- www/index.php | 7 ++++- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/imagestore/Controller/Api/ImageBase.php b/src/imagestore/Controller/Api/ImageBase.php index e48a52d..f815689 100644 --- a/src/imagestore/Controller/Api/ImageBase.php +++ b/src/imagestore/Controller/Api/ImageBase.php @@ -6,6 +6,7 @@ class Controller_Api_ImageBase extends Controller_Base protected function getBaseUrl() { if (isset($_SERVER['HTTPS'])) { + $protocol = 'https'; } else { $protocol = 'http'; } diff --git a/src/imagestore/Controller/Api/Playlists.php b/src/imagestore/Controller/Api/Playlists.php index 5728efe..ea9d332 100644 --- a/src/imagestore/Controller/Api/Playlists.php +++ b/src/imagestore/Controller/Api/Playlists.php @@ -7,12 +7,25 @@ class Controller_Api_Playlists extends Controller_Api_ImageBase { $playlists = (object) array( 'games' => array(), - 'playlists' => array() + 'playlists' => array( + (object) array( + //main playlists in the store? + 'name' => null, + 'id' => -1, + 'image' => null, + 'tiles' => array() + ), + (object) array( + //mainpage + 'name' => null, + 'id' => -2, + 'image' => null, + 'tiles' => array() + ) + ) ); - //-1 - link to playlists - //-2 - ???? - //1 - featured - //2 - trending now + + $mainpage = 0; $id = 0; foreach ($this->groupByParent($this->getDirs()) as $dir => $arDirs) { $plnum = count($playlists->playlists); @@ -22,6 +35,8 @@ class Controller_Api_Playlists extends Controller_Api_ImageBase 'name' => $dir, 'tiles' => array() ); + $playlists->playlists[0]->tiles[] = array('playlist' => $id); + foreach ($arDirs as $dirInfo) { $uuid = str_replace( '/', '-.-', $this->getRelPath($dirInfo->getPathname()) @@ -37,6 +52,12 @@ class Controller_Api_Playlists extends Controller_Api_ImageBase $playlists->playlists[$plnum]->tiles[] = (object) array( 'game' => $uuid ); + + if (++$mainpage < 10) { + $playlists->playlists[1]->tiles[] = (object) array( + 'game' => $uuid + ); + } } } diff --git a/www/index.php b/www/index.php index 8417d26..2cb7a38 100644 --- a/www/index.php +++ b/www/index.php @@ -6,7 +6,12 @@ Autoloader::register(); require_once __DIR__ . '/../data/config.php'; -$url = $_SERVER['REDIRECT_URL']; +if (!isset($_SERVER['REDIRECT_URL'])) { + $url = ''; +} else { + $url = $_SERVER['REDIRECT_URL']; +} + if (substr($url, 0, 5) == '/api/') { $api = new Controller_Api(); $api->handle(substr($url, 5)); -- 2.30.2