register_hook( "TPL_METAHEADER_OUTPUT", "BEFORE", $this, "addScripts", ); $controller->register_hook( "TPL_CONTENT_DISPLAY", "BEFORE", $this, "addPageLinkStatus", ); $controller->register_hook( "CSS_STYLES_INCLUDED", "BEFORE", $this, "addTemporaryInputStyles", ); $controller->register_hook( "TOOLBAR_DEFINE", "AFTER", $this, "addToolbarButton", ); } /** * Add plugin JavaScript files in a deterministic order. * * @param Event $event * @param mixed $param * @return void */ public function addScripts(Event $event, $param) { $plugin = $this->getPluginName(); $base = DOKU_BASE . "lib/plugins/$plugin/js/"; $scripts = [ "lightbox.js", "gallery-thumbnails.js", "open-service.js", "scratchpads.js", "date-fix.js", "page-link.js", "linkfavicon.js", "main.js", ]; foreach ($scripts as $script) { $event->data["script"][] = [ "type" => "text/javascript", "src" => $base . $script, ]; } } /** * Include temporary global input styling via css.php so @ini_* placeholders resolve. * * @param Event $event * @param mixed $param * @return void */ public function addTemporaryInputStyles(Event $event, $param) { if (!isset($event->data['mediatype']) || $event->data['mediatype'] !== 'screen') { return; } if (!isset($event->data['files']) || !is_array($event->data['files'])) { return; } $plugin = $this->getPluginName(); $event->data['files'][DOKU_PLUGIN . $plugin . '/temp-input-colors.css'] = DOKU_BASE . 'lib/plugins/' . $plugin . '/'; } /** * Add custom toolbar button for code blocks. * * @param Event $event * @param mixed $param * @return void */ public function addToolbarButton(Event $event, $param) { $event->data[] = [ "type" => "format", "title" => $this->getLang("toolbar_code_title"), "icon" => "../../plugins/luxtools/images/code.png", "key" => "C", "open" => "", "sample" => $this->getLang("toolbar_code_sample"), "close" => "", "block" => false, ]; // Date Fix: normalize selected timestamp $event->data[] = [ "type" => "LuxtoolsDatefix", "title" => $this->getLang("toolbar_datefix_title"), "icon" => "../../plugins/luxtools/images/date-fix.svg", "key" => "t", "block" => false, ]; // Date Fix All: normalize all timestamps on page $event->data[] = [ "type" => "LuxtoolsDatefixAll", "title" => $this->getLang("toolbar_datefix_all_title"), "icon" => "../../plugins/luxtools/images/date-fix-all.svg", "block" => false, ]; // Page Link: create a page-scoped UUID for .pagelink linking $event->data[] = [ "type" => "LuxtoolsPageLink", "title" => $this->getLang("toolbar_pagelink_title"), "icon" => "../../plugins/luxtools/images/pagelink.svg", "block" => false, ]; } /** * Inject page link status above the page content. * * @param Event $event * @param mixed $param * @return void */ public function addPageLinkStatus(Event $event, $param) { global $ACT, $ID; if (!is_string($ACT) || $ACT !== 'show') { return; } if (!is_string($ID) || $ID === '') { return; } $pageId = $ID; if (function_exists('cleanID')) { $pageId = (string)cleanID($pageId); } if ($pageId === '') return; $pathConfig = (string)$this->getConf('paths'); $depth = (int)$this->getConf('pagelink_search_depth'); if ($depth < 0) $depth = 0; $pageLink = new PageLink($pathConfig, $depth); $uuid = $pageLink->getPageUuid($pageId); if ($uuid === null) return; $linkInfo = $pageLink->resolveUuid($uuid); $folder = $linkInfo['folder'] ?? null; $multiple = !empty($linkInfo['multiple']); $statusText = ''; $copyable = false; $title = ''; if (is_string($folder) && $folder !== '') { $trimmed = rtrim($folder, '/\\'); $statusText = basename($trimmed); $title = $trimmed; } else { $statusText = (string)$this->getLang('pagelink_unlinked'); $copyable = true; } $warning = ''; if ($multiple) { $warning = ''; } $html = '' . hsc($statusText) . $warning . ''; $event->data = $html . $event->data; } }