Skip to content

Commit 436a545

Browse files
committed
Use the new quote system
1 parent 9e978f6 commit 436a545

File tree

8 files changed

+26
-203
lines changed

8 files changed

+26
-203
lines changed

fileDelete.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<file>acp/update_com.woltlab.wcf.conversation_5.5_cleanup_orphaned_attachments.php</file>
1313
<file>js/WoltLab/Conversation/UI/Participant/Add.js</file>
1414
<file>js/WoltLab/Conversation/Ui/Participant/Add.js</file>
15+
<file>js/WoltLab/Conversation/Ui/Message/Quote.js</file>
1516
<file>js/require.build.js</file>
1617
<file>js/require.build.min.js</file>
1718
<file>lib/form/ConversationMessageAddForm.class.php</file>

files/js/WoltLabSuite/Core/Conversation/Ui/Message/Quote.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

files/lib/data/conversation/message/ConversationMessage.class.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use wcf\data\attachment\GroupedAttachmentList;
66
use wcf\data\conversation\Conversation;
77
use wcf\data\DatabaseObject;
8+
use wcf\data\IEmbeddedMessageObject;
89
use wcf\data\IMessage;
10+
use wcf\data\object\type\ObjectTypeCache;
911
use wcf\data\TUserContent;
1012
use wcf\system\html\output\HtmlOutputProcessor;
1113
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
@@ -33,7 +35,7 @@
3335
* @property-read int $editCount number of times the conversation message has been edited
3436
* @property-read int $hasEmbeddedObjects number of embedded objects in the conversation message
3537
*/
36-
class ConversationMessage extends DatabaseObject implements IMessage
38+
class ConversationMessage extends DatabaseObject implements IMessage, IEmbeddedMessageObject
3739
{
3840
use TUserContent;
3941

@@ -215,4 +217,19 @@ public function __toString(): string
215217
{
216218
return $this->getFormattedMessage();
217219
}
220+
221+
#[\Override]
222+
public function loadEmbeddedObjects(): void
223+
{
224+
if ($this->hasEmbeddedObjects) {
225+
ObjectTypeCache::getInstance()
226+
->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'com.woltlab.wcf.conversation.message')
227+
->getProcessor()
228+
->cacheObjects([$this->messageID]);
229+
MessageEmbeddedObjectManager::getInstance()->loadObjects(
230+
'com.woltlab.wcf.conversation.message',
231+
[$this->messageID]
232+
);
233+
}
234+
}
218235
}

files/lib/data/conversation/message/ConversationMessageAction.class.php

Lines changed: 1 addition & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use wcf\data\DatabaseObject;
1010
use wcf\data\IAttachmentMessageQuickReplyAction;
1111
use wcf\data\IMessageInlineEditorAction;
12-
use wcf\data\IMessageQuoteAction;
13-
use wcf\data\object\type\ObjectTypeCache;
1412
use wcf\data\smiley\SmileyCache;
1513
use wcf\event\message\MessageSpamChecking;
1614
use wcf\system\attachment\AttachmentHandler;
@@ -48,8 +46,7 @@
4846
*/
4947
class ConversationMessageAction extends AbstractDatabaseObjectAction implements
5048
IAttachmentMessageQuickReplyAction,
51-
IMessageInlineEditorAction,
52-
IMessageQuoteAction
49+
IMessageInlineEditorAction
5350
{
5451
/**
5552
* @inheritDoc
@@ -595,140 +592,6 @@ public function getRedirectUrl(DatabaseObject $container, DatabaseObject $messag
595592
return $message->getLink();
596593
}
597594

598-
/**
599-
* @inheritDoc
600-
*/
601-
public function validateSaveFullQuote()
602-
{
603-
$this->message = $this->getSingleObject();
604-
605-
if (!Conversation::isParticipant([$this->message->conversationID])) {
606-
throw new PermissionDeniedException();
607-
}
608-
}
609-
610-
private function loadEmbeddedObjects(): void
611-
{
612-
if ($this->message->hasEmbeddedObjects) {
613-
ObjectTypeCache::getInstance()
614-
->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'com.woltlab.wcf.conversation.message')
615-
->getProcessor()
616-
->cacheObjects([$this->message->messageID]);
617-
MessageEmbeddedObjectManager::getInstance()->loadObjects(
618-
'com.woltlab.wcf.conversation.message',
619-
[$this->message->messageID]
620-
);
621-
}
622-
}
623-
624-
/**
625-
* @inheritDoc
626-
*/
627-
public function saveFullQuote()
628-
{
629-
$this->loadEmbeddedObjects();
630-
631-
$quoteID = MessageQuoteManager::getInstance()->addQuote(
632-
'com.woltlab.wcf.conversation.message',
633-
$this->message->conversationID,
634-
$this->message->messageID,
635-
$this->message->getExcerpt(),
636-
$this->message->getMessage()
637-
);
638-
639-
if ($quoteID === false) {
640-
$removeQuoteID = MessageQuoteManager::getInstance()->getQuoteID(
641-
'com.woltlab.wcf.conversation.message',
642-
$this->message->messageID,
643-
$this->message->getExcerpt(),
644-
$this->message->getMessage()
645-
);
646-
MessageQuoteManager::getInstance()->removeQuote($removeQuoteID);
647-
}
648-
649-
$returnValues = [
650-
'count' => MessageQuoteManager::getInstance()->countQuotes(),
651-
'fullQuoteMessageIDs' => MessageQuoteManager::getInstance()->getFullQuoteObjectIDs(
652-
['com.woltlab.wcf.conversation.message']
653-
),
654-
];
655-
656-
if ($quoteID) {
657-
$returnValues['renderedQuote'] = MessageQuoteManager::getInstance()->getQuoteComponents($quoteID);
658-
}
659-
660-
return $returnValues;
661-
}
662-
663-
/**
664-
* @inheritDoc
665-
*/
666-
public function validateSaveQuote()
667-
{
668-
$this->readString('message');
669-
$this->readBoolean('renderQuote', true);
670-
$this->message = $this->getSingleObject();
671-
672-
if (!Conversation::isParticipant([$this->message->conversationID])) {
673-
throw new PermissionDeniedException();
674-
}
675-
}
676-
677-
/**
678-
* @inheritDoc
679-
*/
680-
public function saveQuote()
681-
{
682-
$this->loadEmbeddedObjects();
683-
684-
$quoteID = MessageQuoteManager::getInstance()->addQuote(
685-
'com.woltlab.wcf.conversation.message',
686-
$this->message->conversationID,
687-
$this->message->messageID,
688-
$this->parameters['message'],
689-
false
690-
);
691-
692-
$returnValues = [
693-
'count' => MessageQuoteManager::getInstance()->countQuotes(),
694-
'fullQuoteMessageIDs' => MessageQuoteManager::getInstance()->getFullQuoteObjectIDs(
695-
['com.woltlab.wcf.conversation.message']
696-
),
697-
];
698-
699-
if ($this->parameters['renderQuote']) {
700-
$returnValues['renderedQuote'] = MessageQuoteManager::getInstance()->getQuoteComponents($quoteID);
701-
}
702-
703-
return $returnValues;
704-
}
705-
706-
/**
707-
* @inheritDoc
708-
*/
709-
public function validateGetRenderedQuotes()
710-
{
711-
$this->readInteger('parentObjectID');
712-
713-
$this->conversation = new Conversation($this->parameters['parentObjectID']);
714-
if (!$this->conversation->conversationID) {
715-
throw new UserInputException('parentObjectID');
716-
}
717-
}
718-
719-
/**
720-
* @inheritDoc
721-
*/
722-
public function getRenderedQuotes()
723-
{
724-
$quotes = MessageQuoteManager::getInstance()
725-
->getQuotesByParentObjectID('com.woltlab.wcf.conversation.message', $this->conversation->conversationID);
726-
727-
return [
728-
'template' => \implode("\n\n", $quotes),
729-
];
730-
}
731-
732595
/**
733596
* @inheritDoc
734597
*/

