Use guest support of UserFunctionTemplatePlugin
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / templates / conversationList.tpl
index a867282960789937f05bdd82a5d128e8088deed0..73c29f87c32977b196661dc73025a7ff75391ed5 100644 (file)
@@ -6,12 +6,16 @@
                        <h1 class="contentTitle">{if $filter}{lang}wcf.conversation.folder.{$filter}{/lang}{else}{$__wcf->getActivePage()->getTitle()}{/if}</h1>
                </div>
                
-               <nav class="contentHeaderNavigation">
-                       <ul>
-                               <li><a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.conversation.button.add{/lang}</span></a></li>
-                               {event name='contentHeaderNavigation'}
-                       </ul>
-               </nav>
+               {hascontent}
+                       <nav class="contentHeaderNavigation">
+                               <ul>
+                                       {content}
+                                               {if $__wcf->session->getPermission('user.conversation.canStartConversation')}<li><a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.conversation.button.add{/lang}</span></a></li>{/if}
+                                               {event name='contentHeaderNavigation'}
+                                       {/content}
+                               </ul>
+                       </nav>
+               {/hascontent}
        </header>
 {/capture}
 
@@ -55,7 +59,7 @@
                                
                                <div class="formSubmit">
                                        <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
-                                       {@SECURITY_TOKEN_INPUT_TAG}
+                                       {csrfToken}
                                </div>
                        </form>
                </div>
 {/hascontent}
 
 {if !$items}
-       <p class="info">{lang}wcf.conversation.noConversations{/lang}</p>
+       <p class="info" role="status">{lang}wcf.conversation.noConversations{/lang}</p>
 {else}
        <div class="section tabularBox messageGroupList conversationList jsClipboardContainer" data-type="com.woltlab.wcf.conversation.conversation">
                <ol class="tabularList">
                        <li class="tabularListRow tabularListRowHead">
                                <ol class="tabularListColumns">
                                        <li class="columnMark jsOnly"><label><input type="checkbox" class="jsClipboardMarkAll"></label></li>
