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 e48a52d..f815689 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 5728efe..ea9d332 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 8417d26..2cb7a38 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));