From 41c79f7a2f8a0db1b2df1fecb84b2e94419ff529 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Fri, 28 Jul 2023 14:35:19 +0800 Subject: [PATCH] * Refactor ui of user::dynamic. --- module/index/config.php | 1 - module/user/ui/dynamic.html.php | 113 ++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 module/user/ui/dynamic.html.php diff --git a/module/index/config.php b/module/index/config.php index ec9e499e93..59e46dc473 100644 --- a/module/index/config.php +++ b/module/index/config.php @@ -46,6 +46,5 @@ $config->index->oldPages[] = 'dev-langitem'; $config->index->oldPages[] = 'dev-editor'; $config->index->oldPages[] = 'action-trash'; $config->index->oldPages[] = 'dept-browse'; -$config->index->oldPages[] = 'user-dynamic'; $config->index->oldPages[] = 'repo-setrules'; $config->index->oldPages[] = 'host-treemap'; diff --git a/module/user/ui/dynamic.html.php b/module/user/ui/dynamic.html.php new file mode 100644 index 0000000000..ab359afc6b --- /dev/null +++ b/module/user/ui/dynamic.html.php @@ -0,0 +1,113 @@ + + * @package user + * @link https://www.zentao.net + */ +namespace zin; + +include './featurebar.html.php'; + +/* zin: Define the feature bar on main menu. */ +$dynamicNavs = array(); +foreach($lang->user->featureBar['dynamic'] as $period => $label) +{ + $dynamicNavs[$period] = array('text' => $label, 'url' => inlink('dynamic', "userID={$user->id}&type={$period}")); +} +if(isset($dynamicNavs[$type])) $dynamicNavs[$type]['active'] = true; + +$content = null; +if(empty($dateGroups)) +{ + $content = div + ( + setClass('flex items-center justify-center h-64'), + span + ( + setClass('text-gray'), + $lang->action->noDynamic + ), + ); +} +else +{ + $content = array(); + $firstAction = ''; + $lastAction = ''; + foreach($dateGroups as $date => $actions) + { + $isToday = date(DT_DATE3) == $date; + if(empty($firstAction)) $firstAction = reset($actions); + $content[] = li + ( + div + ( + setClass('cursor-pointer leading-5'), + span + ( + icon('angle-down text-primary border-2 rounded-full toolbar z-10 bg-canvas align-middle'), + ), + span + ( + setClass('ml-2'), + $isToday ? $lang->today : $date, + ), + on::click('toggleCollapse') + ), + div + ( + setClass('border-l border-l-1 mx-2 px-4 py-3'), + div + ( + setClass('flex-auto px-4 alert actions-box'), + setClass($type == 'today' ? 'border-secondary' : ''), + dynamic + ( + set::dynamics($actions), + set::users($users), + ) + ) + ) + ); + $lastAction = end($actions); + } + + $content = ul + ( + setClass('timeline'), + $content + ); +} + + +panel +( + set::title(null), + set::headingActions(array(nav(set::items($dynamicNavs)))), + $content +); + +if(!empty($firstAction)) +{ + $firstDate = date('Y-m-d', strtotime($firstAction->originalDate) + 24 * 3600); + $lastDate = substr($lastAction->originalDate, 0, 10); + $hasPre = $this->action->hasPreOrNext($firstDate, 'pre'); + $hasNext = $this->action->hasPreOrNext($lastDate, 'next'); + $preLink = $hasPre ? inlink('dynamic', "useID={$user->id}&type={$type}&recTotal={$pager->recTotal}&date=" . strtotime($firstDate) . '&direction=pre') : 'javascript:;'; + $nextLink = $hasNext ? inlink('dynamic', "useID={$user->id}&type={$type}&recTotal={$pager->recTotal}&date=" . strtotime($lastDate) . '&direction=next') : 'javascript:;'; + + if($hasPre || $hasNext) + { + floatPreNextBtn + ( + empty($hasNext) ? null : set::preLink($nextLink), + empty($hasPre) ? null : set::nextLink($preLink) + ); + } +} + +render();