-                                       <li class="columnSubject{if $sortField === 'subject'} active {@$sortOrder}{/if}"><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField=subject&sortOrder={if $sortField == 'subject' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">{lang}wcf.global.subject{/lang}</a></li>
-                                       <li class="columnStats{if $sortField == 'replies'} active {@$sortOrder}{/if}"><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField=replies&sortOrder={if $sortField == 'replies' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">{lang}wcf.conversation.replies{/lang}</a></li>
-                                       <li class="columnLastPost{if $sortField === 'lastPostTime'} active {@$sortOrder}{/if}"><a href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField=lastPostTime&sortOrder={if $sortField == 'lastPostTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">{lang}wcf.conversation.lastPostTime{/lang}</a></li>
                                        
-                                       {event name='columnHeads'}
+                                       <li class="columnSort">
+                                               <ul class="inlineList">
+                                                       <li>
+                                                               <a rel="nofollow" href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField={$sortField}&sortOrder={if $sortOrder == 'ASC'}DESC{else}ASC{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">
+                                                                       <span class="icon icon16 fa-sort-amount-{$sortOrder|strtolower} jsTooltip" title="{lang}wcf.global.sorting{/lang} ({lang}wcf.global.sortOrder.{if $sortOrder === 'ASC'}ascending{else}descending{/if}{/lang})"></span>
+                                                               </a>
+                                                       </li>
+                                                       <li>
+                                                               <div class="dropdown">
+                                                                       <span class="dropdownToggle">{if $sortField == 'subject'}{lang}wcf.global.subject{/lang}{else}{lang}wcf.conversation.{$sortField}{/lang}{/if}</span>
+                                                                       
+                                                                       <ul class="dropdownMenu">
+                                                                               {foreach from=$validSortFields item=_sortField}
+                                                                                       <li{if $_sortField === $sortField} class="active"{/if}><a rel="nofollow" href="{link controller='ConversationList'}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}pageNo={@$pageNo}&sortField={$_sortField}&sortOrder={if $sortField === $_sortField}{if $sortOrder === 'DESC'}ASC{else}DESC{/if}{else}{$sortOrder}{/if}{if $labelID}&labelID={@$labelID}{/if}{/link}">{if $_sortField == 'subject'}{lang}wcf.global.subject{/lang}{else}{lang}wcf.conversation.{$_sortField}{/lang}{/if}</a></li>
+                                                                               {/foreach}
+                                                                       </ul>
+                                                               </div>
+                                                       </li>
+                                               </ul>
+                                       </li>
                                </ol>
                        </li>
                        
                                                        {/hascontent}
                                                                
                                                        <h3>
-                                                               <a href="{if $conversation->isNew()}{link controller='Conversation' object=$conversation}action=firstNew{/link}{else}{link controller='Conversation' object=$conversation}{/link}{/if}" class="conversationLink messageGroupLink" data-conversation-id="{@$conversation->conversationID}">{$conversation->subject}</a>
+                                                               <a href="{if $conversation->isNew()}{link controller='Conversation' object=$conversation}action=firstNew{/link}{else}{$conversation->getLink()}{/if}" class="conversationLink messageGroupLink" data-object-id="{@$conversation->conversationID}">{$conversation->subject}</a>
                                                                {if $conversation->replies}
                                                                        <span class="badge messageGroupCounterMobile">{@$conversation->replies|shortUnit}</span>
                                                                {/if}
                                                        </h3>
                                                        
-                                                       <aside class="statusDisplay">
+                                                       <aside class="statusDisplay" role="presentation">
                                                                <ul class="statusIcons">
                                                                        {if $conversation->isClosed}<li><span class="icon icon16 fa-lock jsIconLock jsTooltip" title="{lang}wcf.global.state.closed{/lang}"></span></li>{/if}
                                                                        {if $conversation->attachments}<li><span class="icon icon16 fa-paperclip jsIconAttachment jsTooltip" title="{lang}wcf.conversation.attachments{/lang}"></span></li>{/if}
                                                        </aside>
                                                        
                                                        <ul class="inlineList dotSeparated small messageGroupInfo">
-                                                               <li class="messageGroupAuthor">{if $conversation->userID}<a href="{link controller='User' object=$conversation->getUserProfile()->getDecoratedObject()}{/link}" class="userLink" data-user-id="{@$conversation->userID}">{$conversation->username}</a>{else}{$conversation->username}{/if}</li>
+                                                               <li class="messageGroupAuthor">{user object=$conversation->getUserProfile()}</li>
                                                                <li class="messageGroupTime">{@$conversation->time|time}</li>
-                                                               <li class="messageGroupEditLink jsOnly"><a class="jsConversationInlineEditor">{lang}wcf.global.button.edit{/lang}</a></li>
+                                                               <li class="messageGroupEditLink jsOnly"><a href="#" class="jsConversationInlineEditor">{lang}wcf.global.button.edit{/lang}</a></li>
                                                                {event name='messageGroupInfo'}
                                                        </ul>
                                                        
                                                        {if $conversation->getParticipantSummary()|count}
                                                                <small class="conversationParticipantSummary">
                                                                        {assign var='participantSummaryCount' value=$conversation->getParticipantSummary()|count}
-                                                                       {lang}wcf.conversation.participants{/lang}: {implode from=$conversation->getParticipantSummary() item=participant}<a href="{link controller='User' object=$participant}{/link}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-user-id="{@$participant->userID}">{$participant->username}</a>{/implode}
+                                                                       {lang}wcf.conversation.participants{/lang}: {implode from=$conversation->getParticipantSummary() item=participant}<a href="{$participant->getLink()}" class="userLink{if $participant->hideConversation == 2} conversationLeft{/if}" data-object-id="{@$participant->userID}">{$participant->username}</a>{/implode}
                                                                        {if $participantSummaryCount < $conversation->participants}{lang}wcf.conversation.participants.other{/lang}{/if}
                                                                </small>
                                                        {/if}
                                                                <dd>{@$conversation->participants|shortUnit}</dd>
                                                        </dl>
                                                        
-                                                       <div class="messageGroupListStatsSimple">{@$conversation->replies|shortUnit}</div>
+                                                       <div class="messageGroupListStatsSimple">{if $conversation->replies}<span class="icon icon16 fa-comment-o" aria-label="{lang}wcf.conversation.replies{/lang}"></span> {@$conversation->replies|shortUnit}{/if}</div>
                                                </li>
                                                <li class="columnLastPost">
-                                                       {if $conversation->replies != 0}
+                                                       {if $conversation->replies != 0 && $conversation->lastPostTime}
                                                                <div class="box32">
                                                                        <a href="{link controller='Conversation' object=$conversation}action=lastPost{/link}" class="jsTooltip" title="{lang}wcf.conversation.gotoLastPost{/lang}">{@$conversation->getLastPosterProfile()->getAvatar()->getImageTag(32)}</a>
                                                                        
                                                                        <div>
                                                                                <p>
-                                                                                       {if $conversation->lastPosterID}
-                                                                                               <a href="{link controller='User' object=$conversation->getLastPosterProfile()->getDecoratedObject()}{/link}" class="userLink" data-user-id="{@$conversation->getLastPosterProfile()->userID}">{$conversation->lastPoster}</a>
-                                                                                       {else}
-                                                                                               {$conversation->lastPoster}
-                                                                                       {/if}
+                                                                                       {user object=$conversation->getLastPosterProfile()}
                                                                                </p>
                                                                                <small>{@$conversation->lastPostTime|time}</small>
                                                                        </div>
                </div>
        {/hascontent}
        
-       <nav class="contentFooterNavigation">
-               <ul>
-                       <li><a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.conversation.button.add{/lang}</span></a></li>
-                       {event name='contentFooterNavigation'}
-               </ul>
-       </nav>
+       {hascontent}
+               <nav class="contentFooterNavigation">
+                       <ul>
+                               {content}
+                                       {if $__wcf->session->getPermission('user.conversation.canStartConversation')}<li><a href="{link controller='ConversationAdd'}{/link}" title="{lang}wcf.conversation.add{/lang}" class="button"><span class="icon icon16 fa-plus"></span> <span>{lang}wcf.conversation.button.add{/lang}</span></a></li>{/if}
+                                       {event name='contentFooterNavigation'}
+                               {/content}
+                       </ul>
+               </nav>
+       {/hascontent}
 </footer>
 
 <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Conversation{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@LAST_UPDATE_TIME}"></script>
 <script data-relocate="true">
-       require(['Language', 'WoltLabSuite/Core/Ui/ItemList/User'], function(Language, UiItemListUser) {
+       require(['Language', 'WoltLabSuite/Core/Controller/Popover', 'WoltLabSuite/Core/Ui/ItemList/User'], function(Language, ControllerPopover, UiItemListUser) {
                Language.addObject({
-                       'wcf.conversation.edit.addParticipants': '{lang}wcf.conversation.edit.addParticipants{/lang}',
-                       'wcf.conversation.edit.assignLabel': '{lang}wcf.conversation.edit.assignLabel{/lang}',
-                       'wcf.conversation.edit.close': '{lang}wcf.conversation.edit.close{/lang}',
-                       'wcf.conversation.edit.leave': '{lang}wcf.conversation.edit.leave{/lang}',
-                       'wcf.conversation.edit.open': '{lang}wcf.conversation.edit.open{/lang}',
-                       'wcf.conversation.label.management': '{lang}wcf.conversation.label.management{/lang}',
-                       'wcf.conversation.label.management.addLabel.success': '{lang}wcf.conversation.label.management.addLabel.success{/lang}',
-                       'wcf.conversation.label.management.deleteLabel.confirmMessage': '{lang}wcf.conversation.label.management.deleteLabel.confirmMessage{/lang}',
-                       'wcf.conversation.label.management.editLabel': '{lang}wcf.conversation.label.management.editLabel{/lang}',
-                       'wcf.conversation.label.placeholder': '{lang}wcf.conversation.label.placeholder{/lang}',
-                       'wcf.conversation.leave.title': '{lang}wcf.conversation.leave.title{/lang}',
-                       'wcf.global.state.closed': '{lang}wcf.global.state.closed{/lang}',
-                       'wcf.conversation.label.assignLabels': '{lang}wcf.conversation.label.assignLabels{/lang}'
+                       'wcf.conversation.edit.addParticipants': '{jslang}wcf.conversation.edit.addParticipants{/jslang}',
+                       'wcf.conversation.edit.assignLabel': '{jslang}wcf.conversation.edit.assignLabel{/jslang}',
+                       'wcf.conversation.edit.close': '{jslang}wcf.conversation.edit.close{/jslang}',
+                       'wcf.conversation.edit.leave': '{jslang}wcf.conversation.edit.leave{/jslang}',
+                       'wcf.conversation.edit.open': '{jslang}wcf.conversation.edit.open{/jslang}',
+                       'wcf.conversation.edit.subject': '{jslang}wcf.conversation.edit.subject{/jslang}',
+                       'wcf.conversation.label.management': '{jslang}wcf.conversation.label.management{/jslang}',
+                       'wcf.conversation.label.management.addLabel.success': '{jslang}wcf.conversation.label.management.addLabel.success{/jslang}',
+                       'wcf.conversation.label.management.deleteLabel.confirmMessage': '{jslang}wcf.conversation.label.management.deleteLabel.confirmMessage{/jslang}',
+                       'wcf.conversation.label.management.editLabel': '{jslang}wcf.conversation.label.management.editLabel{/jslang}',
+                       'wcf.conversation.label.placeholder': '{jslang}wcf.conversation.label.placeholder{/jslang}',
+                       'wcf.conversation.leave.title': '{jslang}wcf.conversation.leave.title{/jslang}',
+                       'wcf.global.state.closed': '{jslang}wcf.global.state.closed{/jslang}',
+                       'wcf.global.subject': '{jslang}wcf.global.subject{/jslang}',
+                       'wcf.conversation.label.assignLabels': '{jslang}wcf.conversation.label.assignLabels{/jslang}'
                });
                
                WCF.Clipboard.init('wcf\\page\\ConversationListPage', {@$hasMarkedItems}, { });
                
                new WCF.Conversation.Clipboard($editorHandler);
                new WCF.Conversation.Label.Manager('{link controller='ConversationList' encode=false}{if $filter}filter={@$filter}&{/if}{if !$participants|empty}participants={implode from=$participants item=participant}{$participant|rawurlencode}{/implode}&{/if}sortField={$sortField}&sortOrder={$sortOrder}&pageNo={@$pageNo}{/link}');
-               new WCF.Conversation.Preview();
                new WCF.Conversation.MarkAsRead();
                new WCF.Conversation.MarkAllAsRead();
                
                }
                
                UiItemListUser.init('participants', {
-                       excludedSearchValues: ['{$__wcf->user->username|encodeJS}']
+                       excludedSearchValues: ['{$__wcf->user->username|encodeJS}'],
+                       maxItems: 20
+               });
+               
+               ControllerPopover.init({
+                       className: 'conversationLink',
+                       dboAction: 'wcf\\data\\conversation\\ConversationAction',
+                       identifier: 'com.woltlab.wcf.conversation'
                });
        });
 </script>