Skip to content
Open
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
19 changes: 15 additions & 4 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
$opt['hidestart'] = false; // hide start pages
$opt['label'] = ''; // label to put at top of the list
$opt['layout'] = 'table'; // html layout type: table (1 col = div only) or columns (html 5 only)
$opt['limit'] = 0; // limit results to certain number
$opt['limit'] = '0'; // limit results to certain number or a range of results
$opt['maxns'] = 0; // max number of namespaces to display (i.e. ns depth)
$opt['natsort'] = false; // allow natural case sorting
$opt['proper'] = 'none'; // display file names in Proper Case
Expand Down Expand Up @@ -110,6 +110,15 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
$opt[$option] = true;
break;
case 'limit':
$options = explode('-', $value);
if (!empty($options[0]) && !empty($options[1])) {
$from = $options[0];
$until = $options[1];
$opt['limit'] = array('from' => $from, 'until' => $until);
} else if (!empty($options[0]) && empty($options[1])){
$opt['limit'] = $options[0];
}
break;
case 'maxns':
$opt[$option] = abs($value);
break;
Expand Down Expand Up @@ -304,9 +313,11 @@ function render($mode, Doku_Renderer $renderer, $opt) {
$pq->msort($sort_array, $sort_opts);

// limit the result list length if required; this can only be done after sorting!
if ($opt['limit'] > 0) {
$sort_array = array_slice($sort_array, 0, $opt['limit']);
}
if (!empty ($opt['limit']['from']) && !empty ($opt['limit']['until'])) {
$sort_array = array_slice($sort_array, (int)$opt['limit']['from'] - 1, (int)$opt['limit']['until']);
} else if (empty ($opt['limit']['from']) && empty ($opt['limit']['until']) && $opt['limit'] != '0') {
$sort_array = array_slice($sort_array, 0 , (int)$opt['limit']);
}

// do a link count BEFORE grouping (don't want to count headers...)
$count = count($sort_array);
Expand Down