templates/conversation.tpl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,12 @@
166166
var $inlineEditor = new WCF.Conversation.InlineEditor('.conversation');
167167
$inlineEditor.setEditorHandler($editorHandler);
168168
169-
{assign var=__supportPaste value=true}
170-
{if !$conversation->canReply()}{assign var=__supportPaste value=false}{/if}
171-
{include file='shared_messageQuoteManager' wysiwygSelector='text' supportPaste=$__supportPaste}
172-
173-
require(["WoltLabSuite/Core/Conversation/Ui/Message/Quote"], ({ UiConversationMessageQuote }) => {
174-
new UiConversationMessageQuote($quoteManager);
175-
});
176-
177169
{if $conversation->canReply()}
178170
require(['WoltLabSuite/Core/Conversation/Ui/Message/Reply'], function({ Reply }) {
179171
new Reply({
180172
ajax: {
181173
className: 'wcf\\data\\conversation\\message\\ConversationMessageAction'
182174
},
183-
quoteManager: $quoteManager
184175
});
185176
});
186177
{/if}
@@ -189,10 +180,13 @@
189180
require([
190181
'WoltLabSuite/Core/Conversation/Ui/Object/Action/RemoveParticipant',
191182
'WoltLabSuite/Core/Conversation/Ui/Message/InlineEditor',
192-
], (UiObjectActionRemoveParticipant, { UiConversationMessageInlineEditor }) => {
183+
'WoltLabSuite/Core/Component/Quote/Message',
184+
], (UiObjectActionRemoveParticipant, { UiConversationMessageInlineEditor }, { registerContainer }) => {
193185
new UiConversationMessageInlineEditor({$conversation->conversationID});
194186
195187
UiObjectActionRemoveParticipant.setup();
188+
189+
registerContainer(".message", ".messageBody", "wcf\\data\\conversation\\message\\ConversationMessage", "com.woltlab.wcf.conversation.message");
196190
});
197191
</script>
198192

templates/conversationAdd.tpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@
162162
});
163163
{/if}
164164
});
165-
166-
$(function() {
167-
{include file='shared_messageQuoteManager' wysiwygSelector='text' supportPaste=true}
168-
});
169165
</script>
170166

171167
{include file='shared_wysiwyg'}

templates/conversationMessageList.tpl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,14 @@
8383
<li
8484
class="jsQuoteMessage"
8585
data-object-id="{$message->messageID}"
86-
data-is-quoted="{if $__quoteFullQuote|isset && $message->messageID|in_array:$__quoteFullQuote}1{else}0{/if}"
8786
>
88-
<a
89-
href="#"
87+
<button type="button"
9088
title="{lang}wcf.message.quote.quoteMessage{/lang}"
9189
class="button jsTooltip{if $__quoteFullQuote|isset && $message->messageID|in_array:$__quoteFullQuote} active{/if}"
9290
>
9391
{icon name='quote-left' type='solid'}
9492
<span class="invisible">{lang}wcf.message.quote.quoteMessage{/lang}</span>
95-
</a>
93+
</button>
9694
</li>
9795
{if $message->userID != $__wcf->getUser()->userID && $__wcf->session->getPermission('user.profile.canReportContent')}
9896
<li>

ts/WoltLabSuite/Core/Conversation/Ui/Message/Quote.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)