zentaomax.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Create the select code of products.
  4. *
  5. * @param array $products
  6. * @param int $productID
  7. * @param string $currentModule
  8. * @param string $currentMethod
  9. * @param string $extra
  10. * @param int|string $branch
  11. * @param int $module
  12. * @param string $moduleType
  13. * @param bool $withBranch true|false
  14. *
  15. * @access public
  16. * @return string
  17. */
  18. public function select($products, $productID, $currentModule, $currentMethod, $extra = '', $branch = '', $module = 0, $moduleType = '', $withBranch = true)
  19. {
  20. $isQaModule = (strpos(',project,execution,', ",{$this->app->tab},") !== false and strpos(',bug,testcase,testtask,ajaxselectstory,', ",{$this->app->rawMethod},") !== false and isset($products[0])) ? true : false;
  21. $isFeedbackModel = strpos(',feedback,', ",{$this->app->tab},") !== false ? true : false;
  22. if(count($products) <= 2 and isset($products[0]))
  23. {
  24. unset($products[0]);
  25. $productID = key($products);
  26. }
  27. if(empty($products)) return;
  28. if($this->app->tab == 'project' and strpos(',zeroCase,browseUnits,groupCase,', ",$currentMethod,") !== false) $isQaModule = true;
  29. $this->app->loadLang('product');
  30. if(!$isQaModule and !$productID and !$isFeedbackModel)
  31. {
  32. unset($this->lang->product->menu->settings['subMenu']->branch);
  33. return;
  34. }
  35. $isMobile = $this->app->viewType == 'mhtml';
  36. $productID = $productID == 'all' ? 0 : $productID;
  37. setcookie("lastProduct", $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
  38. if($productID) $currentProduct = $this->getById($productID);
  39. if($isQaModule and $this->app->tab == 'project')
  40. {
  41. if($this->app->tab == 'project') $extra = strpos(',testcase,groupCase,zeroCase,', ",$currentMethod,") !== false ? $extra : $this->session->project;
  42. if($this->app->tab == 'execution') $extra = $this->session->execution;
  43. }
  44. if($isQaModule and !$productID)
  45. {
  46. $currentProduct = new stdclass();
  47. $currentProduct->name = $products[$productID];
  48. $currentProduct->type = 'normal';
  49. }
  50. if($isFeedbackModel and !$productID)
  51. {
  52. $currentProduct = new stdclass();
  53. $currentProduct->name = isset($products[$productID]) ? $products[$productID] : current($products);
  54. $currentProduct->type = 'normal';
  55. }
  56. $this->session->set('currentProductType', $currentProduct->type);
  57. $output = '';
  58. if(!empty($products))
  59. {
  60. $moduleName = 'product';
  61. if($isQaModule) $moduleName = 'bug';
  62. if($isFeedbackModel) $moduleName = 'feedback';
  63. $dropMenuLink = helper::createLink($moduleName, 'ajaxGetDropMenu', "objectID=$productID&module=$currentModule&method=$currentMethod&extra=$extra");
  64. $output = "<div class='btn-group angle-btn'><div class='btn-group'><button data-toggle='dropdown' type='button' class='btn btn-limit' id='currentItem' title='{$currentProduct->name}' style='width: 90%'><span class='text'>{$currentProduct->name}</span> <span class='caret'></span></button><div id='dropMenu' class='dropdown-menu search-list' data-ride='searchList' data-url='$dropMenuLink'>";
  65. $output .= '<div class="input-control search-box has-icon-left has-icon-right search-example"><input type="search" class="form-control search-input" /><label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label><a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a></div>';
  66. $output .= "</div></div>";
  67. if($isMobile) $output = "<a id='currentItem' href=\"javascript:showSearchMenu('product', '$productID', '$currentModule', '$currentMethod', '$extra')\"><span class='text'>{$currentProduct->name}</span> <span class='icon-caret-down'></span></a><div id='currentItemDropMenu' class='hidden affix enter-from-bottom layer'></div>";
  68. if($currentProduct->type == 'normal' || !$withBranch) unset($this->lang->product->menu->settings['subMenu']->branch);
  69. if($currentProduct->type != 'normal' && $currentModule != 'programplan' && $withBranch)
  70. {
  71. $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$currentProduct->type]);
  72. $this->lang->product->menu->settings['subMenu']->branch = str_replace('@branch@', $this->lang->product->branch, $this->lang->product->menu->settings['subMenu']->branch);
  73. $branches = $this->loadModel('branch')->getPairs($productID, 'all');
  74. $branchName = $branches[$branch];
  75. if(!$isMobile)
  76. {
  77. $params = explode(',', $extra);
  78. $dropMenuLink = helper::createLink('branch', 'ajaxGetDropMenu', "objectID=$productID&branch=$branch&module=$currentModule&method=$currentMethod&extra={$params[0]}");
  79. $output .= "<div class='btn-group'><button id='currentBranch' data-toggle='dropdown' type='button' class='btn btn-limit' title='{$branchName}' style='width: 90%'>{$branchName} <span class='caret'></span></button><div id='dropMenu' class='dropdown-menu search-list' data-ride='searchList' data-url='$dropMenuLink'>";
  80. $output .= '<div class="input-control search-box has-icon-left has-icon-right search-example"><input type="search" class="form-control search-input" /><label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label><a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a></div>';
  81. $output .= "</div></div>";
  82. }
  83. else
  84. {
  85. $output .= "<a id='currentBranch' href=\"javascript:showSearchMenu('branch', '$productID', '$currentModule', '$currentMethod', '$extra')\">{$branchName} <span class='icon-caret-down'></span></a><div id='currentBranchDropMenu' class='hidden affix enter-from-bottom layer'></div>";
  86. }
  87. }
  88. if(!$isMobile) $output .= '</div>';
  89. }
  90. return $output;
  91. }