X-Git-Url: https://git.cweiske.de/grauphel.git/blobdiff_plain/849cf18b89186163bc3695c5a0eb2908471b95b3..92943b3dbac9db26d95500e129bd70475c376b1e:/controller/guicontroller.php diff --git a/controller/guicontroller.php b/controller/guicontroller.php index 79c6447..06ea681 100644 --- a/controller/guicontroller.php +++ b/controller/guicontroller.php @@ -56,18 +56,40 @@ 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' - ) - ), - ) - ); + $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') + ), + '/' + ); } } ?>