From d11e205ca590333b43946ee0393f6e4e1c330ad1 Mon Sep 17 00:00:00 2001 From: Satoshi Sahara Date: Mon, 7 Sep 2020 23:17:49 +0900 Subject: [PATCH] consistent html_buildlist() usage see usage of html_buildlist in plugin acl (admin and action component) --- inc/Ajax.php | 3 ++- inc/Ui/Index.php | 40 +++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/inc/Ajax.php b/inc/Ajax.php index c97bd09dc..f1aea7d93 100644 --- a/inc/Ajax.php +++ b/inc/Ajax.php @@ -326,7 +326,8 @@ class Ajax { foreach (array_keys($data) as $item) { $data[$item]['level'] = $lvl + 1; } - echo (new Ui\Index)->buildIndexList($data); + $idx = new Ui\Index; + echo html_buildlist($data, 'idx', [$idx,'formatListItem'], [$idx,'tagListItem']); } /** diff --git a/inc/Ui/Index.php b/inc/Ui/Index.php index 87de2c519..d2cbfccb1 100644 --- a/inc/Ui/Index.php +++ b/inc/Ui/Index.php @@ -33,38 +33,36 @@ class Index extends Ui * @return void */ public function show() + { + // print intro + print p_locale_xhtml('index'); + + print $this->sitemap(); + } + + /** + * Build html of sitemap, unordered list of pages under the namespace + * + * @return string + */ + public function sitemap() { global $conf; global $ID; - $ns = cleanID($this->ns); + $ns = cleanID($this->ns); if (empty($ns)){ $ns = getNS($ID); if ($ns === false) $ns = ''; } - $ns = utf8_encodeFN(str_replace(':', '/', $ns)); - - // print intro - print p_locale_xhtml('index'); - - print '
'; - + $ns = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); search($data, $conf['datadir'], 'search_index', array('ns' => $ns)); - print $this->buildIndexList($data); - print '
'; - } - - /** - * Build html of unordered list of index items - * - * @param array $data array with item arrays - * @return string - */ - public function buildIndexList($data) - { - return html_buildlist($data, 'idx', [$this,'formatListItem'], [$this,'tagListItem']); + $html = '
' + . html_buildlist($data, 'idx', [$this,'formatListItem'], [$this,'tagListItem']) + . '
'; + return $html; } /**