fix link output for tomdroid
[grauphel.git] / controller / guicontroller.php
index e3753d7fc0f5f1d8a861323109aeed739799b7ba..313bf6987f188180950bfb653e8fd717cf970c1b 100644 (file)
@@ -29,13 +29,13 @@ use \OCP\AppFramework\Http\TemplateResponse;
  */
 class GuiController extends Controller
 {
-       /**
-        * constructor of the controller
+    /**
+     * constructor of the controller
      *
-        * @param string   $appName Name of the app
-        * @param IRequest $request Instance of the request
-        */
-       public function __construct($appName, \OCP\IRequest $request, $user, $urlGen)
+     * @param string   $appName Name of the app
+     * @param IRequest $request Instance of the request
+     */
+    public function __construct($appName, \OCP\IRequest $request, $user, $urlGen)
     {
         parent::__construct($appName, $request);
         $this->user   = $user;
@@ -56,18 +56,28 @@ class GuiController extends Controller
      */
     public function index()
     {
+        $this->checkDeps();
+
         $res = new TemplateResponse('grauphel', 'index');
         $res->setParams(
             array(
-                'apiurl' => $this->urlGen->getAbsoluteURL(
-                    $this->urlGen->linkToRoute(
-                        'grauphel.gui.index'
-                    )
-                ),
+                //we need to remove the trailing / for tomdroid
+                'apiurl' => rtrim(
+                    $this->urlGen->getAbsoluteURL(
+                        $this->urlGen->linkToRoute('grauphel.gui.index')
+                    ),
+                    '/'
+                )
             )
         );
         return $res;
+    }
 
+    protected function checkDeps()
+    {
+        if (!class_exists('OAuthProvider')) {
+            throw new \Exception('PHP extension "oauth" is required');
+        }
     }
 }
 ?>