Skip to content

Commit

Permalink
replace sort by the sort in pagelist
Browse files Browse the repository at this point in the history
  • Loading branch information
Klap-in committed Aug 19, 2023
1 parent e9d45ea commit 8f7e02a
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions syntax/topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,19 @@ function render($format, Doku_Renderer $renderer, $data) {
if (!$pagelist = $this->loadHelper('pagelist')) {
return false;
}
$pagelist->sort = false;
$pagelist->rsort = false;

$configflags = explode(',', str_replace(" ", "", $this->getConf('pagelist_flags')));
$flags = array_merge($configflags, $flags);
foreach($flags as $key => $flag) {
if($flag == "") {
$flags[] = 'defaultsortby=pagename'; //default sortby if a sort requested
$flags = array_merge($configflags, $flags);
foreach ($flags as $key => $flag) {
if ($flag == "") {
unset($flags[$key]);
}
}
}

$pagelist->setFlags($flags);
$pagelist->startList();

// Sort pages by pagename if required by flags
if($pagelist->sort || $pagelist->rsort) {
$fnc = function($a, $b) {
return strcmp(noNS($a["id"]), noNS($b["id"]));
};
usort($pages, $fnc);
// rsort is true - revserse sort the pages
if($pagelist->rsort) {
krsort($pages);
}
}

foreach ($pages as $page) {
$pagelist->addPage($page);
}
Expand Down

0 comments on commit 8f7e02a

Please sign in to comment.