+ finish the feature of edit a module.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = '上级模块';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,13 @@
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<?php include '../../common/treeview.html.php';?>
|
||||
<?php include '../../common/colorbox.html.php';?>
|
||||
<script language='javascript'>
|
||||
$(document).ready(function()
|
||||
{
|
||||
$("a.iframe").colorbox({width:480, height:320, iframe:true, transition:'none'});
|
||||
});
|
||||
</script>
|
||||
<div class="yui-d0 yui-t3">
|
||||
<div class="yui-b">
|
||||
<form method='post' target='hiddenwin' action='<?php echo $this->createLink('tree', 'updateOrder', "product={$product->id}&viewType=$viewType");?>'>
|
||||
|
||||
@@ -22,31 +22,24 @@
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<div id='doc3'>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table align='center' class='table-4'>
|
||||
<caption><?php echo $lang->product->edit;?></caption>
|
||||
<?php include '../../common/header.lite.html.php';?>
|
||||
<div id='yui-d0' style='margin-top:20px'>
|
||||
<form method='post'>
|
||||
<table class='table-1'>
|
||||
<caption><?php echo $lang->tree->edit;?></caption>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->product->name;?></th>
|
||||
<td class='a-left'><input type='text' name='name' value='<?php echo $product->name;?>' /></td>
|
||||
<th class='rowhead'><?php echo $lang->tree->parent;?></th>
|
||||
<td><?php echo html::select('parent', $optionMenu, $module->parent, "class='text-1'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->product->code;?></th>
|
||||
<td class='a-left'><input type='text' name='code' value='<?php echo $product->code;?>' /></td>
|
||||
<th class='rowhead'><?php echo $lang->tree->name;?></th>
|
||||
<td><?php echo html::input('name', $module->name, "class='text-1'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->product->desc;?></th>
|
||||
<td class='a-left'><textarea name='desc' style='width:100%' rows='5'><?php echo $product->desc;?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'>
|
||||
<input type='submit' value='<?php echo $lang->product->saveButton;?>' accesskey='S' />
|
||||
<input type='reset' value='<?php echo $lang->reset;?>' />
|
||||
<input type='hidden' value='<?php echo $product->id;?>' name='id' />
|
||||
<td colspan='2' class='a-center'>
|
||||
<?php echo html::submitButton();?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user