}
$this->addNavigation($res, $selectedRawtag);
+ $this->addGlobalVars($res);
return $res;
}
'notes' => $notes,
)
);
+ $this->addGlobalVars($res);
$this->addNavigation($res, $rawtag);
return $res;
'username' => $this->user->getUid(),
)
);
+ $this->addGlobalVars($res);
$this->addNavigation($res, null);
return $res;
return $this->database($reset);
}
+ /**
+ * Register some variables that templates will probably need.
+ *
+ * @return void
+ */
+ protected function addGlobalVars(TemplateResponse $res)
+ {
+ $params = $res->getParams();
+ $params['date'] = \OC::$server->getDateTimeFormatter();
+ $params['urlGen'] = \OC::$server->getURLGenerator();
+ $res->setParams($params);
+ }
+
protected function addNavigation(TemplateResponse $res, $selectedRawtag = null)
{
$nav = new \OCP\Template('grauphel', 'appnavigation', '');
{
$urlGen = \OC::$server->getURLGenerator();
$notes = new NoteStorage($urlGen);
- $notes->setUsername(\OC_User::getUser());
+ $notes->setUsername(
+ \OC::$server->getUserSession()->getUser()->getUID()
+ );
$qp = new QueryParser();
$rows = $notes->search($qp->parse($query));
<div id="app-settings-content" style="display: none;">
<ul>
<li><a href="<?php p(OC::$server->getURLGenerator()->linkToRoute('grauphel.gui.index')); ?>">Info and stats</a></li>
- <?php if (OCP\User::isLoggedIn()) { ?>
+ <?php if (\OC::$server->getUserSession()->isLoggedIn()) { ?>
<li><a href="<?php p(OC::$server->getURLGenerator()->linkToRoute('grauphel.gui.tokens')); ?>">Manage access tokens</a></li>
<li><a href="<?php p(OC::$server->getURLGenerator()->linkToRoute('grauphel.gui.database')); ?>">Manage database</a></li>
<?php } ?>
<h1><?php echo ($_['note']->title); ?></h1>
<p class="muted">
Last modified:
- <?php p(\OCP\Util::formatDate(strtotime($_['note']->{'last-change-date'}))); ?>
+ <?php p($_['date']->formatDate(strtotime($_['note']->{'last-change-date'}))); ?>
</p>
<div class="note-content">
<?php echo $_['note-content']; ?>
<?php foreach ($_['notes'] as $note) { ?>
<tr id="note-<?php p($note['guid']); ?>">
<td>
- <a class="cellclick" href="<?php p(OC::$server->getURLGenerator()->linkToRoute('grauphel.gui.note', array('guid' => $note['guid']))); ?>"><?php echo ($note['title']); ?></a>
+ <a class="cellclick" href="<?php p($_['urlGen']->linkToRoute('grauphel.gui.note', array('guid' => $note['guid']))); ?>"><?php echo ($note['title']); ?></a>
</td>
<td style="color: <?php echo p($note['dateColor']); ?>">
- <?php p(\OCP\Util::formatDate(strtotime($note['last-change-date']))); ?>
+ <?php p($_['date']->formatDate(strtotime($note['last-change-date']))); ?>
</td>
</tr>
<?php } ?>
<td><?php p($token->tokenKey); ?></td>
<td title="<?php p($token->client); ?>"><?php p($_['client']->getNiceName($token->client)); ?></td>
<td>
- <?php p(\OCP\Util::formatDate($token->lastuse)); ?>
+ <?php p($_['date']->formatDate($token->lastuse)); ?>
<form method="POST" action="<?php p(OC::$server->getURLGenerator()->linkToRoute('grauphel.token.delete', array('username' => $_['username'], 'tokenKey' => $token->tokenKey))); ?>">
<input type="hidden" name="delete" value="1" />
<button type="submit" class="icon-delete delete action"