diff options
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/renderer.php | 48 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 19 |
2 files changed, 41 insertions, 26 deletions
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index e748c36d8..0c3c56c56 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -271,17 +271,17 @@ class Doku_Renderer extends DokuWiki_Plugin { * * @author Andreas Gohr <andi@splitbrain.org> */ - function _simpleTitle($name){ + function _simpleTitle($name) { global $conf; - //if there is a hash we use the anchor name only - @list($name,$hash) = explode('#',$name,2); + //if there is a hash we use the ancor name only + @list($name, $hash) = explode('#', $name, 2); if($hash) return $hash; - if($conf['useslash']){ - $name = strtr($name,';/',';:'); - }else{ - $name = strtr($name,';',':'); + if($conf['useslash']) { + $name = strtr($name, ';/', ';:'); + } else { + $name = strtr($name, ';', ':'); } return noNSorNS($name); @@ -290,9 +290,9 @@ 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]) ) { + if(isset($this->interwiki[$shortcut])) { $url = $this->interwiki[$shortcut]; } else { // Default to Google I'm feeling lucky @@ -301,25 +301,31 @@ class Doku_Renderer extends DokuWiki_Plugin { } //split into hash and url part - @list($reference,$hash) = explode('#',$reference,2); + @list($reference, $hash) = explode('#', $reference, 2); //replace placeholder - if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#',$url)){ + if(preg_match('#\{(URL|NAME|SCHEME|HOST|PORT|PATH|QUERY)\}#', $url)) { //use placeholders - $url = str_replace('{URL}',rawurlencode($reference),$url); - $url = str_replace('{NAME}',$reference,$url); + $url = str_replace('{URL}', rawurlencode($reference), $url); + $url = str_replace('{NAME}', $reference, $url); $parsed = parse_url($reference); if(!$parsed['port']) $parsed['port'] = 80; - $url = str_replace('{SCHEME}',$parsed['scheme'],$url); - $url = str_replace('{HOST}',$parsed['host'],$url); - $url = str_replace('{PORT}',$parsed['port'],$url); - $url = str_replace('{PATH}',$parsed['path'],$url); - $url = str_replace('{QUERY}',$parsed['query'],$url); - }else{ + $url = str_replace('{SCHEME}', $parsed['scheme'], $url); + $url = str_replace('{HOST}', $parsed['host'], $url); + $url = str_replace('{PORT}', $parsed['port'], $url); + $url = str_replace('{PATH}', $parsed['path'], $url); + $url = str_replace('{QUERY}', $parsed['query'], $url); + } else { //default - $url = $url.rawurlencode($reference); + $url = $url . rawurlencode($reference); + } + //handle as wiki links + if($url{0} === ':') { + list($id, $urlparam) = explode('?', $url, 2); + $url = wl(cleanID($id), $urlparam); + $exists = page_exists($id); } - if($hash) $url .= '#'.rawurlencode($hash); + if($hash) $url .= '#' . rawurlencode($hash); return $url; } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 4966f103a..e3f9a4187 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -688,7 +688,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } /** - */ + */ function interwikilink($match, $name = null, $wikiName, $wikiUri) { global $conf; @@ -700,19 +700,28 @@ 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); + if(!$isImage) { + $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName); $link['class'] = "interwiki iw_$class"; } else { $link['class'] = 'media'; } //do we stay at the same server? Use local target - if( strpos($url,DOKU_URL) === 0 ){ + 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']); |