add sidebar
[grauphel.git] / controller / guicontroller.php
index 313bf6987f188180950bfb653e8fd717cf970c1b..06ea681af572b62cba800ed64a9f8de4dcab2c03 100644 (file)
@@ -59,25 +59,37 @@ class GuiController extends Controller
         $this->checkDeps();
 
         $res = new TemplateResponse('grauphel', 'index');
-        $res->setParams(
-            array(
-                //we need to remove the trailing / for tomdroid
-                'apiurl' => rtrim(
-                    $this->urlGen->getAbsoluteURL(
-                        $this->urlGen->linkToRoute('grauphel.gui.index')
-                    ),
-                    '/'
-                )
-            )
-        );
+        $res->setParams(array('apiurl' => $this->getApiUrl()));
+        $this->addNavigation($res);
         return $res;
     }
 
+    protected function addNavigation(TemplateResponse $res)
+    {
+        $nav = new \OCP\Template('grauphel', 'appnavigation', '');
+        $nav->assign('apiurl', $this->getApiUrl());
+
+        $params = $res->getParams();
+        $params['appNavigation'] = $nav;
+        $res->setParams($params);
+    }
+
     protected function checkDeps()
     {
         if (!class_exists('OAuthProvider')) {
             throw new \Exception('PHP extension "oauth" is required');
         }
     }
+
+    protected function getApiUrl()
+    {
+        //we need to remove the trailing / for tomdroid and conboy
+        return rtrim(
+            $this->urlGen->getAbsoluteURL(
+                $this->urlGen->linkToRoute('grauphel.gui.index')
+            ),
+            '/'
+        );
+    }
 }
 ?>