lwb5-in-2025/scripts/game/main/manual/library/getSectionsIn.inc

36 lines
739 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class main_manual_getSectionsIn {
public function __construct($lib) {
2016-01-10 11:01:49 +01:00
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function run($rootId, $type = 1) {
$qs = ($type > 0) ? (" AND is_page" . ($type == 2 ? " AND in_menu" : "")) : " AND NOT is_page";
$q = $this->db->query("SELECT id,name,title,after_section FROM man_section WHERE in_section=$rootId$qs");
$sl = array();
$as = array();
while ($r = dbFetchArray($q)) {
$sl[$r[0]] = array(
"name" => $r[1],
"title" => $r[2]
);
$as[$r[3]] = $r[0];
}
$cid = $rootId;
$nl = array();
while (!is_null($as[$cid])) {
$cid = $as[$cid];
$nl[$cid] = $sl[$cid];
$nl[$cid]['subs'] = $this->run($cid, $type);
}
return $nl;
}
}
?>