lite.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /**
  3. * 设置导航。
  4. * Set navigation.
  5. *
  6. * @param int $executionID
  7. * @param int $buildID
  8. * @param string $extra
  9. * @access public
  10. * @return void
  11. */
  12. public function setMenu($executionID, $buildID = 0, $extra = '')
  13. {
  14. common::setMenuVars('execution', $executionID);
  15. $execution = $this->getById($executionID);
  16. if(isset($this->lang->execution->menu->kanban))
  17. {
  18. $this->loadModel('project')->setMenu($execution->project);
  19. $this->lang->kanbanProject->menu->execution['subMenu'] = new stdClass();
  20. if($this->app->rawModule == 'tree') unset($this->lang->kanbanProject->menu->execution['subMenu']);
  21. }
  22. $kanbanList = $this->getList($execution->project, 'kanban', 'all');
  23. $currentKanban = zget($kanbanList, $execution->id, '');
  24. if(empty($currentKanban)) $this->accessDenied();
  25. $subMenu = $this->lang->execution->menu;
  26. foreach($subMenu as $key => $value)
  27. {
  28. if(common::hasPriv('execution', $key))
  29. {
  30. $tmpValue = explode('|', $value['link']);
  31. $subMenu->{$key}['name'] = $tmpValue[0];
  32. $subMenu->{$key}['module'] = $tmpValue[1];
  33. $subMenu->{$key}['method'] = $tmpValue[2];
  34. $subMenu->{$key}['vars'] = $tmpValue[3];
  35. }
  36. else
  37. {
  38. unset($subMenu->$key);
  39. }
  40. }
  41. $this->setSubNav($kanbanList, $currentKanban);
  42. }
  43. /**
  44. * 设置三级导航。
  45. * Set sub navigation.
  46. *
  47. * @param array $kanbanList
  48. * @param object $currentKanban
  49. * @access public
  50. * @return void
  51. */
  52. public function setSubNav($kanbanList, $currentKanban)
  53. {
  54. $lowerModule = strtolower($this->app->rawModule);
  55. $lowerMethod = strtolower($this->app->rawMethod);
  56. $modulePageNav = "";
  57. $modulePageNav .= "<div class='btn-group angle-btn active'><div class='btn-group'>";
  58. $modulePageNav .= "<button data-toggle='dropdown' type='button' class='btn' style='border-radius: 4px;'>{$currentKanban->name} <span class='caret'></span></button>";
  59. $modulePageNav .= "<ul class='dropdown-menu'>";
  60. foreach($kanbanList as $kanbanID => $kanban)
  61. {
  62. if($this->session->kanbanview && strpos('|kanban|task|calendar|gantt|tree|grouptask|', "|{$this->session->kanbanview}|") !== false)
  63. {
  64. $method = $this->session->kanbanview;
  65. }
  66. elseif($this->cookie->kanbanview && strpos('|kanban|task|calendar|gantt|tree|grouptask|', "|{$this->cookie->kanbanview}|") !== false)
  67. {
  68. $method = $this->cookie->kanbanview;
  69. }
  70. else
  71. {
  72. $method = 'kanban';
  73. }
  74. $module = 'execution';
  75. if($lowerModule == 'task' and $lowerMethod == 'create')
  76. {
  77. $module = 'task';
  78. $method = 'create';
  79. }
  80. $modulePageNav .= '<li>' . html::a(helper::createLink($module, $method, "execution=$kanban->id"), $kanban->name) . '</li>';
  81. }
  82. $modulePageNav .= "</ul></div></div>";
  83. if($lowerModule == 'execution' and strpos('|kanban|task|calendar|gantt|tree|grouptask|', "|{$lowerMethod}|") !== false)
  84. {
  85. $this->session->set('kanbanview', $lowerMethod);
  86. setcookie('kanbanview', $lowerMethod, $this->config->cookieLife, $this->config->webRoot, '', false, true);
  87. }
  88. if(strpos('|task|calendar|gantt|tree|grouptask|', "|{$lowerMethod}|") !== false) $this->lang->TRActions = $this->getTRActions($lowerMethod);
  89. if(strpos('|relation|maintainrelation|', "|{$lowerMethod}|") !== false) $this->lang->TRActions = $this->getTRActions('gantt');
  90. if($lowerModule == 'task' or ($lowerModule == 'execution' and strpos('|kanban|task|calendar|gantt|tree|grouptask|', "|{$lowerMethod}|") === false))
  91. {
  92. if($this->session->kanbanview)
  93. {
  94. $this->lang->TRActions = $this->getTRActions($this->session->kanbanview);
  95. }
  96. elseif($this->cookie->kanbanview)
  97. {
  98. $this->lang->TRActions = $this->getTRActions($this->cookie->kanbanview);
  99. }
  100. }
  101. $this->lang->modulePageNav = $modulePageNav;
  102. }
  103. /**
  104. * 设置右上角页面切换按钮。
  105. * Set right top page switch button.
  106. *
  107. * @param string $currentMethod
  108. * @access public
  109. * @return void
  110. */
  111. public function getTRActions($currentMethod)
  112. {
  113. $subMenu = $this->lang->execution->menu;
  114. foreach($subMenu as $key => $value)
  115. {
  116. if(common::hasPriv('execution', $key))
  117. {
  118. $tmpValue = explode('|', $value['link']);
  119. $subMenu->{$key}['name'] = $tmpValue[0];
  120. $subMenu->{$key}['module'] = $tmpValue[1];
  121. $subMenu->{$key}['method'] = $tmpValue[2];
  122. $subMenu->{$key}['vars'] = $tmpValue[3];
  123. }
  124. else
  125. {
  126. unset($subMenu->$key);
  127. }
  128. }
  129. $TRActions = '';
  130. $TRActions .= "<div class='btn-group dropdown'>";
  131. $TRActions .= html::a("javascript:;", "<i class='icon icon-" . $this->lang->execution->icons[$currentMethod]."'> </i>" . $subMenu->{$currentMethod}['name'] . " <span class='caret'></span>", '', "class='btn btn-link' data-toggle='dropdown'");
  132. $TRActions .= "<ul class='dropdown-menu pull-right'>";
  133. foreach($subMenu as $subKey => $subName)
  134. {
  135. $active = $this->session->kanbanview == $subKey ? "class='active'" : '';
  136. $TRActions .= "<li $active>" . html::a(helper::createLink('execution', $subName['method'], $subName['vars']), "<i class='icon icon-" . $this->lang->execution->icons[$subName['method']] . "'></i> " . $subName['name']) . '</li>';
  137. }
  138. $TRActions .= "</ul></div>";
  139. return $TRActions;
  140. }