diff --git a/module/tree/control.php b/module/tree/control.php index 1a70271db8..f3397392bd 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -101,13 +101,17 @@ class tree extends control { if(!empty($_POST)) { - if($this->product->update($_POST)) die(js::locate($this->createLink($this->moduleName, 'index', "product=$_POST[id]"), 'parent')); + $this->tree->update($moduleID); + echo js::alert($this->lang->tree->successSave); + die(js::reload('parent')); } + $this->view->module = $this->tree->getById($moduleID); + $this->view->optionMenu = $this->tree->getOptionMenu($this->view->module->product, $this->view->module->view); + + /* 去掉自己和child。*/ + $childs = $this->tree->getAllChildId($moduleID); + foreach($childs as $childModuleID) unset($this->view->optionMenu[$childModuleID]); - $product = $this->product->getByID($productID); - $header['title'] = $this->lang->product->edit . $this->lang->colon . $product->name; - $this->assign('header', $header); - $this->assign('product', $product); $this->display(); } diff --git a/module/tree/lang/zh-cn.php b/module/tree/lang/zh-cn.php index e8b197cc35..3d0081226f 100644 --- a/module/tree/lang/zh-cn.php +++ b/module/tree/lang/zh-cn.php @@ -23,6 +23,7 @@ */ $lang->tree->common = '模块维护'; $lang->tree->add = "添加"; +$lang->tree->edit = "编辑"; $lang->tree->addChild = "添加子模块"; $lang->tree->delete = "删除模块"; $lang->tree->browse = "模块列表"; @@ -36,4 +37,8 @@ $lang->tree->manageChild = "维护子模块"; $lang->tree->child = "子模块"; $lang->tree->ajaxGetOptionMenu = "接口:获取下拉列表"; -$lang->tree->confirmDelete = " 您确定删除该模块吗?"; +$lang->tree->confirmDelete = "您确定删除该模块吗?"; +$lang->tree->successSave = "成功保存"; + +$lang->tree->name = '模块名称'; +$lang->tree->parent = '上级模块'; diff --git a/module/tree/model.php b/module/tree/model.php index 27fd67ec65..f01c16b4cf 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -151,7 +151,7 @@ class treeModel extends model private function createManageLink($module) { $linkHtml = $module->name; - //$linkHtml .= ' ' . html::a(helper::createLink('tree', 'edit', "product={$module->product}&module={$module->id}"), $this->lang->tree->edit); + if(common::hasPriv('tree', 'edit')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'edit', "module={$module->id}"), $this->lang->tree->edit, '', 'class="iframe"'); if(common::hasPriv('tree', 'browse')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'browse', "product={$module->product}&viewType={$module->view}&module={$module->id}"), $this->lang->tree->child); if(common::hasPriv('tree', 'delete')) $linkHtml .= ' ' . html::a(helper::createLink('tree', 'delete', "product={$module->product}&module={$module->id}"), $this->lang->delete, 'hiddenwin'); if(common::hasPriv('tree', 'updateorder')) $linkHtml .= ' ' . html::input("orders[$module->id]", $module->order, 'style="width:30px;text-align:center"'); @@ -251,7 +251,19 @@ class treeModel extends model } } } - + + /* 编辑一个模块。*/ + public function update($moduleID) + { + $module = fixer::input('post')->specialChars('name')->get(); + $parent = $this->getById($this->post->parent); + $childs = $this->getAllChildId($moduleID); + $module->grade = $parent ? $parent->grade + 1 : 1; + $this->dao->update(TABLE_MODULE)->data($module)->autoCheck()->check('name', 'notempty')->where('id')->eq($moduleID)->exec(); + $this->dao->update(TABLE_MODULE)->set('grade = grade + 1')->where('id')->in($childs)->andWhere('id')->ne($moduleID)->exec(); + $this->fixModulePath(); + } + /* 删除一个模块。*/ public function delete($moduleID) { @@ -279,7 +291,7 @@ class treeModel extends model for($grade = 1; $grade <= $maxGrade; $grade ++) { /* 当前级别的模块。*/ - $gradeModules = $this->dao->select('id, parent')->from(TABLE_MODULE)->where('grade')->eq($grade)->fetchAll('id'); + $gradeModules = $this->dao->select('id, parent, grade')->from(TABLE_MODULE)->where('grade')->eq($grade)->fetchAll('id'); foreach($gradeModules as $moduleID => $module) { if($grade == 1) @@ -291,13 +303,8 @@ class treeModel extends model /* 取parent模块的path。*/ if(isset($modules[$module->parent])) { - $module->path = $modules[$module->parent]->path . "$moduleID,"; - } - else - { - $module->parent = 0; - $module->grade = 1; - $module->path = ",$moduleID,"; + $module->path = $modules[$module->parent]->path . "$moduleID,"; + $module->grade = $modules[$module->parent]->grade + 1; } } } diff --git a/module/tree/view/browse.html.php b/module/tree/view/browse.html.php index 79054736c8..e1414c1bd6 100644 --- a/module/tree/view/browse.html.php +++ b/module/tree/view/browse.html.php @@ -24,6 +24,13 @@ ?> + +
id}&viewType=$viewType");?>'> diff --git a/module/tree/view/edit.html.php b/module/tree/view/edit.html.php index 7d21eb5535..fbe9f1c131 100644 --- a/module/tree/view/edit.html.php +++ b/module/tree/view/edit.html.php @@ -22,31 +22,24 @@ * @link http://www.zentao.cn */ ?> - -
- - - + +
+ +
product->edit;?>
+ - - + + - - + + - - - - -
tree->edit;?>
product->name;?>tree->parent;?>parent, "class='text-1'");?>
product->code;?>tree->name;?>name, "class='text-1'");?>
product->desc;?>
- - - + +
-