dynamic.html.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * The dynamic view file of user 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 Mengyi Liu <liumengyi@easycorp.ltd>
  7. * @package user
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. include './featurebar.html.php';
  12. /* zin: Define the feature bar on main menu. */
  13. $dynamicNavs = array();
  14. foreach($lang->user->featureBar['dynamic'] as $key => $label) $dynamicNavs[$key] = array('text' => $label, 'url' => inlink('dynamic', "userID={$user->id}&period={$key}"));
  15. if(isset($dynamicNavs[$period]))
  16. {
  17. if(!empty($recTotal)) $dynamicNavs[$period]['badge'] = array('text' => ($recTotal < \actionModel::MAXCOUNT ? $recTotal : (\actionModel::MAXCOUNT - 1) . '+'), 'class' => 'size-sm canvas ring-0 rounded-md bg-gray-200');
  18. $dynamicNavs[$period]['active'] = true;
  19. }
  20. $content = null;
  21. if(empty($dateGroups))
  22. {
  23. $content = div
  24. (
  25. setClass('flex items-center justify-center h-64'),
  26. span
  27. (
  28. setClass('text-gray'),
  29. $lang->action->noDynamic
  30. )
  31. );
  32. }
  33. else
  34. {
  35. $content = array();
  36. $firstAction = '';
  37. $lastAction = '';
  38. foreach($dateGroups as $date => $actions)
  39. {
  40. $lastAction = end($actions);
  41. $isToday = date(DT_DATE3) == $date;
  42. if(empty($firstAction)) $firstAction = reset($actions);
  43. $content[] = li
  44. (
  45. div
  46. (
  47. setClass('cursor-pointer leading-5'),
  48. span
  49. (
  50. icon('angle-down text-primary border-2 rounded-full z-10 bg-canvas align-middle')
  51. ),
  52. span
  53. (
  54. setClass('ml-2'),
  55. $isToday ? $lang->today : $date
  56. ),
  57. on::click('toggleCollapse')
  58. ),
  59. div
  60. (
  61. setClass('border-l border-l-1 mx-2 px-4 py-3'),
  62. div
  63. (
  64. setClass('flex-auto px-4 alert actions-box'),
  65. setClass($period == 'today' ? 'border-secondary' : ''),
  66. dynamic
  67. (
  68. set::dynamics($actions),
  69. set::users($users)
  70. )
  71. )
  72. )
  73. );
  74. }
  75. global $app;
  76. $hasMore = $app->control->loadModel('action')->hasMoreAction($lastAction);
  77. if($hasMore)
  78. {
  79. $content[] = li
  80. (
  81. a
  82. (
  83. setID('showMoreDynamic'),
  84. setClass('block text-center'),
  85. setData(array('lastid' => $lastAction->id)),
  86. set::href('###'),
  87. on::click('showMore'),
  88. icon('chevron-double-down')
  89. )
  90. );
  91. }
  92. $content = ul
  93. (
  94. setClass('timeline list-none pl-0'),
  95. $content
  96. );
  97. }
  98. panel
  99. (
  100. set::title(null),
  101. set::headingActions(array(nav(set::items($dynamicNavs)))),
  102. $content
  103. );
  104. if(!empty($firstAction))
  105. {
  106. $firstDate = date('Y-m-d', strtotime($firstAction->originalDate) + 24 * 3600);
  107. $lastDate = substr($lastAction->originalDate, 0, 10);
  108. $hasPre = $this->action->hasPreOrNext($firstDate, 'pre');
  109. $hasNext = $this->action->hasPreOrNext($lastDate, 'next');
  110. $preLink = $hasPre ? inlink('dynamic', "userID={$user->id}&period={$period}&recTotal={$recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;';
  111. $nextLink = $hasNext ? inlink('dynamic', "userID={$user->id}&period={$period}&recTotal={$recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;';
  112. if($hasPre || $hasNext)
  113. {
  114. floatPreNextBtn
  115. (
  116. empty($hasNext) ? null : set::preLink($nextLink),
  117. empty($hasPre) ? null : set::nextLink($preLink)
  118. );
  119. }
  120. }
  121. render();