Lexer->addSpecialPattern(LinkUtility::LINK_PATTERN, $mode, PluginUtility::getModeForComponent($this->getPluginComponent())); } /** * The handler for an internal link * based on `internallink` in {@link Doku_Handler} * The handler call the good renderer in {@link Doku_Renderer_xhtml} with * the parameters (ie for instance internallink) * @param string $match * @param int $state * @param int $pos * @param Doku_Handler $handler * @return array|bool */ function handle($match, $state, $pos, Doku_Handler $handler) { /** * Because we use the specialPattern, there is only one state ie DOKU_LEXER_SPECIAL */ $attributes = LinkUtility::getAttributes($match); $tag = new Tag(self::TAG, $attributes, $state, $handler->calls); $parent = $tag->getParent(); $parentName = ""; if ($parent != null) { $parentName = $parent->getName(); } return array( PluginUtility::ATTRIBUTES => $attributes, PluginUtility::PARENT_TAG => $parentName ); } /** * Render the output * @param string $format * @param Doku_Renderer $renderer * @param array $data - what the function handle() return'ed * @return boolean - rendered correctly? (however, returned value is not used at the moment) * @see DokuWiki_Syntax_Plugin::render() * * */ function render($format, Doku_Renderer $renderer, $data) { // The data switch ($format) { case 'xhtml': /** @var Doku_Renderer_xhtml $renderer */ /** * Cache problem */ if (isset($data[PluginUtility::ATTRIBUTES])) { $attributes = $data[PluginUtility::ATTRIBUTES]; } else { $attributes = $data; } $type = $attributes[LinkUtility::ATTRIBUTE_TYPE]; $id = $attributes[LinkUtility::ATTRIBUTE_ID]; /** * If this is a low quality internal page, * print a shallow link for the anonymous user */ if ( $type == "internal" && $this->getConf(LowQualityPage::CONF_LOW_QUALITY_PAGE_PROTECTION_ENABLE) && LowQualityPage::isPageToExclude($id) ) { $htmlLink = LinkUtility::renderLowQualityProtectedLink($attributes); } else { $htmlLink = LinkUtility::renderAsAnchorElement($renderer, $attributes); $parentClassWithoutClass = array( syntax_plugin_combo_button::TAG, syntax_plugin_combo_cite::TAG, syntax_plugin_combo_dropdown::TAG, syntax_plugin_combo_listitem::TAG, syntax_plugin_combo_preformatted::TAG ); if (page_exists($id) && in_array($data[PluginUtility::PARENT_TAG], $parentClassWithoutClass)) { $htmlLink = LinkUtility::deleteDokuWikiClass($htmlLink); } if ($data[PluginUtility::PARENT_TAG] == syntax_plugin_combo_button::TAG) { // We could also apply the class ie btn-secondary ... $htmlLink = LinkUtility::inheritColorFromParent($htmlLink); } } $renderer->doc .= $htmlLink; return true; break; case 'metadata': /** * Keep track of the backlinks ie meta['relation']['references'] * @var Doku_Renderer_metadata $renderer */ if (isset($data[PluginUtility::ATTRIBUTES])) { $attributes = $data[PluginUtility::ATTRIBUTES]; } else { $attributes = $data; } LinkUtility::handleMetadata($renderer, $attributes); return true; break; case Analytics::RENDERER_FORMAT: /** * * @var renderer_plugin_combo_analytics $renderer */ $attributes = $data[PluginUtility::ATTRIBUTES]; LinkUtility::processLinkStats($attributes, $renderer->stats); break; } // unsupported $mode return false; } }