ajout de la partie slam dans le dossier web
This commit is contained in:
		
							
								
								
									
										96
									
								
								ap23/web/doku/inc/Menu/AbstractMenu.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								ap23/web/doku/inc/Menu/AbstractMenu.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| use dokuwiki\Extension\Event; | ||||
| use dokuwiki\Menu\Item\AbstractItem; | ||||
|  | ||||
| /** | ||||
|  * Class AbstractMenu | ||||
|  * | ||||
|  * Basic menu functionality. A menu defines a list of AbstractItem that shall be shown. | ||||
|  * It contains convenience functions to display the menu in HTML, but template authors can also | ||||
|  * just accesst the items via getItems() and create the HTML as however they see fit. | ||||
|  */ | ||||
| abstract class AbstractMenu implements MenuInterface { | ||||
|  | ||||
|     /** @var string[] list of Item classes to load */ | ||||
|     protected $types = array(); | ||||
|  | ||||
|     /** @var int the context this menu is used in */ | ||||
|     protected $context = AbstractItem::CTX_DESKTOP; | ||||
|  | ||||
|     /** @var string view identifier to be set in the event */ | ||||
|     protected $view = ''; | ||||
|  | ||||
|     /** | ||||
|      * AbstractMenu constructor. | ||||
|      * | ||||
|      * @param int $context the context this menu is used in | ||||
|      */ | ||||
|     public function __construct($context = AbstractItem::CTX_DESKTOP) { | ||||
|         $this->context = $context; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the list of action items in this menu | ||||
|      * | ||||
|      * @return AbstractItem[] | ||||
|      * @triggers MENU_ITEMS_ASSEMBLY | ||||
|      */ | ||||
|     public function getItems() { | ||||
|         $data = array( | ||||
|             'view' => $this->view, | ||||
|             'items' => array(), | ||||
|         ); | ||||
|         Event::createAndTrigger('MENU_ITEMS_ASSEMBLY', $data, array($this, 'loadItems')); | ||||
|         return $data['items']; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Default action for the MENU_ITEMS_ASSEMBLY event | ||||
|      * | ||||
|      * @see getItems() | ||||
|      * @param array $data The plugin data | ||||
|      */ | ||||
|     public function loadItems(&$data) { | ||||
|         foreach($this->types as $class) { | ||||
|             try { | ||||
|                 $class = "\\dokuwiki\\Menu\\Item\\$class"; | ||||
|                 /** @var AbstractItem $item */ | ||||
|                 $item = new $class(); | ||||
|                 if(!$item->visibleInContext($this->context)) continue; | ||||
|                 $data['items'][] = $item; | ||||
|             } catch(\RuntimeException $ignored) { | ||||
|                 // item not available | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Generate HTML list items for this menu | ||||
|      * | ||||
|      * This is a convenience method for template authors. If you need more fine control over the | ||||
|      * output, use getItems() and build the HTML yourself | ||||
|      * | ||||
|      * @param string|false $classprefix create a class from type with this prefix, false for no class | ||||
|      * @param bool $svg add the SVG link | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getListItems($classprefix = '', $svg = true) { | ||||
|         $html = ''; | ||||
|         foreach($this->getItems() as $item) { | ||||
|             if($classprefix !== false) { | ||||
|                 $class = ' class="' . $classprefix . $item->getType() . '"'; | ||||
|             } else { | ||||
|                 $class = ''; | ||||
|             } | ||||
|  | ||||
|             $html .= "<li$class>"; | ||||
|             $html .= $item->asHtmlLink(false, $svg); | ||||
|             $html .= '</li>'; | ||||
|         } | ||||
|         return $html; | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										21
									
								
								ap23/web/doku/inc/Menu/DetailMenu.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								ap23/web/doku/inc/Menu/DetailMenu.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| /** | ||||
|  * Class DetailMenu | ||||
|  * | ||||
|  * This menu offers options on an image detail view. It usually displayed similar to | ||||
|  * the PageMenu. | ||||
|  */ | ||||
| class DetailMenu extends AbstractMenu { | ||||
|  | ||||
|     protected $view = 'detail'; | ||||
|  | ||||
|     protected $types = array( | ||||
|         'MediaManager', | ||||
|         'ImgBackto', | ||||
|         'Top', | ||||
|     ); | ||||
|  | ||||
| } | ||||
							
								
								
									
										253
									
								
								ap23/web/doku/inc/Menu/Item/AbstractItem.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										253
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Admin.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Back.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Backlink.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Edit.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/ImgBackto.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Login.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Media.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/MediaManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Profile.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Recent.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Register.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Resendpwd.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Revert.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Revisions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Subscribe.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								ap23/web/doku/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
									
								
								ap23/web/doku/inc/Menu/Item/Top.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								ap23/web/doku/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(); | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										20
									
								
								ap23/web/doku/inc/Menu/MenuInterface.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ap23/web/doku/inc/Menu/MenuInterface.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| use dokuwiki\Menu\Item\AbstractItem; | ||||
|  | ||||
| /** | ||||
|  * Interface MenuInterface | ||||
|  * | ||||
|  * Defines what a Menu provides | ||||
|  */ | ||||
| Interface MenuInterface { | ||||
|  | ||||
|     /** | ||||
|      * Get the list of action items in this menu | ||||
|      * | ||||
|      * @return AbstractItem[] | ||||
|      */ | ||||
|     public function getItems(); | ||||
| } | ||||
							
								
								
									
										93
									
								
								ap23/web/doku/inc/Menu/MobileMenu.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								ap23/web/doku/inc/Menu/MobileMenu.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| use dokuwiki\Menu\Item\AbstractItem; | ||||
|  | ||||
| /** | ||||
|  * Class MobileMenu | ||||
|  * | ||||
|  * Note: this does not inherit from AbstractMenu because it is not working like the other | ||||
|  * menus. This is a meta menu, aggregating the items from the other menus and offering a combined | ||||
|  * view. The idea is to use this on mobile devices, thus the context is fixed to CTX_MOBILE | ||||
|  */ | ||||
| class MobileMenu implements MenuInterface { | ||||
|  | ||||
|     /** | ||||
|      * Returns all items grouped by view | ||||
|      * | ||||
|      * @return AbstractItem[][] | ||||
|      */ | ||||
|     public function getGroupedItems() { | ||||
|         $pagemenu = new PageMenu(AbstractItem::CTX_MOBILE); | ||||
|         $sitemenu = new SiteMenu(AbstractItem::CTX_MOBILE); | ||||
|         $usermenu = new UserMenu(AbstractItem::CTX_MOBILE); | ||||
|  | ||||
|         return array( | ||||
|             'page' => $pagemenu->getItems(), | ||||
|             'site' => $sitemenu->getItems(), | ||||
|             'user' => $usermenu->getItems() | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get all items in a flat array | ||||
|      * | ||||
|      * This returns the same format as AbstractMenu::getItems() | ||||
|      * | ||||
|      * @return AbstractItem[] | ||||
|      */ | ||||
|     public function getItems() { | ||||
|         $menu = $this->getGroupedItems(); | ||||
|         return call_user_func_array('array_merge', array_values($menu)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Print a dropdown menu with all DokuWiki actions | ||||
|      * | ||||
|      * Note: this will not use any pretty URLs | ||||
|      * | ||||
|      * @param string $empty empty option label | ||||
|      * @param string $button submit button label | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getDropdown($empty = '', $button = '>') { | ||||
|         global $ID; | ||||
|         global $REV; | ||||
|         /** @var string[] $lang */ | ||||
|         global $lang; | ||||
|         global $INPUT; | ||||
|  | ||||
|         $html = '<form action="' . script() . '" method="get" accept-charset="utf-8">'; | ||||
|         $html .= '<div class="no">'; | ||||
|         $html .= '<input type="hidden" name="id" value="' . $ID . '" />'; | ||||
|         if($REV) $html .= '<input type="hidden" name="rev" value="' . $REV . '" />'; | ||||
|         if($INPUT->server->str('REMOTE_USER')) { | ||||
|             $html .= '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />'; | ||||
|         } | ||||
|  | ||||
|         $html .= '<select name="do" class="edit quickselect" title="' . $lang['tools'] . '">'; | ||||
|         $html .= '<option value="">' . $empty . '</option>'; | ||||
|  | ||||
|         foreach($this->getGroupedItems() as $tools => $items) { | ||||
|             if (count($items)) { | ||||
|                 $html .= '<optgroup label="' . $lang[$tools . '_tools'] . '">'; | ||||
|                 foreach($items as $item) { | ||||
|                     $params = $item->getParams(); | ||||
|                     $html .= '<option value="' . $params['do'] . '">'; | ||||
|                     $html .= hsc($item->getLabel()); | ||||
|                     $html .= '</option>'; | ||||
|                 } | ||||
|                 $html .= '</optgroup>'; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $html .= '</select>'; | ||||
|         $html .= '<button type="submit">' . $button . '</button>'; | ||||
|         $html .= '</div>'; | ||||
|         $html .= '</form>'; | ||||
|  | ||||
|         return $html; | ||||
|     } | ||||
|  | ||||
| } | ||||
							
								
								
									
										23
									
								
								ap23/web/doku/inc/Menu/PageMenu.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								ap23/web/doku/inc/Menu/PageMenu.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| /** | ||||
|  * Class PageMenu | ||||
|  * | ||||
|  * Actions manipulating the current page. Shown as a floating menu in the dokuwiki template | ||||
|  */ | ||||
| class PageMenu extends AbstractMenu { | ||||
|  | ||||
|     protected $view = 'page'; | ||||
|  | ||||
|     protected $types = array( | ||||
|         'Edit', | ||||
|         'Revert', | ||||
|         'Revisions', | ||||
|         'Backlink', | ||||
|         'Subscribe', | ||||
|         'Top', | ||||
|     ); | ||||
|  | ||||
| } | ||||
							
								
								
									
										20
									
								
								ap23/web/doku/inc/Menu/SiteMenu.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ap23/web/doku/inc/Menu/SiteMenu.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| /** | ||||
|  * Class SiteMenu | ||||
|  * | ||||
|  * Actions that are not bound to an individual page but provide toolsfor the whole wiki. | ||||
|  */ | ||||
| class SiteMenu extends AbstractMenu { | ||||
|  | ||||
|     protected $view = 'site'; | ||||
|  | ||||
|     protected $types = array( | ||||
|         'Recent', | ||||
|         'Media', | ||||
|         'Index' | ||||
|     ); | ||||
|  | ||||
| } | ||||
							
								
								
									
										21
									
								
								ap23/web/doku/inc/Menu/UserMenu.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								ap23/web/doku/inc/Menu/UserMenu.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| <?php | ||||
|  | ||||
| namespace dokuwiki\Menu; | ||||
|  | ||||
| /** | ||||
|  * Class UserMenu | ||||
|  * | ||||
|  * Actions related to the current user | ||||
|  */ | ||||
| class UserMenu extends AbstractMenu { | ||||
|  | ||||
|     protected $view = 'user'; | ||||
|  | ||||
|     protected $types = array( | ||||
|         'Profile', | ||||
|         'Admin', | ||||
|         'Register', | ||||
|         'Login', | ||||
|     ); | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user