Initial commit
This commit is contained in:
253
content/inc/Menu/Item/AbstractItem.php
Normal file
253
content/inc/Menu/Item/AbstractItem.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?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 && $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
|
||||
);
|
||||
}
|
||||
}
|
28
content/inc/Menu/Item/Admin.php
Normal file
28
content/inc/Menu/Item/Admin.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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() {
|
||||
parent::__construct();
|
||||
|
||||
$this->svg = DOKU_INC . 'lib/images/menu/settings.svg';
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function visibleInContext($ctx)
|
||||
{
|
||||
global $INFO;
|
||||
if(!$INFO['ismanager']) return false;
|
||||
|
||||
return parent::visibleInContext($ctx);
|
||||
}
|
||||
|
||||
}
|
29
content/inc/Menu/Item/Back.php
Normal file
29
content/inc/Menu/Item/Back.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
18
content/inc/Menu/Item/Backlink.php
Normal file
18
content/inc/Menu/Item/Backlink.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
65
content/inc/Menu/Item/Edit.php
Normal file
65
content/inc/Menu/Item/Edit.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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("source")) 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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
24
content/inc/Menu/Item/ImgBackto.php
Normal file
24
content/inc/Menu/Item/ImgBackto.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
27
content/inc/Menu/Item/Index.php
Normal file
27
content/inc/Menu/Item/Index.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
29
content/inc/Menu/Item/Login.php
Normal file
29
content/inc/Menu/Item/Login.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
21
content/inc/Menu/Item/Media.php
Normal file
21
content/inc/Menu/Item/Media.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
32
content/inc/Menu/Item/MediaManager.php
Normal file
32
content/inc/Menu/Item/MediaManager.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
24
content/inc/Menu/Item/Profile.php
Normal file
24
content/inc/Menu/Item/Profile.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
20
content/inc/Menu/Item/Recent.php
Normal file
20
content/inc/Menu/Item/Recent.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
24
content/inc/Menu/Item/Register.php
Normal file
24
content/inc/Menu/Item/Register.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
24
content/inc/Menu/Item/Resendpwd.php
Normal file
24
content/inc/Menu/Item/Resendpwd.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
26
content/inc/Menu/Item/Revert.php
Normal file
26
content/inc/Menu/Item/Revert.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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(!$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';
|
||||
}
|
||||
|
||||
}
|
21
content/inc/Menu/Item/Revisions.php
Normal file
21
content/inc/Menu/Item/Revisions.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
24
content/inc/Menu/Item/Subscribe.php
Normal file
24
content/inc/Menu/Item/Subscribe.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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';
|
||||
}
|
||||
|
||||
}
|
36
content/inc/Menu/Item/Top.php
Normal file
36
content/inc/Menu/Item/Top.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user