From 1f2fcd2bfeaec601b6196edbf8371be7f31d4ecf Mon Sep 17 00:00:00 2001 From: dingyongliang Date: Fri, 17 Mar 2023 13:20:44 +0800 Subject: [PATCH] * modulemenu: init. --- module/program/ui/browse.html.php | 14 ++++++++++ zin/func.php | 1 + zin/wg/modulemenu/v1.php | 45 +++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 zin/wg/modulemenu/v1.php diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index 0a2ab09ef7..4fbd94ff62 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -98,4 +98,18 @@ programmenu ) ); +modulemenu +( + set + ( + array + ( + 'id' => 1, + 'title' => '所有分类', + 'moduleSettingText' => '模块设置', + 'displaySettingText' => '显示设置' + ) + ) +); + render(); diff --git a/zin/func.php b/zin/func.php index 29d59d9da1..f4e9bf17b5 100644 --- a/zin/func.php +++ b/zin/func.php @@ -65,3 +65,4 @@ function toolbar() {return createWg('toolbar', func_get_args());} function searchform() {return createWg('searchform', func_get_args());} function searchToggle(){return createWg('searchtoggle', func_get_args());} function programmenu() {return createWg('programmenu', func_get_args());} +function modulemenu() {return createWg('modulemenu', func_get_args());} diff --git a/zin/wg/modulemenu/v1.php b/zin/wg/modulemenu/v1.php new file mode 100644 index 0000000000..96cb90eaca --- /dev/null +++ b/zin/wg/modulemenu/v1.php @@ -0,0 +1,45 @@ +getChildModule($parentID); + if (count($children) === 0) return; + + foreach ($children as $child) + { + $item = array('key' => $child->id, 'text' => $child->name); + $items = $this->buildMenuTree($item['items'], $child->id); + if(count($items) !== 0) $item['items'] = $items; + $parent[] = $item; + } + + return $parent; + } + + private function getChildModule($id) + { + return array_filter($this->modules, function($module) use($id) {return $module->parent == $id;}); + } + + protected function build() + { + global $app; + $id = $this->prop('id'); + $this->modules = $app->loadTarget('tree')->getProductStructure($id, 'story'); + $moduleItems = $this->buildMenuTree(array(), 0); + $this->setProp('items', $moduleItems); + $this->setProp('activeClass', 'active'); + + return zui::modulemenu(inherit($this)); + } +}