diff --git a/inc/pageutils.php b/inc/pageutils.php index 367e53625bc9a71bebb11f32e6e919469fe77e45..6334afedd8ff11e12a4d950f98707910451c7fcb 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 0b1531a653d3a7e564deaef261e1a6dca7794759..1c26b0645ff011f5a39b0eeef42b8e5362892eb8 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 4e38e016248ae9af53fdc266854b80c55f95b2d9..fd66c3f1e1b84b4288334a3281061a509c0183f8 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 9c01b455b9d459651f0481490d025a6b19ce1037..0b2e26c674c9225ea1db84ba5e85cfc5bcbac1ef 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 1b328d229f9a441a767d48db5a1f3cfc4bbee125..e430d20fc8f83b8e68c0e07c674d3b7960b974ec 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 40fada72d564c7f90258bdc9d6ffeafcc52e9345..6dfa3cc432eba0248a847a49f141f1afa5d8e85d 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 c907e006c8cf0a26ce724249c9d9edf38820c435..43751d03b7d8d2ba77fca307717a861bf6fc061b 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 751de9c214376a34ffb03dd2a7b417ff7ec478df..5b40b84ea0a9974f4a4e6f7019f46faa86b6b434 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 aeb3f206fe692c13aa7435ff8cb7081e286ae322..457720241fecafebc42cd44501a68b4209b4492e 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 2bcee6ebf1c408d56e5154ce09c1d52f977d3f36..f86d8172821f4c6ca91ceb949f34c2adb9648bb4 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 f872503c4cd599efea545adf508dcc658ed8e10b..f9a7a02e47c368743736aec31587a9049e6bc4cc 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 4a5f1dbf2665a1c4fbad6dfd1d59f902db9c72da..3830751b86ea75266b765949b0c65456949200f8 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 29e27f94f5cb5278f673d0c2b3a67ef75d9bbe40..9ae4c7812fe54b3332dae0f74b0559f1c3f96bc6 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 50d2f5007d2ddf0e32b9d878c8027a03e4092999..6edbf40212dabd58102e9f122a0955b5f1315ef0 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 3f3c99fe56581297b08ff8af91069d2b16387292..50e88084136f79a2989ffc49feb58019ad59f5a2 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 3b0b98cd4c014ec2dace0afb578939a76fba3c32..6e682f9ec80e799a9bccf185fa02ed9ebce389a4 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 0687288aa017aa02ac039af7a88d719ff01a0f42..5927f6a23904cfd4ef60a70cb27525939194be1b 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 893e444edf52040c207e6d30506f85b85c5a9ce5..e78ddf8748f329ba729fde6c96d5427e86a2d1ac 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 54c3ebf1c775cc0641599a4d1553e179c1499336..3fd5e34153380b269ee832a889d541db64319b9e 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 64d414e3fd13064da8af7d71f8de57bbc5fb50a6..95f6d5b39ede6786ed49b537a6b44b64a3a070cf 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 ad6139bbb360a200f94db1f0e3bb8fe47da90314..643272b445527980bff677db7259652d3b0c2fe8 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 20d5ff91f789b77eda148885b2088e76a6e7a7d0..a5bdf1298f7ec2302f06225286003ff4f5d8b46c 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 9f69c26f78b3ede40a868e93227b895bb9bcb121..026b3b30ffbd5c9b2da5da005f116ab76e9bd2e5 100644 --- a/lang/zh-tw/backlinks.txt +++ b/lang/zh-tw/backlinks.txt @@ -1,5 +1,5 @@ ====== å¯è¿”回的連çµ(Backlinks) ====== -這裡是å¯è¿”回原先é é¢çš„æ¸…單。 注æ„: CamelCase 詞彙的連çµä¸¦ä¸æœƒè¢«åµæ¸¬ç‚ºå¯è¿”回的連çµã€‚ +這裡是å¯è¿”回原先é é¢çš„æ¸…單。