diff --git a/conf/default.php b/conf/default.php index 433f3d6..c2fceb2 100755 --- a/conf/default.php +++ b/conf/default.php @@ -3,3 +3,4 @@ $conf['delay'] = 0; $conf['linkall_inclusions'] = ''; $conf['linkall_exclusions'] = ''; +$conf['linkall_points_to'] = ''; diff --git a/conf/metadata.php b/conf/metadata.php index 3f89298..3720754 100755 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -3,3 +3,4 @@ $meta['delay'] = array('numeric', '_min' => 0, '_max' => 10000); $meta['linkall_inclusions'] = array('regex'); $meta['linkall_exclusions'] = array('regex'); +$meta['linkall_points_to'] = array('regex'); diff --git a/lang/en/settings.php b/lang/en/settings.php index e39c3e2..8972626 100755 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -4,3 +4,4 @@ $lang['delay'] = 'Time in miliseconds to wait before showing a tooltip'; $lang['linkall_inclusions'] = 'When using the renderer plugin to add tooltips to all links, this is a regular expression for pages or namespaces to include. For example, "^wiki:|^stuff:" inludes only links from the wiki and stuff namespaces. Leave blank to include all pages.'; $lang['linkall_exclusions'] = 'A regular expression for pages or namespaces to exclude. When combined with linkall_inclusions, this means "Include these pages, except those pages"'; +$lang['linkall_points_to'] = 'A regular expression for pages or namespaces that links must be pointing towards. If a link does not match this expression, the tooltip will not be generated. For example, "^:wiki:|^[.]" would show tooltips on any links in an included/not-excluded page that links to the ":wiki" namespace or any relative page respectively'; diff --git a/renderer.php b/renderer.php index 0dad919..27c6c54 100644 --- a/renderer.php +++ b/renderer.php @@ -13,6 +13,7 @@ class renderer_plugin_autotooltip extends Doku_Renderer_xhtml { /** @type helper_plugin_autotooltip m_helper */ private $m_helper; private $m_exclude; + private $m_points; public function __construct() { global $ID; @@ -24,6 +25,13 @@ public function __construct() { $this->m_exclude = (!empty($inclusions) && !preg_match("/$inclusions/", $ID)) || (!empty($exclusions) && preg_match("/$exclusions/", $ID)); + + // Set the regex for filtering link destinations + $points = $this->getConf('linkall_points_to'); + if (empty($points)) { + $points = ".*"; + } + $this->m_points = "/$points/"; } @@ -48,7 +56,7 @@ function canRender($format) { */ function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { global $ID; - if (!$this->m_exclude && page_exists($id) && $id != $ID) { + if (!$this->m_exclude && page_exists($id) && $id != $ID && preg_match($this->m_points,$id)) { $meta = $this->m_helper->read_meta_fast($id); $abstract = $meta['abstract'];