From 2345e871e407dbece52f3181cd8b077f07cbb0c1 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:11:15 +0100 Subject: wikilink creating refactored to _resolveinterwiki(). Added DOKU_BASE for local target --- inc/parser/renderer.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index e3401fd48..66a106b11 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -321,6 +321,11 @@ class Doku_Renderer extends DokuWiki_Plugin { //default $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($hash) $url .= '#'.rawurlencode($hash); return $url; -- cgit v1.2.3 From 5a9ce44695f44ecc76f356c1fc26f0a1846231b7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:17:09 +0100 Subject: code reformatting --- inc/parser/renderer.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 66a106b11..d01fc3899 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -273,17 +273,17 @@ class Doku_Renderer extends DokuWiki_Plugin { * * @author Andreas Gohr */ - function _simpleTitle($name){ + function _simpleTitle($name) { global $conf; //if there is a hash we use the ancor name only - list($name,$hash) = explode('#',$name,2); + 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); @@ -292,9 +292,9 @@ class Doku_Renderer extends DokuWiki_Plugin { /** * Resolve an interwikilink */ - function _resolveInterWiki(&$shortcut,$reference){ + function _resolveInterWiki(&$shortcut, $reference) { //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 @@ -303,30 +303,30 @@ 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); } //url without slashes is handled as a pageid - if(strpos($url,'/') === false) { + if(strpos($url, '/') === false) { list($url, $urlparam) = explode('?', $url, 2); $url = wl($url, $urlparam); } - if($hash) $url .= '#'.rawurlencode($hash); + if($hash) $url .= '#' . rawurlencode($hash); return $url; } -- cgit v1.2.3 From 6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 14:34:26 +0100 Subject: interwiki : prefixed configurls handled as wikilinks --- inc/parser/renderer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'inc/parser/renderer.php') 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); -- cgit v1.2.3 From f379edc2c80eee8cab2b94a4374113a0100f3929 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 16:51:48 +0100 Subject: fix comment in _resolveInterWiki --- inc/parser/renderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/parser/renderer.php') diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index fa70c299e..01a1fbfec 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -321,7 +321,7 @@ class Doku_Renderer extends DokuWiki_Plugin { //default $url = $url . rawurlencode($reference); } - //url without slashes is handled as a pageid + //handle as wiki links if($url{0} === ':') { list($id, $urlparam) = explode('?', $url, 2); $url = wl(cleanID($id), $urlparam); -- cgit v1.2.3