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 .= "