diff --git a/module/doc/control.php b/module/doc/control.php index bf8285c56e..65e08cffe4 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -71,9 +71,13 @@ class doc extends control $docs = $this->doc->getDocs($libID, $productID, $projectID, $modules, $orderBy, $pager); /* Get the tree menu. */ - if($libID == 'product' or $libID == 'project') + if($libID == 'product') { - $moduleTree = $this->tree->getSystemDocTreeMenu($libID); + $moduleTree = $this->tree->getProductDocTreeMenu(); + } + elseif($libID == 'project') + { + $moduleTree = $this->tree->getProjectDocTreeMenu(); } else { diff --git a/module/doc/view/browse.html.php b/module/doc/view/browse.html.php index 7f8d494f9f..385510ea57 100644 --- a/module/doc/view/browse.html.php +++ b/module/doc/view/browse.html.php @@ -21,7 +21,7 @@ -
+
diff --git a/module/project/model.php b/module/project/model.php index 4d1d30d414..3d2e111894 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -217,6 +217,21 @@ class projectModel extends model ->fetchAll(); } + /** + * Get projects lists grouped by product. + * + * @access public + * @return array + */ + public function getProductGroupList() + { + return $this->dao->select('t1.id, t1.name, t2.product')->from(TABLE_PROJECT)->alias('t1') + ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.id = t2.project') + ->where('t1.deleted')->eq(0) + ->orderBy('t1.id') + ->fetchGroup('product'); + } + /** * Get project by id. * diff --git a/module/tree/model.php b/module/tree/model.php index 694dd4ce89..da0f73f959 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -161,73 +161,91 @@ class treeModel extends model } /** - * Get the tree menu of system document library. + * Get the tree menu of product document library. * - * @param string $libID product|project * @access public * @return string */ - public function getSystemDocTreeMenu($libID) + public function getProductDocTreeMenu() { $menu = "
    "; - if($libID == 'product') + $products = $this->loadModel('product')->getPairs(); + $modules = $this->dao->findByType('productdoc')->from(TABLE_MODULE)->orderBy('`order`')->fetchAll(); + $projectModules = $this->dao->findByType('projectdoc')->from(TABLE_MODULE)->orderBy('`order`')->fetchAll(); + + foreach($products as $productID =>$productName) { - $products = $this->loadModel('product')->getPairs(); - $modules = $this->dao->findByType('productdoc')->from(TABLE_MODULE)->orderBy('`order`')->fetchAll(); - $projectModules = $this->dao->findByType('projectdoc')->from(TABLE_MODULE)->orderBy('`order`')->fetchAll(); - - foreach($products as $productID =>$productName) + $menu .= '
  • '; + $menu .= html::a(helper::createLink('doc', 'browse', "libID=product&module=0&productID=$productID"), $productName); + if($modules) { - $menu .= '
  • '; - $menu .= html::a(helper::createLink('doc', 'browse', "libID=product&module=0&productID=$productID"), $productName); - if($modules) + $menu .= '
      '; + foreach($modules as $module) { + $menu .= '
    • ' . html::a(helper::createLink('doc', 'browse', "libID=product&module=$module->id&productID=$productID"), $module->name) . '
    • '; + } + + /* If $projectModules not emtpy, append the project modules. */ + if($projectModules) + { + $menu .= '
    • '; + $menu .= html::a(helper::createLink('doc', 'browse', "libID=product&module=0&productID=$productID&projectID=int"), $this->lang->tree->projectDoc); $menu .= '
        '; - foreach($modules as $module) + foreach($projectModules as $module) { $menu .= '
      • ' . html::a(helper::createLink('doc', 'browse', "libID=product&module=$module->id&productID=$productID"), $module->name) . '
      • '; } - - /* If $projectModules not emtpy, append the project modules. */ - if($projectModules) - { - $menu .= '
      • '; - $menu .= html::a(helper::createLink('doc', 'browse', "libID=product&module=0&productID=$productID&projectID=int"), $this->lang->tree->projectDoc); - $menu .= '
          '; - foreach($projectModules as $module) - { - $menu .= '
        • ' . html::a(helper::createLink('doc', 'browse', "libID=product&module=$module->id&productID=$productID"), $module->name) . '
        • '; - } - $menu .= '
      • '; - } - - $menu .= '
      '; + $menu .= '
  • '; } - $menu .= ''; + + $menu .= '
'; } } - elseif($libID == 'project') + + $menu .= ''; + return $menu; + } + + /** + * Get the tree menu of project document library. + * + * @access public + * @return void + */ + public function getProjectDocTreeMenu() + { + $menu = "
    "; + $products = $this->loadModel('product')->getPairs(); + $projects = $this->loadModel('project')->getProductGroupList(); + $modules = $this->dao->findByType('projectdoc')->from(TABLE_MODULE)->orderBy('`order`')->fetchAll(); + + foreach($products as $productID => $productName) { - $projects = $this->loadModel('project')->getPairs(); - $modules = $this->dao->findByType('projectdoc')->from(TABLE_MODULE)->orderBy('`order`')->fetchAll(); - - foreach($projects as $projectID =>$projectName) + $menu .= '
  • '; + $menu .= $productName; + + if(isset($projects[$productID])) { - $menu .= '
  • '; - $menu .= html::a(helper::createLink('doc', 'browse', "libID=project&moduleID=0&productID=0&projectID=$projectID"), $projectName); - if($modules) + $menu .= '
      '; + foreach($projects[$productID] as $project) { - $menu .= '
        '; - foreach($modules as $module) + $menu .= '
      • ' . html::a(helper::createLink('doc', 'browse', "libID=project&module=0&productID=0&projectID=$project->id"), $project->name); + if($modules) { - $menu .= '
      • ' . html::a(helper::createLink('doc', 'browse', "libID=project&module=$module->id&productID=0&projectID=$projectID"), $module->name) . '
      • '; + $menu .= '
          '; + foreach($modules as $module) + { + $menu .= '
        • ' . html::a(helper::createLink('doc', 'browse', "libID=project&module=$module->id&productID=0&projectID=$project->id"), $module->name) . '
        • '; + } + $menu .= '
        '; } - $menu .= '
      '; + $menu .= ''; } - $menu .= ''; + $menu .='
    '; } + $menu .='
  • '; } - + $menu .= '
'; return $menu; }