fix https bug, add main playlists
authorChristian Weiske <cweiske@cweiske.de>
Wed, 11 Sep 2013 21:05:02 +0000 (23:05 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 11 Sep 2013 21:05:02 +0000 (23:05 +0200)
src/imagestore/Controller/Api/ImageBase.php
src/imagestore/Controller/Api/Playlists.php
www/index.php

index e48a52dbfc970c0e17f8403f49c1f80b0a233af2..f815689b79cbd45fd3123c4960ae4f6c7f16674b 100644 (file)
@@ -6,6 +6,7 @@ class Controller_Api_ImageBase extends Controller_Base
     protected function getBaseUrl()
     {
         if (isset($_SERVER['HTTPS'])) {
+            $protocol = 'https';
         } else {
             $protocol = 'http';
         }
index 5728efe59a51172c31c5be8a8a42693744453dde..ea9d332e10b3d44d38f0a0bad3bb9ea1c9c1efbc 100644 (file)
@@ -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
+                    );
+                }
             }
         }
 
index 8417d262302baf536506f48ccde852d01102163b..2cb7a38870bb234a5150d6af4dc20927d42ae2c9 100644 (file)
@@ -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));