From c1a842d49885dd8737fc48ec33a07ea160d3d1ee Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 7 Feb 2024 22:46:44 +0100 Subject: [PATCH] minor refactoring --- syntax/bookmanager.php | 12 ++++++------ syntax/exportlink.php | 4 ++-- syntax/exportsaved.php | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/syntax/bookmanager.php b/syntax/bookmanager.php index c034e81..53b810b 100644 --- a/syntax/bookmanager.php +++ b/syntax/bookmanager.php @@ -77,8 +77,8 @@ function handle($match, $state, $pos, Doku_Handler $handler) { $num = 10; $order = 'date'; if($type == 'archive') { - list(/* $junk */, $params) = explode(':', $match, 2); - list($param1, $param2) = explode('&', $params, 2); + [/* $junk */, $params] = array_pad(explode(':', $match, 2), 2, ''); + [$param1, $param2] = array_pad(explode('&', $params, 2),2, ''); $sortoptions = ['date', 'title']; if(is_numeric($param1)) { @@ -102,7 +102,7 @@ function handle($match, $state, $pos, Doku_Handler $handler) { /** * @param string $format render mode e.g. text, xhtml, meta,... - * @param Doku_Renderer &$renderer + * @param Doku_Renderer $renderer * @param array $data return of handle() * @return bool */ @@ -349,7 +349,7 @@ function _datesort($a, $b) { * @return int */ function _titlesort($a, $b) { - if($a['id'] <= $b['id']) return -1; + if($a['id'] < $b['id']) return -1; if($a['id'] > $b['id']) return 1; return 0; } @@ -398,11 +398,11 @@ private function getlist($order, $limit = 0) { * @return string html of list */ private function showlist($result, $isbookmanager = false) { - $output = ''; return $output; } } diff --git a/syntax/exportlink.php b/syntax/exportlink.php index a7c73b9..b199789 100644 --- a/syntax/exportlink.php +++ b/syntax/exportlink.php @@ -60,10 +60,10 @@ public function handle($match, $state, $pos, Doku_Handler $handler) { global $ID; $match = substr($match, 2, -2); //remove ~~ - list($type, $match) = explode('>', $match, 2); + [$type, $match] = array_pad(explode('>', $match, 2),2, ''); $type = strtolower(substr($type, 0, -2)); //remove NS - list($ns, $title) = explode('|', $match, 2); + [$ns, $title] = array_pad(explode('|', $match, 2), 2, ''); $id = $ns . ':start'; $resolver = new PageResolver($ID); $page = $resolver->resolveId($id); diff --git a/syntax/exportsaved.php b/syntax/exportsaved.php index f0f0e76..f71abf5 100644 --- a/syntax/exportsaved.php +++ b/syntax/exportsaved.php @@ -46,7 +46,7 @@ public function getSort() public function handle($match, $state, $pos, Doku_Handler $handler) { $match = substr($match, 2, -2); // strip markup - list($type, $savedSelectionPage) = explode(':', $match, 2); + [$type, $savedSelectionPage] = array_pad(explode(':', $match, 2), 2, ''); //type: EXPORT... $type = strtolower(substr($type, 6)); $exporturl = [ @@ -60,8 +60,8 @@ public function handle($match, $state, $pos, Doku_Handler $handler) } $link = $exporturl[$type]; - list($savedSelectionPage, $linktitle) = explode('|', $savedSelectionPage, 2); - list($savedSelectionPage, $extraParameters) = explode('&', $savedSelectionPage, 2); + [$savedSelectionPage, $linktitle] = array_pad(explode('|', $savedSelectionPage, 2), 2, ''); + [$savedSelectionPage, $extraParameters] = array_pad(explode('&', $savedSelectionPage, 2), 2, ''); $ns = $this->getConf('save_namespace'); $savedSelectionPageid = cleanID($ns . ":" . $savedSelectionPage);