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/** 74cbd2578SEli Fenton * Auto-Tooltip DokuWiki plugin 84cbd2578SEli Fenton * 94cbd2578SEli Fenton * @license MIT 104cbd2578SEli Fenton * @author Eli Fenton 114cbd2578SEli Fenton */ 124cbd2578SEli Fentonclass renderer_plugin_autotooltip extends Doku_Renderer_xhtml { 134cbd2578SEli Fenton /** @type helper_plugin_autotooltip m_helper */ 144cbd2578SEli Fenton private $m_helper; 15adc8be0aSEli Fenton private $m_exclude; 164cbd2578SEli Fenton 174cbd2578SEli Fenton public function __construct() { 184cbd2578SEli Fenton global $ID; 194cbd2578SEli Fenton $this->m_helper = plugin_load('helper', 'autotooltip'); 204cbd2578SEli Fenton 21adc8be0aSEli Fenton // Include and exclude pages. 22adc8be0aSEli Fenton $inclusions = $this->getConf('linkall_inclusions'); 234cbd2578SEli Fenton $exclusions = $this->getConf('linkall_exclusions'); 24adc8be0aSEli Fenton $this->m_exclude = 25adc8be0aSEli Fenton (!empty($inclusions) && !preg_match("/$inclusions/", $ID)) || 26adc8be0aSEli Fenton (!empty($exclusions) && preg_match("/$exclusions/", $ID)); 274cbd2578SEli Fenton } 284cbd2578SEli Fenton 294cbd2578SEli Fenton 304cbd2578SEli Fenton /** 314cbd2578SEli Fenton * @param $format 324cbd2578SEli Fenton * @return bool 334cbd2578SEli Fenton */ 344cbd2578SEli Fenton function canRender($format) { 354cbd2578SEli Fenton return $format == 'xhtml'; 364cbd2578SEli Fenton } 374cbd2578SEli Fenton 384cbd2578SEli Fenton 394cbd2578SEli Fenton /** 404cbd2578SEli Fenton * Intercept Doku_Renderer_xhtml:internallink to give every wikilink a tooltip! 414cbd2578SEli Fenton * 424cbd2578SEli Fenton * @param string $id 434cbd2578SEli Fenton * @param null $name 444cbd2578SEli Fenton * @param null $search 454cbd2578SEli Fenton * @param bool $returnonly 464cbd2578SEli Fenton * @param string $linktype 474cbd2578SEli Fenton * @return string 484cbd2578SEli Fenton */ 494cbd2578SEli Fenton function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { 504cbd2578SEli Fenton global $ID; 51*dd27e4fbSEli Fenton $fullId = $id; 52*dd27e4fbSEli Fenton $id = preg_replace('/\#.*$/', '', $id); 53*dd27e4fbSEli Fenton 54adc8be0aSEli Fenton if (!$this->m_exclude && page_exists($id) && $id != $ID) { 55d39942acSEli Fenton $meta = $this->m_helper->read_meta_fast($id); 56d39942acSEli Fenton $abstract = $meta['abstract']; 574cbd2578SEli Fenton 58*dd27e4fbSEli Fenton $link = parent::internallink($fullId, $name, $search, true, $linktype); 594cbd2578SEli Fenton $link = $this->m_helper->stripNativeTooltip($link); 60d39942acSEli Fenton $link = $this->m_helper->forText($link, $abstract, $meta['title']); 614cbd2578SEli Fenton 624cbd2578SEli Fenton if (!$returnonly) { 634cbd2578SEli Fenton $this->doc .= $link; 644cbd2578SEli Fenton } 654cbd2578SEli Fenton return $link; 664cbd2578SEli Fenton } 674cbd2578SEli Fenton return parent::internallink($id, $name, $search, $returnonly, $linktype); 684cbd2578SEli Fenton } 694cbd2578SEli Fenton} 70