Add support for content positions for `UserListBox`
authorMarcel Werk <burntime@woltlab.com>
Fri, 16 Feb 2024 13:27:34 +0000 (14:27 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 16 Feb 2024 13:27:34 +0000 (14:27 +0100)
com.woltlab.wcf/templates/boxUserList.tpl
com.woltlab.wcf/templates/boxUserListSidebar.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/system/box/UserListBoxController.class.php

index 4c00b3b586c1e65f1c60a27d35b3a1e2653a0714..e5cbb96a3b4cd9d9527fc7a5e51e76c38b3baa69 100644 (file)
@@ -1,15 +1,5 @@
-<ul class="sidebarItemList">
-       {foreach from=$boxUsers item=boxUser}
-               <li class="box24">
-                       {user object=$boxUser type='avatar24' ariaHidden='true' tabindex='-1'}
-                       
-                       <div class="sidebarItemTitle">
-                               <h3>{user object=$boxUser}</h3>
-                               {capture assign='__boxUserLanguageItem'}{lang __optional=true}wcf.user.boxList.description.{$boxSortField}{/lang}{/capture}
-                               {if $__boxUserLanguageItem}
-                                       <small>{@$__boxUserLanguageItem}</small>
-                               {/if}
-                       </div>
-               </li>
+<div class="userCardList">
+       {foreach from=$boxUsers item=user}
+               {include file='userCard'}
        {/foreach}
-</ul>
+</div>
diff --git a/com.woltlab.wcf/templates/boxUserListSidebar.tpl b/com.woltlab.wcf/templates/boxUserListSidebar.tpl
new file mode 100644 (file)
index 0000000..4c00b3b
--- /dev/null
@@ -0,0 +1,15 @@
+<ul class="sidebarItemList">
+       {foreach from=$boxUsers item=boxUser}
+               <li class="box24">
+                       {user object=$boxUser type='avatar24' ariaHidden='true' tabindex='-1'}
+                       
+                       <div class="sidebarItemTitle">
+                               <h3>{user object=$boxUser}</h3>
+                               {capture assign='__boxUserLanguageItem'}{lang __optional=true}wcf.user.boxList.description.{$boxSortField}{/lang}{/capture}
+                               {if $__boxUserLanguageItem}
+                                       <small>{@$__boxUserLanguageItem}</small>
+                               {/if}
+                       </div>
+               </li>
+       {/foreach}
+</ul>
index 4ab76207848a0ccf3d749aea2488ed8c4f805ff1..6aa4e65fd3678cafeed59eb32fc1d11779c89e61 100644 (file)
@@ -39,6 +39,11 @@ class UserListBoxController extends AbstractDatabaseObjectListBoxController
      */
     protected $conditionDefinition = 'com.woltlab.wcf.box.userList.condition';
 
+    /**
+     * @inheritDoc
+     */
+    protected static $supportedPositions = ['contentTop', 'contentBottom', 'sidebarLeft', 'sidebarRight'];
+
     /**
      * @inheritDoc
      */
@@ -123,6 +128,11 @@ class UserListBoxController extends AbstractDatabaseObjectListBoxController
      */
     protected function getTemplate()
     {
+        $templateName = 'boxUserList';
+        if ($this->getBox()->position == 'sidebarLeft' || $this->getBox()->position == 'sidebarRight') {
+            $templateName = 'boxUserListSidebar';
+        }
+
         $userProfiles = [];
         if ($this->userIDs !== null) {
             $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($this->userIDs);
@@ -135,7 +145,7 @@ class UserListBoxController extends AbstractDatabaseObjectListBoxController
             DatabaseObject::sort($userProfiles, $this->sortField, $this->sortOrder);
         }
 
-        return WCF::getTPL()->fetch('boxUserList', 'wcf', [
+        return WCF::getTPL()->fetch($templateName, 'wcf', [
             'boxUsers' => $this->userIDs !== null ? $userProfiles : $this->objectList->getObjects(),
             'boxSortField' => $this->box->sortField,
         ], true);