diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2018-10-07 11:44:54 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2018-10-07 11:44:54 +0200 |
| commit | 076545376eb1ce47de2135373fb858db5a411e8c (patch) | |
| tree | f145250df7bbf0d9a937cdb4898d8410babc2a26 | |
| parent | 9e6dc3ebf5ec6cfbfd16fb095311635cc75fe637 (diff) | |
| download | grauphel-076545376eb1ce47de2135373fb858db5a411e8c.tar.gz grauphel-076545376eb1ce47de2135373fb858db5a411e8c.zip | |
Get rid of deprecated API usage:
- \OC_User
- \OCP\User
- \OCP\Util::formatDate
Resolves: https://github.com/cweiske/grauphel/issues/69
| -rw-r--r-- | controller/guicontroller.php | 16 | ||||
| -rw-r--r-- | lib/search/provider.php | 4 | ||||
| -rw-r--r-- | templates/appnavigation.php | 2 | ||||
| -rw-r--r-- | templates/gui-note.php | 2 | ||||
| -rw-r--r-- | templates/tag.php | 4 | ||||
| -rw-r--r-- | templates/tokens.php | 2 |
6 files changed, 24 insertions, 6 deletions
diff --git a/controller/guicontroller.php b/controller/guicontroller.php index d48296d..ef109a7 100644 --- a/controller/guicontroller.php +++ b/controller/guicontroller.php @@ -146,6 +146,7 @@ class GuiController extends Controller } $this->addNavigation($res, $selectedRawtag); + $this->addGlobalVars($res); return $res; } @@ -196,6 +197,7 @@ class GuiController extends Controller 'notes' => $notes, ) ); + $this->addGlobalVars($res); $this->addNavigation($res, $rawtag); return $res; @@ -220,6 +222,7 @@ class GuiController extends Controller 'username' => $this->user->getUid(), ) ); + $this->addGlobalVars($res); $this->addNavigation($res, null); return $res; @@ -260,6 +263,19 @@ class GuiController extends Controller 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', ''); diff --git a/lib/search/provider.php b/lib/search/provider.php index b395778..816209e 100644 --- a/lib/search/provider.php +++ b/lib/search/provider.php @@ -39,7 +39,9 @@ class Provider extends \OCP\Search\Provider { $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)); diff --git a/templates/appnavigation.php b/templates/appnavigation.php index 7d51049..72e30b6 100644 --- a/templates/appnavigation.php +++ b/templates/appnavigation.php @@ -12,7 +12,7 @@ <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 } ?> diff --git a/templates/gui-note.php b/templates/gui-note.php index 2aa5a20..bb8d03e 100644 --- a/templates/gui-note.php +++ b/templates/gui-note.php @@ -14,7 +14,7 @@ <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']; ?> diff --git a/templates/tag.php b/templates/tag.php index ee5f592..e8e092e 100644 --- a/templates/tag.php +++ b/templates/tag.php @@ -19,10 +19,10 @@ <?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 } ?> diff --git a/templates/tokens.php b/templates/tokens.php index 9fe7dd6..9d812eb 100644 --- a/templates/tokens.php +++ b/templates/tokens.php @@ -26,7 +26,7 @@ <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" |
