. * * @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com) * @author Chunsheng Wang * @package tree * @version $Id$ * @link http://www.zentaoms.com */ class tree extends control { protected $product; const NEW_CHILD_COUNT = 5; /* 构造函数,加载产品模块。*/ public function __construct() { parent::__construct(); $this->loadModel('product'); $this->loadModel('bug'); $this->loadModel('testcase'); } /* 设置当前的产品。*/ private function setProduct($productID) { $this->product = $this->product->getById($productID); } /* 模块列表。*/ public function browse($productID, $viewType, $currentModuleID = 0) { $product = $this->product->getById($productID); if($viewType == 'product') { /* 设置菜单。*/ $this->product->setMenu($this->product->getPairs(), $productID, 'product'); $this->lang->tree->menu = $this->lang->product->menu; $this->lang->set('menugroup.tree', 'product'); /* 设置导航。*/ $header['title'] = $this->lang->tree->manageProduct . $this->lang->colon . $product->name; $position[] = html::a($this->createLink('product', 'browse', "product=$productID"), $product->name); $position[] = $this->lang->tree->manageProduct; } elseif($viewType == 'bug') { /* 设置菜单。*/ $this->bug->setMenu($this->product->getPairs(), $productID); $this->lang->tree->menu = $this->lang->bug->menu; $this->lang->set('menugroup.tree', 'qa'); $header['title'] = $this->lang->tree->manageBug . $this->lang->colon . $product->name; $position[] = html::a($this->createLink('bug', 'browse', "product=$productID"), $product->name); $position[] = $this->lang->tree->manageBug; $this->lang->set('menugroup.tree', 'qa'); } elseif($viewType == 'case') { /* 设置菜单。*/ $this->testcase->setMenu($this->product->getPairs(), $productID); $this->lang->tree->menu = $this->lang->testcase->menu; $this->lang->set('menugroup.tree', 'qa'); $header['title'] = $this->lang->tree->manageCase . $this->lang->colon . $product->name; $position[] = html::a($this->createLink('testcase', 'browse', "product=$productID"), $product->name); $position[] = $this->lang->tree->manageCase; $this->lang->set('menugroup.tree', 'qa'); } $parentModules = $this->tree->getParents($currentModuleID); $this->assign('header', $header); $this->assign('position', $position); $this->assign('productID', $productID); $this->assign('product', $product); $this->assign('viewType', $viewType); $this->assign('modules', $this->tree->getTreeMenu($productID, $viewType, $rooteModuleID = 0, array('treeModel', 'createManageLink'))); $this->assign('sons', $this->tree->getSons($productID, $currentModuleID, $viewType)); $this->assign('currentModuleID', $currentModuleID); $this->assign('parentModules', $parentModules); $this->display(); } /* 编辑模块。*/ public function edit($moduleID) { if(!empty($_POST)) { $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]); $this->display(); } /* 更新排序。*/ public function updateOrder() { if(!empty($_POST)) { $this->tree->updateOrder($_POST['orders']); die(js::reload('parent')); } } /* 维护子菜单。*/ public function manageChild($productID, $viewType) { if(!empty($_POST)) { $this->tree->manageChild($productID, $viewType, $_POST['parentModuleID'], $_POST['modules']); die(js::reload('parent')); } } /* 删除某一个模块。*/ public function delete($productID, $moduleID, $confirm = 'no') { if($confirm == 'no') { echo js::confirm($this->lang->tree->confirmDelete, $this->createLink('tree', 'delete', "productID=$productID&moduleID=$moduleID&confirm=yes")); exit; } else { $this->tree->delete($moduleID); die(js::reload('parent')); } } /* ajax请求: 返回某一个产品的模块列表。*/ public function ajaxGetOptionMenu($productID, $viewType = 'product', $rootModuleID = 0) { $optionMenu = $this->tree->getOptionMenu($productID, $viewType, $rootModuleID); die( html::select("module", $optionMenu)); } }