Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion plugin.info.txt
Original file line number Diff line number Diff line change
@@ -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
22 changes: 19 additions & 3 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
}

/**
Expand Down Expand Up @@ -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();
Expand Down