+
+ if ($this->user === null) {
+ return;
+ }
+
+ $rawtags = $this->getNotes()->getTags();
+ sort($rawtags);
+ $tags = array();
+ foreach ($rawtags as $rawtag) {
+ if (substr($rawtag, 0, 16) == 'system:notebook:') {
+ $tags[] = array(
+ 'name' => substr($rawtag, 16),
+ 'id' => $rawtag,
+ 'href' => $this->urlGen->linkToRoute(
+ 'grauphel.gui.tag', array('tag' => $rawtag)
+ ),
+ );
+ }
+ }
+ $nav->assign('tags', $tags);
+ }
+
+ protected function addStats(TemplateResponse $res)
+ {
+ if ($this->user === null) {
+ return;
+ }
+
+ $username = $this->user->getUid();
+ $notes = $this->getNotes();
+ $tokens = new \OCA\Grauphel\Lib\TokenStorage();
+
+ $nav = new \OCP\Template('grauphel', 'indexStats', '');
+ $nav->assign('notes', count($notes->loadNotesOverview()));
+ $nav->assign('syncrev', $notes->loadSyncData()->latestSyncRevision);
+ $nav->assign('tokens', count($tokens->loadForUser($username, 'access')));
+
+ $params = $res->getParams();
+ $params['stats'] = $nav;
+ $res->setParams($params);