9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/grauphel.htm
14 namespace OCA\Grauphel\Controller;
16 use \OCP\AppFramework\Controller;
17 use \OCP\AppFramework\Http\TemplateResponse;
24 * @author Christian Weiske <cweiske@cweiske.de>
25 * @copyright 2014 Christian Weiske
26 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
27 * @version Release: @package_version@
28 * @link http://cweiske.de/grauphel.htm
30 class GuiController extends Controller
33 * constructor of the controller
35 * @param string $appName Name of the app
36 * @param IRequest $request Instance of the request
38 public function __construct($appName, \OCP\IRequest $request, $user, $urlGen)
40 parent::__construct($appName, $request);
42 $this->urlGen = $urlGen;
44 //default http header: we assume something is broken
45 header('HTTP/1.0 500 Internal Server Error');
51 * Tomdroid wants this to be a public page. Sync fails otherwise.
57 public function index()
61 $res = new TemplateResponse('grauphel', 'index');
62 $res->setParams(array('apiurl' => $this->getApiUrl()));
63 $this->addNavigation($res);
67 protected function addNavigation(TemplateResponse $res)
69 $nav = new \OCP\Template('grauphel', 'appnavigation', '');
70 $nav->assign('apiurl', $this->getApiUrl());
72 $params = $res->getParams();
73 $params['appNavigation'] = $nav;
74 $res->setParams($params);
77 protected function checkDeps()
79 if (!class_exists('OAuthProvider')) {
80 throw new \Exception('PHP extension "oauth" is required');
84 protected function getApiUrl()
86 //we need to remove the trailing / for tomdroid and conboy
88 $this->urlGen->getAbsoluteURL(
89 $this->urlGen->linkToRoute('grauphel.gui.index')