* */ namespace ComboStrap; use dokuwiki\Menu\Item\AbstractItem; /** * Class MenuItem * * * @package ComboStrap * * To be able to debug, disable the trigger data attribute * The popover will stay on the page */ class HistoricalBreadcrumbMenuItem extends AbstractItem { const RECENT_PAGES_VISITED = "Recent Pages Visited"; /** * This unique name should not be in the {@link \action_plugin_combo_historicalbreadcrumb} * to avoid circular reference */ const HISTORICAL_BREADCRUMB_NAME = "historical-breadcrumb"; const CANONICAL = "breadcrumb"; public function __construct() { /** * Making popover active */ $snippetManager = PluginUtility::getSnippetManager(); $snippetManager ->addPopoverLibrary() ->attachJavascriptFromComponentId(HistoricalBreadcrumbMenuItem::HISTORICAL_BREADCRUMB_NAME); /** * Css */ $snippetManager->attachCssInternalStylesheet(HistoricalBreadcrumbMenuItem::HISTORICAL_BREADCRUMB_NAME); parent::__construct(); } /** * * @return string */ public function getLabel(): string { return self::RECENT_PAGES_VISITED; } public function getLinkAttributes($classprefix = 'menuitem '): array { $linkAttributes = parent::getLinkAttributes($classprefix); $linkAttributes['href'] = "#"; $dataAttributeNamespace = Bootstrap::getDataNamespace(); $linkAttributes["data{$dataAttributeNamespace}-toggle"] = "popover"; $linkAttributes["data{$dataAttributeNamespace}-placement"] = "left"; $linkAttributes["data{$dataAttributeNamespace}-html"] = "true"; global $lang; $linkAttributes["data{$dataAttributeNamespace}-title"] = $lang['breadcrumb']; $pages = breadcrumbs(); if (sizeof($pages) === 0) { // happens when there is no history return $linkAttributes; } $pages = array_reverse($pages); /** * All page should be shown, * also the actual * because when the user is going * in admin mode, it's an easy way to get back */ $actualPageId = array_keys($pages)[0]; $actualPageName = array_shift($pages); $html = $this->createLink($actualPageId, $actualPageName, self::HISTORICAL_BREADCRUMB_NAME . "-home"); $html .= '