diff options
-rw-r--r-- | inc/pageutils.php | 13 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 6 | ||||
-rw-r--r-- | inc/parserutils.php | 11 | ||||
-rw-r--r-- | inc/search.php | 46 | ||||
-rw-r--r-- | lang/cs/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/da/backlinks.txt | 2 | ||||
-rw-r--r-- | lang/de/backlinks.txt | 4 | ||||
-rw-r--r-- | lang/en/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/fi/backlinks.txt | 5 | ||||
-rw-r--r-- | lang/fr/backlinks.txt | 2 | ||||
-rw-r--r-- | lang/he/backlinks.txt | 2 | ||||
-rw-r--r-- | lang/hu/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/it/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/nl/backlinks.txt | 2 | ||||
-rw-r--r-- | lang/no/backlinks.txt | 2 | ||||
-rw-r--r-- | lang/pl/backlinks.txt | 1 | ||||
-rw-r--r-- | lang/pt-br/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/pt/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/ro/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/ru/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/sv/backlinks.txt | 2 | ||||
-rw-r--r-- | lang/vi/backlinks.txt | 3 | ||||
-rw-r--r-- | lang/zh-tw/backlinks.txt | 2 |
23 files changed, 56 insertions, 71 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php index 367e53625..6334afedd 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -122,14 +122,11 @@ function localeFN($id){ /** * Returns a full media id * - * uses global $ID to resolve relative pages - * * @author Andreas Gohr <andi@splitbrain.org> */ -function resolve_mediaid(&$page,&$exists){ - global $ID; +function resolve_mediaid($ns,&$page,&$exists){ global $conf; - $ns = getNS($ID); + //if links starts with . add current namespace if($page{0} == '.'){ $page = $ns.':'.substr($page,1); @@ -148,14 +145,10 @@ function resolve_mediaid(&$page,&$exists){ /** * Returns a full page id * - * uses global $ID to resolve relative pages - * * @author Andreas Gohr <andi@splitbrain.org> */ -function resolve_pageid(&$page,&$exists){ - global $ID; +function resolve_pageid($ns,&$page,&$exists){ global $conf; - $ns = getNS($ID); //if links starts with . add current namespace if($page{0} == '.'){ diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 0b1531a65..1c26b0645 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -390,9 +390,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer { function internallink($id, $name = NULL, $search=NULL) { global $conf; + global $ID; $name = $this->_getLinkTitle($name, $this->_simpleTitle($id), $isImage, $id); - resolve_pageid($id,$exists); + resolve_pageid(getNS($ID),$id,$exists); if ( !$isImage ) { if ( $exists ) { @@ -644,7 +645,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL, $height=NULL, $cache=NULL) { global $conf; - resolve_mediaid($src, $exists); + global $ID; + resolve_mediaid(getNS($ID),$src, $exists); $link = array(); $link['class'] = 'media'; diff --git a/inc/parserutils.php b/inc/parserutils.php index 4e38e0162..fd66c3f1e 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -111,7 +111,7 @@ function p_cached_xhtml($file){ * * @author Andreas Gohr <andi@splitbrain.org> */ -function p_cached_instructions($file){ +function p_cached_instructions($file,$cacheonly=false){ global $conf; $cache = $conf['datadir'].'/_cache/instructions/'; $cache .= md5($file.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT']); @@ -119,6 +119,15 @@ function p_cached_instructions($file){ // check if cache can be used $cachetime = @filemtime($cache); // 0 if not exists + // cache forced? + if($cacheonly){ + if($cachetime){ + return unserialize(io_readfile($cache)); + }else{ + return NULL; + } + } + if( @file_exists($file) // does the source exist && $cachetime > @filemtime($file) // cache is fresh && !isset($_REQUEST['purge']) // no purge param was set diff --git a/inc/search.php b/inc/search.php index 9c01b455b..0b2e26c67 100644 --- a/inc/search.php +++ b/inc/search.php @@ -207,13 +207,10 @@ function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ //only search txt files if(!preg_match('#\.txt$#',$file)) return true;; - //get text - $text = io_readfile($base.'/'.$file); - //absolute search id $sid = cleanID($opts['ns'].':'.$opts['name']); - //construct current namespace + //current id and namespace $cid = pathID($file); $cns = getNS($cid); @@ -222,31 +219,25 @@ function search_backlinks(&$data,$base,$file,$type,$lvl,$opts){ return false; } - //match all links - //FIXME may be incorrect because of code blocks - // CamelCase isn't supported, too - preg_match_all('#\[\[(.+?)\]\]#si',$text,$matches,PREG_SET_ORDER); - foreach($matches as $match){ - //get ID from link and discard most non wikilinks - list($mid) = split('\|',$match[1],2); - if(preg_match("#^(https?|telnet|gopher|file|wais|ftp|ed2k|irc)://#",$mid)) continue; - if(preg_match("#\w+>#",$mid)) continue; - $mns = getNS($mid); - //namespace starting with "." - prepend current namespace - if(strpos($mns,'.')===0){ - $mid = $cns.":".substr($mid,1); - } - if($mns===false){ - //no namespace in link? add current - $mid = "$cns:$mid"; - } - $mid = cleanID($mid); - - if ($mid == $sid){ - $data[]['id'] = $cid; - break; + //fetch instructions + require_once(DOKU_INC.'inc/parserutils.php'); + $instructions = p_cached_instructions($base.$file,true); + if(is_null($instructions)) return false; + + //check all links for match + foreach($instructions as $ins){ + if($ins[0] == 'internallink' || ($conf['camelcase'] && $ins[0] == 'camelcaselink') ){ + $mid = $ins[1][0]; + resolve_pageid($cns,$mid,$exists); //exists is not used + if($mid == $sid){ + //we have a match - finish + $data[]['id'] = $cid; + break; + } } } + + return false; } /** @@ -325,6 +316,7 @@ function sort_search_fulltext($a,$b){ * translates a document path to an ID * * @author Andreas Gohr <andi@splitbrain.org> + * @todo move to pageutils */ function pathID($path){ $id = utf8_decodeFN($path); diff --git a/lang/cs/backlinks.txt b/lang/cs/backlinks.txt index 1b328d229..e430d20fc 100644 --- a/lang/cs/backlinks.txt +++ b/lang/cs/backlinks.txt @@ -1,4 +1,3 @@ ====== Zpětné odkazy ====== -Zde je seznam stránek, které pravděpodobně odkazují na aktuální stránku. Všimněte -si, že odkazy s prvními písmeny velkými (CamelCase) nejsou detekovány jako zpětné odkazy. +Zde je seznam stránek, které pravděpodobně odkazují na aktuální stránku. diff --git a/lang/da/backlinks.txt b/lang/da/backlinks.txt index 40fada72d..6dfa3cc43 100644 --- a/lang/da/backlinks.txt +++ b/lang/da/backlinks.txt @@ -1,4 +1,4 @@ ====== Henvisninger bagud ====== -Dette er en liste over alle de dokumenter der henviser tilbage til det nuværende dokument. Vær opmærksom på at CamelCase henvisninger ikke bliver opfattet som henvisninger bagud. +Dette er en liste over alle de dokumenter der henviser tilbage til det nuværende dokument. diff --git a/lang/de/backlinks.txt b/lang/de/backlinks.txt index c907e006c..43751d03b 100644 --- a/lang/de/backlinks.txt +++ b/lang/de/backlinks.txt @@ -1,5 +1,5 @@ ====== Backlinks ====== -Dies ist eine Liste der Seiten, die zurück zur momentanen Seite linken. CamelCase -Links werden dabei jedoch nicht beachtet. +Dies ist eine Liste der Seiten, die zurück zur momentanen Seite linken. + diff --git a/lang/en/backlinks.txt b/lang/en/backlinks.txt index 751de9c21..5b40b84ea 100644 --- a/lang/en/backlinks.txt +++ b/lang/en/backlinks.txt @@ -1,5 +1,4 @@ ====== Backlinks ====== -This is a list of pages that seem to link back to the current page. Note that CamelCase links are -not detected as backlinks. +This is a list of pages that seem to link back to the current page. diff --git a/lang/fi/backlinks.txt b/lang/fi/backlinks.txt index aeb3f206f..457720241 100644 --- a/lang/fi/backlinks.txt +++ b/lang/fi/backlinks.txt @@ -1,3 +1,4 @@ ====== Linkitykset ====== -Tässä lista tälle sivuille linkittävistä sivuista. Huomaa, että WikiSanalinkkejä ei havaita -tässä yhteydessä. + +Tässä lista tälle sivuille linkittävistä sivuista. + diff --git a/lang/fr/backlinks.txt b/lang/fr/backlinks.txt index 2bcee6ebf..f86d81728 100644 --- a/lang/fr/backlinks.txt +++ b/lang/fr/backlinks.txt @@ -1,4 +1,4 @@ ====== Pages pointant sur la page en cours (backlinks) ======
Ceci est la liste de pages qui pointent sur la page en cours.
-Notez bien que les liens "CamelCase" ne sont pas dectectés comme des backlinks.
+
diff --git a/lang/he/backlinks.txt b/lang/he/backlinks.txt index f872503c4..f9a7a02e4 100644 --- a/lang/he/backlinks.txt +++ b/lang/he/backlinks.txt @@ -1,3 +1,3 @@ ====== קישורים לאחור ====== -זוהי רשימת דפים אשר נראה כי הם מקשרים לדף זה. קישורי CamelCase אינם מזוהים כקישור לאחור.
\ No newline at end of file +זוהי רשימת דפים אשר נראה כי הם מקשרים לדף זה. diff --git a/lang/hu/backlinks.txt b/lang/hu/backlinks.txt index 4a5f1dbf2..3830751b8 100644 --- a/lang/hu/backlinks.txt +++ b/lang/hu/backlinks.txt @@ -1,7 +1,6 @@ ====== Hivatkozások ====== Ez azoknak az oldalaknak a listája, amelyek erre az oldalra -"visszamutatnak" (hivatkoznak). Vigyázz, mert a TeveHát stílusú -hivatkozások itt nem jelennek meg. +"visszamutatnak" (hivatkoznak). diff --git a/lang/it/backlinks.txt b/lang/it/backlinks.txt index 29e27f94f..9ae4c7812 100644 --- a/lang/it/backlinks.txt +++ b/lang/it/backlinks.txt @@ -1,3 +1,4 @@ ====== Backlinks ====== -Questa è una lista delle pagine che sembrano avere un collegamento alla pagina corrente. Nota che i link in CamelCase sono sono riconosciuti. +Questa è una lista delle pagine che sembrano avere un collegamento alla pagina corrente. + diff --git a/lang/nl/backlinks.txt b/lang/nl/backlinks.txt index 50d2f5007..6edbf4021 100644 --- a/lang/nl/backlinks.txt +++ b/lang/nl/backlinks.txt @@ -1,4 +1,4 @@ ====== Backlinks ====== -Dit is een lijst van pagina's die terug lijken te wijzen naar de huidige pagina. Let op: KameelLetter links worden niet gezien als backlinks. +Dit is een lijst van pagina's die terug lijken te wijzen naar de huidige pagina. diff --git a/lang/no/backlinks.txt b/lang/no/backlinks.txt index 3f3c99fe5..50e880841 100644 --- a/lang/no/backlinks.txt +++ b/lang/no/backlinks.txt @@ -1,3 +1,3 @@ ======Tilbakelinker====== -Dette er en fortegnelse over sider som ser ut til å linke tilbake til den aktuelle siden. Husk at CamelCase-linker ikke blir oppdaget som tilbakelinker. +Dette er en fortegnelse over sider som ser ut til å linke tilbake til den aktuelle siden. diff --git a/lang/pl/backlinks.txt b/lang/pl/backlinks.txt index 3b0b98cd4..6e682f9ec 100644 --- a/lang/pl/backlinks.txt +++ b/lang/pl/backlinks.txt @@ -1,5 +1,4 @@ ====== Odnośnik z innych stron ====== Poniżej znajduje się lista stron, które zawierają odnośniki na aktualną stronę. -Odnośniki **//PisaneRazem//** zostały pominięte. diff --git a/lang/pt-br/backlinks.txt b/lang/pt-br/backlinks.txt index 0687288aa..5927f6a23 100644 --- a/lang/pt-br/backlinks.txt +++ b/lang/pt-br/backlinks.txt @@ -2,6 +2,3 @@ Esta é uma lista de todos os documentos que apresentam ligações ao documento atual. -**Nota**: As ligações do tipo CamelCase não são detectadas como sendo um //backlink//. - ------ diff --git a/lang/pt/backlinks.txt b/lang/pt/backlinks.txt index 893e444ed..e78ddf874 100644 --- a/lang/pt/backlinks.txt +++ b/lang/pt/backlinks.txt @@ -2,6 +2,3 @@ Esta é uma lista de todos os documentos que apresentam ligações ao documento corrente. -**Nota**: As ligações do tipo CamelCase não são detectadas como sendo um //backlink//. - ------ diff --git a/lang/ro/backlinks.txt b/lang/ro/backlinks.txt index 54c3ebf1c..3fd5e3415 100644 --- a/lang/ro/backlinks.txt +++ b/lang/ro/backlinks.txt @@ -1,5 +1,4 @@ ====== Legături înapoi ====== -Aceasta e o listă de pagini care au legături către pagina curentă. De notat că legăturile -de tip CamelCase nu sînt detectate ca şi legături înapoi. +Aceasta e o listă de pagini care au legături către pagina curentă. diff --git a/lang/ru/backlinks.txt b/lang/ru/backlinks.txt index 64d414e3f..95f6d5b39 100644 --- a/lang/ru/backlinks.txt +++ b/lang/ru/backlinks.txt @@ -1,5 +1,4 @@ ====== Обратные ссылки ====== -Это список страниц, которые обратно ссылаются на текущую страницу. Заметьте, -что ссылки в верблюжей нотации (CamelCase) не определяются как обратные. +Это список страниц, которые обратно ссылаются на текущую страницу. diff --git a/lang/sv/backlinks.txt b/lang/sv/backlinks.txt index ad6139bbb..643272b44 100644 --- a/lang/sv/backlinks.txt +++ b/lang/sv/backlinks.txt @@ -1,4 +1,4 @@ ======Tillbakalänkar====== Detta är en förteckning över sidor som verkar länka tillbaka till den aktuella -sidan. Var god notera att CamelCase-länkar inte upptäcks som tillbakalänkar. +sidan. diff --git a/lang/vi/backlinks.txt b/lang/vi/backlinks.txt index 20d5ff91f..a5bdf1298 100644 --- a/lang/vi/backlinks.txt +++ b/lang/vi/backlinks.txt @@ -1,4 +1,3 @@ ====== Nối về trước ======
-Đây là danh sách các trang hình như đã nối vào trang này. Chú ý là các nối loại CamelCase không được xác
-nhận đã nối về trước.
+Đây là danh sách các trang hình như đã nối vào trang này.
diff --git a/lang/zh-tw/backlinks.txt b/lang/zh-tw/backlinks.txt index 9f69c26f7..026b3b30f 100644 --- a/lang/zh-tw/backlinks.txt +++ b/lang/zh-tw/backlinks.txt @@ -1,5 +1,5 @@ ====== 可返回的連結(Backlinks) ====== -這裡是可返回原先頁面的清單。 注意: CamelCase 詞彙的連結並不會被偵測為可返回的連結。 +這裡是可返回原先頁面的清單。 |