diff options
author | ahriman <ahriman@falte.red> | 2019-01-02 04:57:35 +0000 |
---|---|---|
committer | ahriman <ahriman@falte.red> | 2019-01-02 04:57:35 +0000 |
commit | 2bd7f83a6495011ada78ca8a9f2af417caf01760 (patch) | |
tree | f9acdb7f09e011c65330ab993d4db3620787dbfb /wiki/inc/Menu/Item | |
parent | bcb215c3a7e914d05f166846a33860e48bba64fb (diff) | |
download | site-2bd7f83a6495011ada78ca8a9f2af417caf01760.tar.gz |
removed dokuwiki
Diffstat (limited to 'wiki/inc/Menu/Item')
-rw-r--r-- | wiki/inc/Menu/Item/AbstractItem.php | 253 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Admin.php | 24 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Back.php | 29 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Backlink.php | 18 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Edit.php | 65 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/ImgBackto.php | 24 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Index.php | 27 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Login.php | 29 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Media.php | 21 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/MediaManager.php | 32 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Profile.php | 24 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Recent.php | 20 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Register.php | 24 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Resendpwd.php | 24 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Revert.php | 26 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Revisions.php | 21 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Subscribe.php | 24 | ||||
-rw-r--r-- | wiki/inc/Menu/Item/Top.php | 36 |
18 files changed, 0 insertions, 721 deletions
diff --git a/wiki/inc/Menu/Item/AbstractItem.php b/wiki/inc/Menu/Item/AbstractItem.php deleted file mode 100644 index 45ead55..0000000 --- a/wiki/inc/Menu/Item/AbstractItem.php +++ /dev/null @@ -1,253 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class AbstractItem - * - * This class defines a single Item to be displayed in one of DokuWiki's menus. Plugins - * can extend those menus through action plugins and add their own instances of this class, - * overwriting some of its properties. - * - * Items may be shown multiple times in different contexts. Eg. for the default template - * all menus are shown in a Dropdown list on mobile, but are split into several places on - * desktop. The item's $context property can be used to hide the item depending on the current - * context. - * - * Children usually just need to overwrite the different properties, but for complex things - * the accessors may be overwritten instead. - */ -abstract class AbstractItem { - - /** menu item is to be shown on desktop screens only */ - const CTX_DESKTOP = 1; - /** menu item is to be shown on mobile screens only */ - const CTX_MOBILE = 2; - /** menu item is to be shown in all contexts */ - const CTX_ALL = 3; - - /** @var string name of the action, usually the lowercase class name */ - protected $type = ''; - /** @var string optional keyboard shortcut */ - protected $accesskey = ''; - /** @var string the page id this action links to */ - protected $id = ''; - /** @var string the method to be used when this action is used in a form */ - protected $method = 'get'; - /** @var array parameters for the action (should contain the do parameter) */ - protected $params = array(); - /** @var bool when true, a rel=nofollow should be used */ - protected $nofollow = true; - /** @var string this item's label may contain a placeholder, which is replaced with this */ - protected $replacement = ''; - /** @var string the full path to the SVG icon of this menu item */ - protected $svg = DOKU_INC . 'lib/images/menu/00-default_checkbox-blank-circle-outline.svg'; - /** @var string can be set to overwrite the default lookup in $lang.btn_* */ - protected $label = ''; - /** @var string the tooltip title, defaults to $label */ - protected $title = ''; - /** @var int the context this titme is shown in */ - protected $context = self::CTX_ALL; - - /** - * AbstractItem constructor. - * - * Sets the dynamic properties - * - * Children should always call the parent constructor! - * - * @throws \RuntimeException when the action is disabled - */ - public function __construct() { - global $ID; - $this->id = $ID; - $this->type = $this->getType(); - $this->params['do'] = $this->type; - - if(!actionOK($this->type)) throw new \RuntimeException("action disabled: {$this->type}"); - } - - /** - * Return this item's label - * - * When the label property was set, it is simply returned. Otherwise, the action's type - * is used to look up the translation in the main language file and, if used, the replacement - * is applied. - * - * @return string - */ - public function getLabel() { - if($this->label !== '') return $this->label; - - /** @var array $lang */ - global $lang; - $label = $lang['btn_' . $this->type]; - if(strpos($label, '%s')) { - $label = sprintf($label, $this->replacement); - } - if($label === '') $label = '[' . $this->type . ']'; - return $label; - } - - /** - * Return this item's title - * - * This title should be used to display a tooltip (using the HTML title attribute). If - * a title property was not explicitly set, the label will be returned. - * - * @return string - */ - public function getTitle() { - if($this->title === '') return $this->getLabel(); - return $this->title; - } - - /** - * Return the link this item links to - * - * Basically runs wl() on $id and $params. However if the ID is a hash it is used directly - * as the link - * - * Please note that the generated URL is *not* XML escaped. - * - * @see wl() - * @return string - */ - public function getLink() { - if($this->id[0] == '#') { - return $this->id; - } else { - return wl($this->id, $this->params, false, '&'); - } - } - - /** - * Convenience method to get the attributes for constructing an <a> element - * - * @see buildAttributes() - * @param string|false $classprefix create a class from type with this prefix, false for no class - * @return array - */ - public function getLinkAttributes($classprefix = 'menuitem ') { - $attr = array( - 'href' => $this->getLink(), - 'title' => $this->getTitle(), - ); - if($this->isNofollow()) $attr['rel'] = 'nofollow'; - if($this->getAccesskey()) { - $attr['accesskey'] = $this->getAccesskey(); - $attr['title'] .= ' [' . $this->getAccesskey() . ']'; - } - if($classprefix !== false) $attr['class'] = $classprefix . $this->getType(); - - return $attr; - } - - /** - * Convenience method to create a full <a> element - * - * Wraps around the label and SVG image - * - * @param string|false $classprefix create a class from type with this prefix, false for no class - * @param bool $svg add SVG icon to the link - * @return string - */ - public function asHtmlLink($classprefix = 'menuitem ', $svg = true) { - $attr = buildAttributes($this->getLinkAttributes($classprefix)); - $html = "<a $attr>"; - if($svg) { - $html .= '<span>' . hsc($this->getLabel()) . '</span>'; - $html .= inlineSVG($this->getSvg()); - } else { - $html .= hsc($this->getLabel()); - } - $html .= "</a>"; - - return $html; - } - - /** - * Convenience method to create a <button> element inside it's own form element - * - * Uses html_btn() - * - * @return string - */ - public function asHtmlButton() { - return html_btn( - $this->getType(), - $this->id, - $this->getAccesskey(), - $this->getParams(), - $this->method, - $this->getTitle(), - $this->getLabel(), - $this->getSvg() - ); - } - - /** - * Should this item be shown in the given context - * - * @param int $ctx the current context - * @return bool - */ - public function visibleInContext($ctx) { - return (bool) ($ctx & $this->context); - } - - /** - * @return string the name of this item - */ - public function getType() { - if($this->type === '') { - $this->type = strtolower(substr(strrchr(get_class($this), '\\'), 1)); - } - return $this->type; - } - - /** - * @return string - */ - public function getAccesskey() { - return $this->accesskey; - } - - /** - * @return array - */ - public function getParams() { - return $this->params; - } - - /** - * @return bool - */ - public function isNofollow() { - return $this->nofollow; - } - - /** - * @return string - */ - public function getSvg() { - return $this->svg; - } - - /** - * Return this Item's settings as an array as used in tpl_get_action() - * - * @return array - */ - public function getLegacyData() { - return array( - 'accesskey' => $this->accesskey ?: null, - 'type' => $this->type, - 'id' => $this->id, - 'method' => $this->method, - 'params' => $this->params, - 'nofollow' => $this->nofollow, - 'replacement' => $this->replacement - ); - } -} diff --git a/wiki/inc/Menu/Item/Admin.php b/wiki/inc/Menu/Item/Admin.php deleted file mode 100644 index 7302f0f..0000000 --- a/wiki/inc/Menu/Item/Admin.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Admin - * - * Opens the Admin screen. Only shown to managers or above - */ -class Admin extends AbstractItem { - - /** @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/wiki/inc/Menu/Item/Back.php b/wiki/inc/Menu/Item/Back.php deleted file mode 100644 index a7cc1d9..0000000 --- a/wiki/inc/Menu/Item/Back.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Back - * - * Navigates back up one namepspace. This is currently not used in any menu. Templates - * would need to add this item manually. - */ -class Back extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $ID; - parent::__construct(); - - $parent = tpl_getparent($ID); - if(!$parent) { - throw new \RuntimeException("No parent for back action"); - } - - $this->id = $parent; - $this->params = array('do' => ''); - $this->accesskey = 'b'; - $this->svg = DOKU_INC . 'lib/images/menu/12-back_arrow-left.svg'; - } - -} diff --git a/wiki/inc/Menu/Item/Backlink.php b/wiki/inc/Menu/Item/Backlink.php deleted file mode 100644 index 6dc242b..0000000 --- a/wiki/inc/Menu/Item/Backlink.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Backlink - * - * Shows the backlinks for the current page - */ -class Backlink extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - parent::__construct(); - $this->svg = DOKU_INC . 'lib/images/menu/08-backlink_link-variant.svg'; - } - -} diff --git a/wiki/inc/Menu/Item/Edit.php b/wiki/inc/Menu/Item/Edit.php deleted file mode 100644 index 5de1778..0000000 --- a/wiki/inc/Menu/Item/Edit.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Edit - * - * Most complex item. Shows the edit button but mutates to show, draft and create based on - * current state. - */ -class Edit extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $ACT; - global $INFO; - global $REV; - - parent::__construct(); - - if($ACT === 'show') { - $this->method = 'post'; - if($INFO['writable']) { - $this->accesskey = 'e'; - if(!empty($INFO['draft'])) { - $this->type = 'draft'; - $this->params['do'] = 'draft'; - } else { - $this->params['rev'] = $REV; - if(!$INFO['exists']) { - $this->type = 'create'; - } - } - } else { - if(!actionOK($this->type)) throw new \RuntimeException("action disabled: source"); - $params['rev'] = $REV; - $this->type = 'source'; - $this->accesskey = 'v'; - } - } else { - $this->params = array('do' => ''); - $this->type = 'show'; - $this->accesskey = 'v'; - } - - $this->setIcon(); - } - - /** - * change the icon according to what type the edit button has - */ - protected function setIcon() { - $icons = array( - 'edit' => '01-edit_pencil.svg', - 'create' => '02-create_pencil.svg', - 'draft' => '03-draft_android-studio.svg', - 'show' => '04-show_file-document.svg', - 'source' => '05-source_file-xml.svg', - ); - if(isset($icons[$this->type])) { - $this->svg = DOKU_INC . 'lib/images/menu/' . $icons[$this->type]; - } - } - -} diff --git a/wiki/inc/Menu/Item/ImgBackto.php b/wiki/inc/Menu/Item/ImgBackto.php deleted file mode 100644 index 72820a5..0000000 --- a/wiki/inc/Menu/Item/ImgBackto.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class ImgBackto - * - * Links back to the originating page from a detail image view - */ -class ImgBackto extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $ID; - parent::__construct(); - - $this->svg = DOKU_INC . 'lib/images/menu/12-back_arrow-left.svg'; - $this->type = 'img_backto'; - $this->params = array(); - $this->accesskey = 'b'; - $this->replacement = $ID; - } - -} diff --git a/wiki/inc/Menu/Item/Index.php b/wiki/inc/Menu/Item/Index.php deleted file mode 100644 index 4132673..0000000 --- a/wiki/inc/Menu/Item/Index.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Index - * - * Shows the sitemap - */ -class Index extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $conf; - global $ID; - 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']) { - $this->nofollow = false; - } - } - -} diff --git a/wiki/inc/Menu/Item/Login.php b/wiki/inc/Menu/Item/Login.php deleted file mode 100644 index 671f6a7..0000000 --- a/wiki/inc/Menu/Item/Login.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Login - * - * Show a login or logout item, based on the current state - */ -class Login extends AbstractItem { - - /** @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')) { - throw new \RuntimeException("logout disabled"); - } - $this->params['do'] = 'logout'; - $this->type = 'logout'; - $this->svg = DOKU_INC . 'lib/images/menu/logout.svg'; - } - } - -} diff --git a/wiki/inc/Menu/Item/Media.php b/wiki/inc/Menu/Item/Media.php deleted file mode 100644 index 0e5f47b..0000000 --- a/wiki/inc/Menu/Item/Media.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Media - * - * Opens the media manager - */ -class Media extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $ID; - parent::__construct(); - - $this->svg = DOKU_INC . 'lib/images/menu/folder-multiple-image.svg'; - $this->params['ns'] = getNS($ID); - } - -} diff --git a/wiki/inc/Menu/Item/MediaManager.php b/wiki/inc/Menu/Item/MediaManager.php deleted file mode 100644 index 8549d20..0000000 --- a/wiki/inc/Menu/Item/MediaManager.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class MediaManager - * - * Opens the current image in the media manager. Used on image detail view. - */ -class MediaManager extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $IMG; - parent::__construct(); - - $imgNS = getNS($IMG); - $authNS = auth_quickaclcheck("$imgNS:*"); - 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->type = 'mediaManager'; - $this->params = array( - 'ns' => $imgNS, - 'image' => $IMG, - 'do' => 'media' - ); - } - -} diff --git a/wiki/inc/Menu/Item/Profile.php b/wiki/inc/Menu/Item/Profile.php deleted file mode 100644 index 2b4ceeb..0000000 --- a/wiki/inc/Menu/Item/Profile.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Profile - * - * Open the user's profile - */ -class Profile extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $INPUT; - parent::__construct(); - - 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/wiki/inc/Menu/Item/Recent.php b/wiki/inc/Menu/Item/Recent.php deleted file mode 100644 index ff90ce6..0000000 --- a/wiki/inc/Menu/Item/Recent.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Recent - * - * Show the site wide recent changes - */ -class Recent extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - parent::__construct(); - - $this->accesskey = 'r'; - $this->svg = DOKU_INC . 'lib/images/menu/calendar-clock.svg'; - } - -} diff --git a/wiki/inc/Menu/Item/Register.php b/wiki/inc/Menu/Item/Register.php deleted file mode 100644 index 615146e..0000000 --- a/wiki/inc/Menu/Item/Register.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Register - * - * Open the view to register a new account - */ -class Register extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $INPUT; - parent::__construct(); - - if($INPUT->server->str('REMOTE_USER')) { - throw new \RuntimeException("no register when already logged in"); - } - - $this->svg = DOKU_INC . 'lib/images/menu/account-plus.svg'; - } - -} diff --git a/wiki/inc/Menu/Item/Resendpwd.php b/wiki/inc/Menu/Item/Resendpwd.php deleted file mode 100644 index 7ddc6b0..0000000 --- a/wiki/inc/Menu/Item/Resendpwd.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Resendpwd - * - * Access the "forgot password" dialog - */ -class Resendpwd extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $INPUT; - parent::__construct(); - - if($INPUT->server->str('REMOTE_USER')) { - throw new \RuntimeException("no resendpwd when already logged in"); - } - - $this->svg = DOKU_INC . 'lib/images/menu/lock-reset.svg'; - } - -} diff --git a/wiki/inc/Menu/Item/Revert.php b/wiki/inc/Menu/Item/Revert.php deleted file mode 100644 index a360c68..0000000 --- a/wiki/inc/Menu/Item/Revert.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Revert - * - * Quick revert to the currently shown page revision - */ -class Revert extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $REV; - global $INFO; - parent::__construct(); - - if(!$INFO['ismanager'] || !$REV || !$INFO['writable']) { - throw new \RuntimeException('revert not available'); - } - $this->params['rev'] = $REV; - $this->params['sectok'] = getSecurityToken(); - $this->svg = DOKU_INC . 'lib/images/menu/06-revert_replay.svg'; - } - -} diff --git a/wiki/inc/Menu/Item/Revisions.php b/wiki/inc/Menu/Item/Revisions.php deleted file mode 100644 index 3009a79..0000000 --- a/wiki/inc/Menu/Item/Revisions.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Revisions - * - * Access the old revisions of the current page - */ -class Revisions extends AbstractItem { - - /** @inheritdoc */ - 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/wiki/inc/Menu/Item/Subscribe.php b/wiki/inc/Menu/Item/Subscribe.php deleted file mode 100644 index 1c9d335..0000000 --- a/wiki/inc/Menu/Item/Subscribe.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Subscribe - * - * Access the subscription management view - */ -class Subscribe extends AbstractItem { - - /** @inheritdoc */ - public function __construct() { - global $INPUT; - parent::__construct(); - - 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/wiki/inc/Menu/Item/Top.php b/wiki/inc/Menu/Item/Top.php deleted file mode 100644 index a05c4f1..0000000 --- a/wiki/inc/Menu/Item/Top.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace dokuwiki\Menu\Item; - -/** - * Class Top - * - * Scroll back to the top. Uses a hash as $id which is handled special in getLink(). - * Not shown in mobile context - */ -class Top extends AbstractItem { - - /** @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; - } - - /** - * Convenience method to create a <button> element - * - * Uses html_topbtn() - * - * @todo this does currently not support the SVG icon - * @return string - */ - public function asHtmlButton() { - return html_topbtn(); - } - -} |