]> git.pld-linux.org Git - packages/dokuwiki-plugin-pagemove.git/blob - dokuwiki-plugin-pagemove-redirectlinks.patch
- handle redirect links
[packages/dokuwiki-plugin-pagemove.git] / dokuwiki-plugin-pagemove-redirectlinks.patch
1 --- pagemove/admin.php  2008-02-25 19:02:48.062065053 +0200
2 +++ pagemove/admin.php  2008-02-25 19:01:41.271159305 +0200
3 @@ -411,7 +411,8 @@
4      function _pm_updatelinks(&$text, $links)
5      {
6        foreach( $links as $old => $new ) {
7 -        $text = preg_replace( '#\[\[' . $old . '((\]\])|[\|\#])#i', '[[' . $new . '\1', $text);
8 +        $text = preg_replace( '#\[\[' . $old . '(\]\]|[\|\#])#i', '[[' . $new . '\1', $text);
9 +        $text = preg_replace( '#~~REDIRECT>' . $old . '(~~|[\|\#])#i', '~~REDIRECT>' . $new . '\1', $text);
10        }
11      }
12  
13 @@ -440,7 +441,14 @@
14        //match all links
15        //FIXME may be incorrect because of code blocks
16        //      CamelCase isn't supported, too
17 -      preg_match_all('#\[\[(.+?)\]\]#si',$text,$matches,PREG_SET_ORDER);
18 +      $matches = array();
19 +      if (preg_match_all('#\[\[(.+?)\]\]#s',$text,$m,PREG_SET_ORDER)) {
20 +        $matches = array_merge($matches, $m);
21 +      }
22 +      if (preg_match_all('#~~REDIRECT>(.+?)~~#s',$text,$m,PREG_SET_ORDER)) {
23 +        $matches = array_merge($matches, $m);
24 +      }
25 +
26        foreach($matches as $match){
27          //get ID from link and discard most non wikilinks
28          list($mid) = split('[\|#]',$match[1],2);
29 @@ -572,9 +580,9 @@
30       */
31      function _pm_search_backlinks(&$data,$base,$file,$type,$lvl,$opts){
32        //we do nothing with directories
33 -      if($type == 'd') return true;;
34 +      if($type == 'd') return true;
35        //only search txt files
36 -      if(!preg_match('#\.txt$#',$file)) return true;;
37 +      if(!preg_match('#\.txt$#',$file)) return true;
38      
39        //get text
40        $text = io_readfile($base.'/'.$file);
41 @@ -589,7 +597,13 @@
42        //match all links
43        //FIXME may be incorrect because of code blocks
44        //      CamelCase isn't supported, too
45 -      preg_match_all('#\[\[(.+?)\]\]#si',$text,$matches,PREG_SET_ORDER);
46 +      $matches = array();
47 +      if (preg_match_all('#\[\[(.+?)\]\]#s',$text,$m,PREG_SET_ORDER)) {
48 +        $matches = array_merge($matches, $m);
49 +      }
50 +      if (preg_match_all('#~~REDIRECT>(.+?)~~#s',$text,$m,PREG_SET_ORDER)) {
51 +        $matches = array_merge($matches, $m);
52 +      }
53        foreach($matches as $match){
54          //get ID from link and discard most non wikilinks
55          list($mid) = split('[\|#]',$match[1],2);
This page took 0.094914 seconds and 3 git commands to generate.