From 0186d28fc7bef2a274e615003e7e7f119039b138 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Thu, 17 Apr 2025 09:47:06 +0200 Subject: [PATCH 1/2] Use a different template for the sidebar to display the user's trophies --- .../templates/boxUserTrophyList.tpl | 51 ++++--------------- .../templates/boxUserTrophyListSidebar.tpl | 26 ++++++++++ .../box/UserTrophyListBoxController.class.php | 8 ++- 3 files changed, 43 insertions(+), 42 deletions(-) create mode 100644 com.woltlab.wcf/templates/boxUserTrophyListSidebar.tpl diff --git a/com.woltlab.wcf/templates/boxUserTrophyList.tpl b/com.woltlab.wcf/templates/boxUserTrophyList.tpl index ddb1c838ac3..e4f15c54b4f 100644 --- a/com.woltlab.wcf/templates/boxUserTrophyList.tpl +++ b/com.woltlab.wcf/templates/boxUserTrophyList.tpl @@ -1,41 +1,12 @@ -{if $boxPosition == 'sidebarLeft' || $boxPosition == 'sidebarRight'} -
    - {foreach from=$boxUserTrophyList item=boxUserTrophy} -
  1. -
    - {unsafe:$boxUserTrophy->getTrophy()->renderTrophy(32)} -
    +
      + {foreach from=$boxUserTrophyList item=boxUserTrophy} +
    1. +
      {unsafe:$boxUserTrophy->getTrophy()->renderTrophy(64)}
      - - -
      -
      - {user object=$boxUserTrophy->getUserProfile() tabindex='-1'} -
      -
      - {time time=$boxUserTrophy->time} -
      -
      -
    2. - {/foreach} -
    -{else} -
      - {foreach from=$boxUserTrophyList item=boxUserTrophy} -
    1. -
      {@$boxUserTrophy->getTrophy()->renderTrophy(64)}
      - -
      -

      {$boxUserTrophy->getTrophy()->getTitle()}

      - {if !$boxUserTrophy->getDescription()|empty}

      {@$boxUserTrophy->getDescription()}

      {/if}

      {user object=$boxUserTrophy->getUserProfile()} {@$boxUserTrophy->time|time}

      -
      -
    2. - {/foreach} -
    -{/if} +
    +

    {$boxUserTrophy->getTrophy()->getTitle()}

    + {if !$boxUserTrophy->getDescription()|empty}

    {unsafe:$boxUserTrophy->getDescription()}

    {/if}

    {user object=$boxUserTrophy->getUserProfile()} {time time=$boxUserTrophy->time}

    +
    +
  2. + {/foreach} +
diff --git a/com.woltlab.wcf/templates/boxUserTrophyListSidebar.tpl b/com.woltlab.wcf/templates/boxUserTrophyListSidebar.tpl new file mode 100644 index 00000000000..272fb5bef21 --- /dev/null +++ b/com.woltlab.wcf/templates/boxUserTrophyListSidebar.tpl @@ -0,0 +1,26 @@ +
    + {foreach from=$boxUserTrophyList item=boxUserTrophy} +
  1. +
    + {unsafe:$boxUserTrophy->getTrophy()->renderTrophy(32)} +
    + + + +
    +
    + {user object=$boxUserTrophy->getUserProfile() tabindex='-1'} +
    +
    + {time time=$boxUserTrophy->time} +
    +
    +
  2. + {/foreach} +
diff --git a/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php b/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php index 8b80b22b50b..adfbbcb12ab 100644 --- a/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php @@ -150,9 +150,13 @@ public function getTemplate() UserProfileRuntimeCache::getInstance()->cacheObjectIDs(\array_unique($userIDs)); - return WCF::getTPL()->render('wcf', 'boxUserTrophyList', [ + $templateName = 'boxUserTrophyList'; + if ($this->getBox()->position == 'sidebarLeft' || $this->getBox()->position == 'sidebarRight') { + $templateName = 'boxUserTrophyListSidebar'; + } + + return WCF::getTPL()->render('wcf', $templateName, [ 'boxUserTrophyList' => $this->objectList, - 'boxPosition' => $this->box->position, ]); } } From 7262ebb3dfc19c4b67e5da50c217c5592012ecc6 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Thu, 17 Apr 2025 09:50:13 +0200 Subject: [PATCH 2/2] Remove unused template variable `boxPosition` --- .../lib/system/box/ArticleListBoxController.class.php | 1 - .../lib/system/box/UserTrophyListBoxController.class.php | 8 ++++---- .../lib/system/box/WhoWasOnlineBoxController.class.php | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php b/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php index 542a5227272..f940e86666f 100644 --- a/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php @@ -94,7 +94,6 @@ protected function getTemplate() return WCF::getTPL()->render('wcf', 'boxArticleList', [ 'boxArticleList' => $this->objectList, 'boxSortField' => $this->sortField, - 'boxPosition' => $this->box->position, ]); } } diff --git a/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php b/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php index adfbbcb12ab..f1963413bd5 100644 --- a/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/UserTrophyListBoxController.class.php @@ -150,10 +150,10 @@ public function getTemplate() UserProfileRuntimeCache::getInstance()->cacheObjectIDs(\array_unique($userIDs)); - $templateName = 'boxUserTrophyList'; - if ($this->getBox()->position == 'sidebarLeft' || $this->getBox()->position == 'sidebarRight') { - $templateName = 'boxUserTrophyListSidebar'; - } + $templateName = match ($this->getBox()->position) { + 'sidebarLeft', 'sidebarRight' => 'boxUserTrophyListSidebar', + default => 'boxUserTrophyList', + }; return WCF::getTPL()->render('wcf', $templateName, [ 'boxUserTrophyList' => $this->objectList, diff --git a/wcfsetup/install/files/lib/system/box/WhoWasOnlineBoxController.class.php b/wcfsetup/install/files/lib/system/box/WhoWasOnlineBoxController.class.php index 0ee2f822a68..3ffd2e77faf 100644 --- a/wcfsetup/install/files/lib/system/box/WhoWasOnlineBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/WhoWasOnlineBoxController.class.php @@ -64,7 +64,6 @@ protected function getTemplate() { return WCF::getTPL()->render('wcf', 'boxWhoWasOnline', [ 'whoWasOnlineList' => $this->users, - 'boxPosition' => $this->box->position, 'whoWasOnlineTimeFormat' => DateUtil::TIME_FORMAT, ]); }