From 4bb2fc4a55c12e16c9272726ea842cce055177a2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Thu, 25 May 2017 15:29:27 +0200 Subject: [PATCH] overwrite item properties in constructor only Othewise weird side effects may happen when a parent constructor overwrites them again. --- inc/Menu/Item/Admin.php | 4 ++-- inc/Menu/Item/Backlink.php | 6 +++++- inc/Menu/Item/Index.php | 3 +-- inc/Menu/Item/Login.php | 3 +-- inc/Menu/Item/Media.php | 5 ++--- inc/Menu/Item/MediaManager.php | 4 ++-- inc/Menu/Item/Profile.php | 4 ++-- inc/Menu/Item/Revisions.php | 1 + inc/Menu/Item/Subscribe.php | 4 ++-- inc/Menu/Item/Top.php | 15 ++++++++++----- 10 files changed, 28 insertions(+), 21 deletions(-) diff --git a/inc/Menu/Item/Admin.php b/inc/Menu/Item/Admin.php index 197f2c6da..7302f0f34 100644 --- a/inc/Menu/Item/Admin.php +++ b/inc/Menu/Item/Admin.php @@ -9,13 +9,13 @@ namespace dokuwiki\Menu\Item; */ class Admin extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/settings.svg'; - /** @inheritdoc */ public function __construct() { global $INFO; parent::__construct(); + $this->svg = DOKU_INC . 'lib/images/menu/settings.svg'; + if(!$INFO['ismanager']) { throw new \RuntimeException("admin is for managers only"); } diff --git a/inc/Menu/Item/Backlink.php b/inc/Menu/Item/Backlink.php index 996bcb20b..6dc242bdd 100644 --- a/inc/Menu/Item/Backlink.php +++ b/inc/Menu/Item/Backlink.php @@ -9,6 +9,10 @@ namespace dokuwiki\Menu\Item; */ class Backlink extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/08-backlink_link-variant.svg'; + /** @inheritdoc */ + public function __construct() { + parent::__construct(); + $this->svg = DOKU_INC . 'lib/images/menu/08-backlink_link-variant.svg'; + } } diff --git a/inc/Menu/Item/Index.php b/inc/Menu/Item/Index.php index 5ae35b23f..41326738b 100644 --- a/inc/Menu/Item/Index.php +++ b/inc/Menu/Item/Index.php @@ -9,8 +9,6 @@ namespace dokuwiki\Menu\Item; */ class Index extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/file-tree.svg'; - /** @inheritdoc */ public function __construct() { global $conf; @@ -18,6 +16,7 @@ class Index extends AbstractItem { parent::__construct(); $this->accesskey = 'x'; + $this->svg = DOKU_INC . 'lib/images/menu/file-tree.svg'; // allow searchbots to get to the sitemap from the homepage (when dokuwiki isn't providing a sitemap.xml) if($conf['start'] == $ID && !$conf['sitemap']) { diff --git a/inc/Menu/Item/Login.php b/inc/Menu/Item/Login.php index d2b3ccd47..671f6a78a 100644 --- a/inc/Menu/Item/Login.php +++ b/inc/Menu/Item/Login.php @@ -9,13 +9,12 @@ namespace dokuwiki\Menu\Item; */ class Login extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/login.svg'; - /** @inheritdoc */ public function __construct() { global $INPUT; parent::__construct(); + $this->svg = DOKU_INC . 'lib/images/menu/login.svg'; $this->params['sectok'] = getSecurityToken(); if($INPUT->server->has('REMOTE_USER')) { if(!actionOK('logout')) { diff --git a/inc/Menu/Item/Media.php b/inc/Menu/Item/Media.php index b2d7667a3..0e5f47bae 100644 --- a/inc/Menu/Item/Media.php +++ b/inc/Menu/Item/Media.php @@ -9,14 +9,13 @@ namespace dokuwiki\Menu\Item; */ class Media extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/folder-multiple-image.svg'; - /** @inheritdoc */ public function __construct() { global $ID; parent::__construct(); - $params['ns'] = getNS($ID); + $this->svg = DOKU_INC . 'lib/images/menu/folder-multiple-image.svg'; + $this->params['ns'] = getNS($ID); } } diff --git a/inc/Menu/Item/MediaManager.php b/inc/Menu/Item/MediaManager.php index 146b56f7c..b89644351 100644 --- a/inc/Menu/Item/MediaManager.php +++ b/inc/Menu/Item/MediaManager.php @@ -9,8 +9,6 @@ namespace dokuwiki\Menu\Item; */ class MediaManager extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/11-mediamanager_folder-image.svg'; - /** @inheritdoc */ public function __construct() { global $IMG; @@ -21,6 +19,8 @@ class MediaManager extends AbstractItem { if($authNS < AUTH_UPLOAD) { throw new \RuntimeException("media manager link only with upload permissions"); } + + $this->svg = DOKU_INC . 'lib/images/menu/11-mediamanager_folder-image.svg'; $this->params = array( 'ns' => $imgNS, 'image' => $IMG, diff --git a/inc/Menu/Item/Profile.php b/inc/Menu/Item/Profile.php index 237d10a2e..2b4ceeb77 100644 --- a/inc/Menu/Item/Profile.php +++ b/inc/Menu/Item/Profile.php @@ -9,8 +9,6 @@ namespace dokuwiki\Menu\Item; */ class Profile extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/account-card-details.svg'; - /** @inheritdoc */ public function __construct() { global $INPUT; @@ -19,6 +17,8 @@ class Profile extends AbstractItem { if(!$INPUT->server->str('REMOTE_USER')) { throw new \RuntimeException("profile is only for logged in users"); } + + $this->svg = DOKU_INC . 'lib/images/menu/account-card-details.svg'; } } diff --git a/inc/Menu/Item/Revisions.php b/inc/Menu/Item/Revisions.php index 648b4a8a3..3009a7924 100644 --- a/inc/Menu/Item/Revisions.php +++ b/inc/Menu/Item/Revisions.php @@ -13,6 +13,7 @@ class Revisions extends AbstractItem { public function __construct() { parent::__construct(); + $this->accesskey = 'o'; $this->type = 'revs'; $this->svg = DOKU_INC . 'lib/images/menu/07-revisions_history.svg'; } diff --git a/inc/Menu/Item/Subscribe.php b/inc/Menu/Item/Subscribe.php index 617bacca9..1c9d335f8 100644 --- a/inc/Menu/Item/Subscribe.php +++ b/inc/Menu/Item/Subscribe.php @@ -9,8 +9,6 @@ namespace dokuwiki\Menu\Item; */ class Subscribe extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/09-subscribe_email-outline.svg'; - /** @inheritdoc */ public function __construct() { global $INPUT; @@ -19,6 +17,8 @@ class Subscribe extends AbstractItem { if(!$INPUT->server->str('REMOTE_USER')) { throw new \RuntimeException("subscribe is only for logged in users"); } + + $this->svg = DOKU_INC . 'lib/images/menu/09-subscribe_email-outline.svg'; } } diff --git a/inc/Menu/Item/Top.php b/inc/Menu/Item/Top.php index 78181d0d5..a7e4cb24b 100644 --- a/inc/Menu/Item/Top.php +++ b/inc/Menu/Item/Top.php @@ -10,10 +10,15 @@ namespace dokuwiki\Menu\Item; */ class Top extends AbstractItem { - protected $svg = DOKU_INC . 'lib/images/menu/10-top_arrow-up.svg'; - protected $accesskey = 't'; - protected $params = array('do' => ''); - protected $id = '#dokuwiki__top'; - protected $context = self::CTX_DESKTOP; + /** @inheritdoc */ + public function __construct() { + parent::__construct(); + + $this->svg = DOKU_INC . 'lib/images/menu/10-top_arrow-up.svg'; + $this->accesskey = 't'; + $this->params = array('do' => ''); + $this->id = '#dokuwiki__top'; + $this->context = self::CTX_DESKTOP; + } } -- GitLab