view.biz.html.hook.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace zin;
  3. $context = \zin\context();
  4. extract($context->data);
  5. global $lang;
  6. if($project->hasProduct && $project->charter && $project->linkType == 'roadmap')
  7. {
  8. $relatedProducts = null;
  9. foreach($products as $productID => $product)
  10. {
  11. $productDom = null;
  12. $branches = array();
  13. foreach($product->branches as $branchID)
  14. {
  15. $branchName = isset($branchGroups[$productID][$branchID]) ? '/' . $branchGroups[$productID][$branchID] : '';
  16. $branches[] = div
  17. (
  18. setClass('flex clip w-full items-center'),
  19. icon('product mr-2'),
  20. a
  21. (
  22. setClass('flex'),
  23. set::title($product->name . $branchName),
  24. hasPriv('product', 'browse') ? set::href(createLink('product', 'browse', "productID={$productID}&branch={$branchID}")) : null,
  25. span(setClass('flex-1'), setStyle('width', '0'), $product->name . $branchName)
  26. )
  27. );
  28. }
  29. $productDom = h::td(div(setClass('flex flex-wrap'), $branches));
  30. $roadmapNode = array();
  31. $roadmapDom = null;
  32. $roadmapIdList = explode(',', $product->roadmaps);
  33. $roadmapIdList = array_unique(array_filter($roadmapIdList));
  34. foreach($roadmapIdList as $roadmapID)
  35. {
  36. if(!isset($roadmaps[$productID][$roadmapID])) continue;
  37. $roadmap = $roadmaps[$productID][$roadmapID];
  38. $class = 'clip';
  39. if(count($roadmapIdList) <= 2) $class .= ' flex flex-1 w-0 items-center';
  40. if(count($roadmapIdList) > 2) $class .= ' flex-none w-1/3';
  41. if(count($roadmapNode) > 2) $class .= ' mt-2';
  42. if(count($roadmapNode) % 3 != 0) $class .= ' pl-6';
  43. $roadmapNode[] = div
  44. (
  45. setClass($class),
  46. icon('productplan mr-2 '),
  47. a(
  48. set::title($roadmap->name),
  49. hasPriv('roadmap', 'view') ? set::href(createLink('roadmap', 'view', "roadmapID={$roadmap->id}")) : null,
  50. span($roadmap->name)
  51. )
  52. );
  53. }
  54. $roadmapDom[] = h::td(div(setClass('flex flex-wrap'), $roadmapNode));
  55. $relatedProducts[] = h::tr(setClass('border-r'), $productDom, $roadmapDom);
  56. }
  57. query('.productsBox')->find('tbody')->replaceWith($relatedProducts);
  58. $thRoadmap = h::th
  59. (
  60. setClass('th-plan'),
  61. span
  62. (
  63. setClass('flex'),
  64. img(set('src', 'static/svg/productplan.svg'), setClass('mr-2')),
  65. $lang->project->manageRoadmap
  66. )
  67. );
  68. query('.productsBox')->find('.th-plan')->replaceWith($thRoadmap);
  69. }
  70. if($project->charter)
  71. {
  72. $charterDom = div
  73. (
  74. icon('seal mr-2 text-primary'),
  75. a
  76. (
  77. set::title($charter->name),
  78. hasPriv('charter', 'view') ? set::href(createLink('charter', 'view', "id={$project->charter}")) : null,
  79. span($charter->name)
  80. )
  81. );
  82. query('.program')->after($project->charter ? div(setClass('flex mt-4 charter'), div(setClass('clip charterBox'), $charterDom)) : null);
  83. query('.program')->addClass($project->parent ? '' : 'hidden');
  84. }