public function MenuRecur($parent, $npath, $num = 0) { $data = array(); $dpath = $npath; if ($parent) { $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND menu=1 AND visible=1 ORDER BY num ASC'; $items = DB::getAll($sql); foreach ($items as $item) { $selected = ''; if ($item['path'] == Funcs::$uri[count(Funcs::$uri) - 1]) { $selected = 'selected'; } elseif ($item['path'] == Funcs::$uri[$num]) { $selected = 'inner'; } $path = $dpath . $item['path'] . '/'; $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path, 'selected' => $selected, 'list' => MenuWidget::MenuRecur($item['id'], $path, $num + 1)); } } return $data; }