diff --git a/README.md b/README.md new file mode 100644 index 0000000..2cee98e --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# nslist: Plugin for DokuWiki +Namespace listing plugin + +Have a look at [DokuWiki: nslist Plugin](https://www.dokuwiki.org/plugin:nslist?s[]=nslist) diff --git a/plugin.info.txt b/plugin.info.txt index d6488a4..3a931be 100644 --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base nslist author Andreas Gohr email dokuwiki@cosmocode.de -date 2016-01-24 +date 2018-09-18 name Namespace Listing desc List all pages in a given namespace url http://www.dokuwiki.org/plugin:nslist diff --git a/syntax.php b/syntax.php index d7d5848..5ff4c6c 100644 --- a/syntax.php +++ b/syntax.php @@ -60,7 +60,8 @@ function handle($match, $state, $pos, Doku_Handler $handler){ 'depth' => 1, 'date' => 1, 'dsort' => 1 - ); + ,'liststyle' => 'default' + ); list($ns,$params) = explode(' ',$match,2); $ns = cleanID($ns); @@ -70,10 +71,12 @@ function handle($match, $state, $pos, Doku_Handler $handler){ if(preg_match('/\b(\d+)\b/i',$params,$m)) $conf['depth'] = $m[1]; if($ns) $conf['ns'] = $ns; + if(preg_match('/liststyle=([a-z\-]+)\&?/i',$params,$m)) $conf['liststyle'] = $m[1]; //parse parameter "liststyle" + $conf['dir'] = str_replace(':','/',$conf['ns']); // prepare data - return $conf; + return $conf; //conf will become data by function render later } /** @@ -107,7 +110,20 @@ function render($format, Doku_Renderer $R, $data) { foreach($result as $item){ $R->listitem_open(1); $R->listcontent_open(); - $R->internallink(':'.$item['id']); + + //Different behaviour as of Liststyle- Param + if($data['liststyle'] == 'default') { + //no special parameter given, use default = empty + $item['id_name'] = ''; + }elseif($data['liststyle'] == 'full') + { + $item['id_name'] = $item['id']; //full name of space + }elseif($data['liststyle'] == 'relative') + { + $item['id_name'] = substr($item['id'],strlen($data['ns'])+1); //strip off given namespace + ':' + }; + + $R->internallink(':'.$item['id'],$item['id_name']); if($data['date']) $R->cdata(' '.dformat($item['mtime'])); $R->listcontent_close();