browse.html.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /**
  3. * The browsetask view file of tree module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Jinyong Zhu<zhujinyong@easycorp.ltd>
  7. * @package tree
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. data('activeMenuID', 'story');
  12. $manageTitle = $lang->tree->manageChild;
  13. if(strpos($viewType, 'doc') !== false)
  14. {
  15. $manageTitle = $lang->doc->manageType;
  16. }
  17. elseif(strpos($viewType, 'trainskill') === false and strpos($viewType, 'trainpost') === false)
  18. {
  19. $manageChild = 'manage' . ucfirst($viewType) . 'Child';
  20. $manageTitle = $lang->tree->$manageChild;
  21. }
  22. $maxOrder = 0;
  23. $fnAppendApp = function($tree) use(&$fnAppendApp)
  24. {
  25. foreach($tree as $subTree)
  26. {
  27. if(!empty($subTree->children)) $subTree->children = $fnAppendApp($subTree->children);
  28. if(!empty($subTree->url)) $subTree->url .= '#app=project';
  29. }
  30. return $tree;
  31. };
  32. $tree = $fnAppendApp($tree);
  33. /* Generate module rows. */
  34. $moduleRows = array();
  35. foreach($sons as $son)
  36. {
  37. if($son->order > $maxOrder) $maxOrder = $son->order;
  38. $moduleRows[] = formRow
  39. (
  40. formGroup
  41. (
  42. inputGroup
  43. (
  44. setClass('row-module'),
  45. input
  46. (
  47. setClass('col-module'),
  48. set::name("modules[id$son->id]"),
  49. set::type('input'),
  50. set::value($son->name),
  51. set::placeholder($placeholder)
  52. ),
  53. input
  54. (
  55. setClass('col-short'),
  56. set::name("shorts[id$son->id]"),
  57. set::type('input'),
  58. set::value($son->short),
  59. set::placeholder($lang->tree->short)
  60. ),
  61. input
  62. (
  63. setClass('hidden'),
  64. set::name("order[id$son->id]"),
  65. set::value($son->order),
  66. set::control('hidden')
  67. )
  68. )
  69. )
  70. );
  71. }
  72. for($i = 0; $i < \tree::NEW_CHILD_COUNT; $i ++)
  73. {
  74. $moduleRows[] = formRow
  75. (
  76. formGroup
  77. (
  78. inputGroup
  79. (
  80. setClass('row-module'),
  81. input
  82. (
  83. setClass('col-module'),
  84. set::name("modules[$i]"),
  85. set::type('input'),
  86. set::value(''),
  87. set::placeholder($placeholder)
  88. ),
  89. input
  90. (
  91. setClass('col-short'),
  92. set::name("shorts[$i]"),
  93. set::type('input'),
  94. set::value(''),
  95. set::placeholder($lang->tree->short)
  96. ),
  97. input
  98. (
  99. setClass('hidden'),
  100. set::name("branch[$i]"),
  101. set::value(0),
  102. set::control('hidden')
  103. )
  104. ),
  105. batchActions()
  106. )
  107. );
  108. }
  109. $parentPath = array();
  110. $parentPath[] = span
  111. (
  112. a
  113. (
  114. setClass('tree-link'),
  115. set('href', helper::createLink('tree', 'browse', "rootID=$root->id&view={$viewType}&currentModuleID=0&branch=$branch")),
  116. $root->name
  117. ),
  118. h::i
  119. (
  120. setClass('icon icon-angle-right muted align-middle'),
  121. setStyle('color', '#313C52')
  122. )
  123. );
  124. foreach($parentModules as $module)
  125. {
  126. $parentPath[] = span
  127. (
  128. a
  129. (
  130. setClass('tree-link'),
  131. set('href', helper::createLink('tree', 'browse', "rootID=$root->id&view={$viewType}&currentModuleID=$module->id&branch=$branch")),
  132. $module->name
  133. ),
  134. h::i
  135. (
  136. setClass('icon icon-angle-right muted align-middle'),
  137. setStyle('color', '#313C52')
  138. )
  139. );
  140. }
  141. div
  142. (
  143. setClass('flex gap-x-4 mb-3'),
  144. !isInModal() ? backBtn
  145. (
  146. set::icon('back'),
  147. set::type('secondary'),
  148. $lang->goback
  149. ) : null,
  150. div
  151. (
  152. setClass('entity-label flex items-center gap-x-2 entity-title text-lg font-bold'),
  153. $lang->tree->common . $lang->hyphen . $root->name
  154. )
  155. );
  156. div
  157. (
  158. setClass('flex gap-x-4'),
  159. div
  160. (
  161. setClass('sidebar sidebar-left basis-2/6'),
  162. panel
  163. (
  164. set::title($lang->tree->child),
  165. setStyle('max-width', '400px'),
  166. ($app->tab == 'product' and $viewType == 'story') ? to::headingActions
  167. (
  168. btn
  169. (
  170. set
  171. (
  172. array
  173. (
  174. 'class' => 'btn primary size-sm',
  175. 'url' => createLink('tree', 'viewHistory', "productID=$rootID"),
  176. 'data-toggle' => 'modal'
  177. )
  178. ),
  179. $lang->history
  180. )
  181. ) : null,
  182. treeEditor
  183. (
  184. set('type', $viewType),
  185. set('items', $tree),
  186. set('canEdit', common::hasPriv('tree', 'edit') && $canBeChanged),
  187. set('canDelete', common::hasPriv('tree', 'delete') && $canBeChanged)
  188. )
  189. )
  190. ),
  191. div
  192. (
  193. setClass('basis-4/6'),
  194. panel
  195. (
  196. set::shadow(false),
  197. set::title($manageTitle),
  198. div
  199. (
  200. setClass('flex'),
  201. div
  202. (
  203. setClass('p-1 tree-item-content'),
  204. setStyle('max-width', '400px'),
  205. $parentPath
  206. ),
  207. form
  208. (
  209. setClass('flex-1 form-horz'),
  210. set::url(helper::createLink('tree', 'manageChild', "root=$root->id&viewType=$viewType")),
  211. $moduleRows,
  212. set::actionsClass('justify-start'),
  213. set::submitBtnText($lang->save),
  214. formGroup
  215. (
  216. setClass('hidden'),
  217. set::name('parentModuleID'),
  218. set::value($currentModuleID),
  219. set::control('hidden')
  220. ),
  221. formGroup
  222. (
  223. setClass('hidden'),
  224. set::name('maxOrder'),
  225. set::value($maxOrder),
  226. set::control('hidden')
  227. )
  228. )
  229. )
  230. )
  231. )
  232. );
  233. render();