Files
EasySoft-ZenTaoPMS/module/tree/control.php
T

157 lines
5.8 KiB
PHP

<?php
/**
* The control file of tree module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright: 2009 Chunsheng Wang
* @author Chunsheng Wang <wwccss@263.net>
* @package tree
* @version $Id$
* @link http://www.zentao.cn
*/
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->findByID($productID);
}
/* 模块列表。*/
public function browse($productID, $viewType, $currentModuleID = 0)
{
$product = $this->product->findByID($productID);
if($viewType == 'product')
{
/* 设置菜单。*/
$this->product->setMenu($this->product->getPairs(), $productID);
$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))
{
if($this->product->update($_POST)) die(js::locate($this->createLink($this->moduleName, 'index', "product=$_POST[id]"), 'parent'));
}
$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();
}
/* 更新排序。*/
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));
}
}