diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-02-15 14:34:26 +0100 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-02-15 14:34:26 +0100 |
commit | 6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe (patch) | |
tree | 05e6f01e4a65cab0801f217e56d7b34111fdd0e9 /inc | |
parent | ddb55c702f2393a435c309fd7d4e169acb2675f7 (diff) | |
download | rpg-6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe.tar.gz rpg-6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe.tar.bz2 |
interwiki : prefixed configurls handled as wikilinks
Diffstat (limited to 'inc')
-rw-r--r-- | inc/common.php | 10 | ||||
-rw-r--r-- | inc/parser/renderer.php | 9 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 11 |
3 files changed, 24 insertions, 6 deletions
diff --git a/inc/common.php b/inc/common.php index cd3c053a3..aa59a8c11 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1497,7 +1497,15 @@ function userinfo($username = null) { $xhtml_renderer->interwiki = getInterwiki(); } $shortcut = 'user'; - $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username); + $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username, $exists); + if($exists !== null) { + if($exists) { + $data['link']['class'] .= ' wikilink1'; + } else { + $data['link']['class'] .= ' wikilink2'; + $data['link']['rel'] = 'nofollow'; + } + } } } else { $data['link'] = false; diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index d01fc3899..fa70c299e 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -292,7 +292,7 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * Resolve an interwikilink */ - function _resolveInterWiki(&$shortcut, $reference) { + function _resolveInterWiki(&$shortcut, $reference, &$exists=null) { //get interwiki URL if(isset($this->interwiki[$shortcut])) { $url = $this->interwiki[$shortcut]; @@ -322,9 +322,10 @@ class Doku_Renderer extends DokuWiki_Plugin { $url = $url . rawurlencode($reference); } //url without slashes is handled as a pageid - if(strpos($url, '/') === false) { - list($url, $urlparam) = explode('?', $url, 2); - $url = wl($url, $urlparam); + if($url{0} === ':') { + list($id, $urlparam) = explode('?', $url, 2); + $url = wl(cleanID($id), $urlparam); + $exists = page_exists($id); } if($hash) $url .= '#' . rawurlencode($hash); diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 20cd8e9d6..53a4dbcad 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -697,7 +697,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $link['name'] = $this->_getLinkTitle($name, $wikiUri, $isImage); //get interwiki URL - $url = $this->_resolveInterWiki($wikiName, $wikiUri); + $exists = null; + $url = $this->_resolveInterWiki($wikiName, $wikiUri, $exists); if(!$isImage) { $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName); @@ -710,6 +711,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if(strpos($url, DOKU_URL) === 0 OR strpos($url, DOKU_BASE) === 0) { $link['target'] = $conf['target']['wiki']; } + if($exists !== null && !$isImage) { + if($exists) { + $link['class'] .= ' wikilink1'; + } else { + $link['class'] .= ' wikilink2'; + $link['rel'] = 'nofollow'; + } + } $link['url'] = $url; $link['title'] = htmlspecialchars($link['url']); |