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; } /**