22/**
33 * OrphansWanted Plugin: Display Orphans, Wanteds and Valid link information
44 *
5- * syntax ~~ORPHANSWANTED:<choice>[!<exclude list>]~~ <choice> :: orphans | wanted | valid | all
5+ * syntax ~~ORPHANSWANTED:<choice>[@<include list>][!<exclude list>]~~ <choice> :: orphans | wanted | valid | all
6+ * [@<include list>] :: optional. prefix each with @ e.g., @wiki@comments:currentyear (defaults to all namespaces if not specified)
67 * [!<exclude list>] :: optional. prefix each with ! e.g., !wiki!comments:currentyear
78 *
89 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
910 * @author <dae@douglasedmunds.com>
1011 * @author Andy Webber <dokuwiki at andywebber dot com>
1112 * @author Federico Ariel Castagnini
1213 * @author Cyrille37 <cyrille37@gmail.com>
14+ * @author Rik Blok <rik dot blok at ubc dot ca>
15+ * @author Christian Paul <christian at chrpaul dot de>
1316 */
1417
1518if (!defined ('DOKU_INC ' )) define ('DOKU_INC ' ,realpath (dirname (__FILE__ ).'/../../ ' ).'/ ' );
@@ -48,7 +51,7 @@ function getSort(){
4851 * Connect pattern to lexer
4952 */
5053 function connectTo ($ mode ) {
51- $ this ->Lexer ->addSpecialPattern ('~~ORPHANSWANTED:[\w:!-]+~~ ' , $ mode , 'plugin_orphanswanted ' );
54+ $ this ->Lexer ->addSpecialPattern ('~~ORPHANSWANTED:[\w:@ !-]+~~ ' , $ mode , 'plugin_orphanswanted ' );
5255 }
5356
5457 /**
@@ -61,7 +64,14 @@ function handle($match, $state, $pos, Doku_Handler $handler){
6164 // Wolfgang 2007-08-29 suggests commenting out the next line
6265 // $match = strtolower($match);
6366 //create array, using ! as separator
64- $ match_array = explode ("! " , $ match );
67+ // eg: $match = 'all@includens!excludens'
68+ $ match_in = explode ("@ " , $ match ); // eg: $match_array = array(); $match_in = array('all', 'includens!excludens')
69+ $ match_ex = explode ("! " ,array_pop ($ match_in )); // eg: $match_array = array(); $match_in = array('all'); $match_ex = array('includens', 'excludens')
70+ array_push ($ match_in ,array_shift ($ match_ex )); // eg: $match_array = array(); $match_in = array('all', 'includens'); $match_ex = array('excludens')
71+ $ match_array [0 ] = array_shift ($ match_in ); // eg: $match_array = array('all'); $match_in = array('includens'); $match_ex = array('excludens')
72+ $ match_array [1 ] = $ match_in ; // eg: $match_array = array('all', array('includens')); $match_ex = array('excludens')
73+ $ match_array [2 ] = $ match_ex ; // eg: $match_array = array('all', array('includens'), array('excludens'))
74+
6575 // $match_array[0] will be orphan, wanted, valid, all, or syntax error
6676 // if there are excluded namespaces, they will be in $match_array[1] .. [x]
6777 // this return value appears in render() as the $data param there
@@ -99,7 +109,6 @@ function render($format, Doku_Renderer $renderer, $data) {
99109 break ;
100110 default :
101111 $ renderer ->doc .= "ORPHANSWANTED syntax error " ;
102- // $renderer->doc .= "syntax ~~ORPHANSWANTED:<choice>~~<optional_excluded> <choice> :: orphans|wanted|valid|all Ex: ~~ORPHANSWANTED:valid~~";
103112 }
104113 return true ;
105114 }
0 commit comments