diff --git a/module/tree/control.php b/module/tree/control.php index 0cebcaa2e2..e277a28cf4 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -13,16 +13,25 @@ class tree extends control { const NEW_CHILD_COUNT = 5; - /* 模块列表。*/ + /** + * Module browse. + * + * @param int $rootID + * @param string $viewType story|bug|case|doc + * @param int $currentModuleID + * @access public + * @return void + */ public function browse($rootID, $viewType, $currentModuleID = 0) { - /* 根据视图的不同,获得相应的产品或者文档库。*/ + /* According to the type, set the module root and modules. */ if(strpos('story|bug|case', $viewType) !== false) { $product = $this->loadModel('product')->getById($rootID); $this->view->root = $product; $this->view->productModules = $this->tree->getOptionMenu($rootID, 'story'); } + /* The viewType is doc. */ elseif(strpos($viewType, 'doc') !== false) { $this->loadModel('doc'); @@ -43,19 +52,16 @@ class tree extends control if($viewType == 'story') { - /* 设置菜单。*/ $this->product->setMenu($this->product->getPairs(), $rootID, 'story'); $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=$rootID"), $product->name); $position[] = $this->lang->tree->manageProduct; } elseif($viewType == 'bug') { - /* 设置菜单。*/ $this->loadModel('bug')->setMenu($this->product->getPairs(), $rootID); $this->lang->tree->menu = $this->lang->bug->menu; $this->lang->set('menugroup.tree', 'qa'); @@ -66,7 +72,6 @@ class tree extends control } elseif($viewType == 'case') { - /* 设置菜单。*/ $this->loadModel('testcase')->setMenu($this->product->getPairs(), $rootID); $this->lang->tree->menu = $this->lang->testcase->menu; $this->lang->set('menugroup.tree', 'qa'); @@ -77,7 +82,6 @@ class tree extends control } elseif(strpos($viewType, 'doc') !== false) { - /* 设置菜单。*/ $this->doc->setMenu($this->doc->getLibs(), $rootID, 'doc'); $this->lang->tree->menu = $this->lang->doc->menu; $this->lang->set('menugroup.tree', 'doc'); @@ -99,7 +103,13 @@ class tree extends control $this->display(); } - /* 编辑模块。*/ + /** + * Edit a module. + * + * @param int $moduleID + * @access public + * @return void + */ public function edit($moduleID) { if(!empty($_POST)) @@ -112,14 +122,19 @@ class tree extends control $this->view->optionMenu = $this->tree->getOptionMenu($this->view->module->root, $this->view->module->type); $this->view->users = $this->loadModel('user')->getPairs('noclosed'); - /* 去掉自己和child。*/ + /* Remove self and childs from the $optionMenu. Because it's parent can't be self or childs. */ $childs = $this->tree->getAllChildId($moduleID); foreach($childs as $childModuleID) unset($this->view->optionMenu[$childModuleID]); die($this->display()); } - /* 更新排序。*/ + /** + * Update modules' orders. + * + * @access public + * @return void + */ public function updateOrder() { if(!empty($_POST)) @@ -129,7 +144,14 @@ class tree extends control } } - /* 维护子菜单。*/ + /** + * Manage child modules. + * + * @param int $rootID + * @param string $viewType + * @access public + * @return void + */ public function manageChild($rootID, $viewType) { if(!empty($_POST)) @@ -139,7 +161,15 @@ class tree extends control } } - /* 删除某一个模块。*/ + /** + * Delete a module. + * + * @param int $rootID + * @param int $moduleID + * @param string $confirm yes|no + * @access public + * @return void + */ public function delete($rootID, $moduleID, $confirm = 'no') { if($confirm == 'no') @@ -154,14 +184,29 @@ class tree extends control } } - /* ajax请求: 返回某一个产品的模块列表。*/ + /** + * AJAX: Get the option menu of modules. + * + * @param int $rootID + * @param string $viewType + * @param int $rootModuleID + * @access public + * @return string the html select string. + */ public function ajaxGetOptionMenu($rootID, $viewType = 'product', $rootModuleID = 0) { $optionMenu = $this->tree->getOptionMenu($rootID, $viewType, $rootModuleID); die( html::select("module", $optionMenu, '', 'onchange=setAssignedTo()')); } - /* ajax请求: 返回某一个模块的son模块.*/ + /** + * AJAX: get a module's son modules. + * + * @param int $moduleID + * @param int $rootID + * @access public + * @return string json_encoded modules. + */ public function ajaxGetSonModules($moduleID, $rootID = 0) { if($moduleID) die(json_encode($this->dao->findByParent($moduleID)->from(TABLE_MODULE)->fetchPairs('id', 'name'))); diff --git a/module/tree/model.php b/module/tree/model.php index 5b218fd39e..694dd4ce89 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -13,16 +13,30 @@ dao->findById((int)$moduleID)->from(TABLE_MODULE)->fetch(); } - /* 生成查询的sql语句。*/ + /** + * Build the sql query. + * + * @param int $rootID + * @param string $type + * @param int $startModule + * @access private + * @return void + */ private function buildMenuQuery($rootID, $type, $startModule) { - /* 查找startModule。*/ + /* Set the start module. */ $startModulePath = ''; if($startModule > 0) { @@ -38,7 +52,15 @@ class treeModel extends model ->get(); } - /* 获取模块的下类列表,用于生成select控件。*/ + /** + * Create an option menu in html. + * + * @param int $rootID + * @param string $type + * @param int $startModule + * @access public + * @return string + */ public function getOptionMenu($rootID, $type = 'story', $startModule = 0) { $treeMenu = array(); @@ -95,7 +117,17 @@ class treeModel extends model return $lastMenu; } - /* 获取树状的模块列表。*/ + /** + * Get the tree menu in html. + * + * @param int $rootID + * @param string $type + * @param int $startModule + * @param string $userFunc the function used to create link + * @param string $extra extra params + * @access public + * @return string + */ public function getTreeMenu($rootID, $type = 'root', $startModule = 0, $userFunc, $extra = '') { $treeMenu = array(); @@ -128,7 +160,13 @@ class treeModel extends model return $lastMenu; } - /* 获得系统文档库的树状列表。*/ + /** + * Get the tree menu of system document library. + * + * @param string $libID product|project + * @access public + * @return string + */ public function getSystemDocTreeMenu($libID) { $menu = "