14cbd2578SEli Fenton<?php 24cbd2578SEli Fentonif (!defined('DOKU_INC')) die(); 34cbd2578SEli Fentonif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 44cbd2578SEli Fentonrequire_once DOKU_INC . 'inc/parser/xhtml.php'; 54cbd2578SEli Fenton 64cbd2578SEli Fenton/** 7*e2969550SEli Fenton * Auto-Tooltip DokuWiki renderer plugin. If the current renderer is ActionRenderer, the action 8*e2969550SEli Fenton * plugin will be used instead. 94cbd2578SEli Fenton * 104cbd2578SEli Fenton * @license MIT 114cbd2578SEli Fenton * @author Eli Fenton 124cbd2578SEli Fenton */ 134cbd2578SEli Fentonclass renderer_plugin_autotooltip extends Doku_Renderer_xhtml { 144cbd2578SEli Fenton /** @type helper_plugin_autotooltip m_helper */ 154cbd2578SEli Fenton private $m_helper; 16adc8be0aSEli Fenton private $m_exclude; 174cbd2578SEli Fenton 184cbd2578SEli Fenton public function __construct() { 194cbd2578SEli Fenton global $ID; 204cbd2578SEli Fenton $this->m_helper = plugin_load('helper', 'autotooltip'); 21*e2969550SEli Fenton $this->m_exclude = $this->m_helper->isExcluded($ID); 224cbd2578SEli Fenton } 234cbd2578SEli Fenton 244cbd2578SEli Fenton 254cbd2578SEli Fenton /** 264cbd2578SEli Fenton * @param $format 274cbd2578SEli Fenton * @return bool 284cbd2578SEli Fenton */ 294cbd2578SEli Fenton function canRender($format) { 304cbd2578SEli Fenton return $format == 'xhtml'; 314cbd2578SEli Fenton } 324cbd2578SEli Fenton 334cbd2578SEli Fenton 344cbd2578SEli Fenton /** 354cbd2578SEli Fenton * Intercept Doku_Renderer_xhtml:internallink to give every wikilink a tooltip! 364cbd2578SEli Fenton * 374cbd2578SEli Fenton * @param string $id 384cbd2578SEli Fenton * @param null $name 394cbd2578SEli Fenton * @param null $search 404cbd2578SEli Fenton * @param bool $returnonly 414cbd2578SEli Fenton * @param string $linktype 424cbd2578SEli Fenton * @return string 434cbd2578SEli Fenton */ 444cbd2578SEli Fenton function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { 454cbd2578SEli Fenton global $ID; 46dd27e4fbSEli Fenton $fullId = $id; 47dd27e4fbSEli Fenton $id = preg_replace('/\#.*$/', '', $id); 48dd27e4fbSEli Fenton 49adc8be0aSEli Fenton if (!$this->m_exclude && page_exists($id) && $id != $ID) { 50*e2969550SEli Fenton $link = parent::internallink($fullId, $name, $search, true, $linktype); 51*e2969550SEli Fenton 52d39942acSEli Fenton $meta = $this->m_helper->read_meta_fast($id); 53d39942acSEli Fenton $abstract = $meta['abstract']; 544cbd2578SEli Fenton $link = $this->m_helper->stripNativeTooltip($link); 55d39942acSEli Fenton $link = $this->m_helper->forText($link, $abstract, $meta['title']); 564cbd2578SEli Fenton 574cbd2578SEli Fenton if (!$returnonly) { 584cbd2578SEli Fenton $this->doc .= $link; 594cbd2578SEli Fenton } 604cbd2578SEli Fenton return $link; 614cbd2578SEli Fenton } 6282191fd0SEli Fenton return parent::internallink($fullId, $name, $search, $returnonly, $linktype); 634cbd2578SEli Fenton } 644cbd2578SEli Fenton} 65