Merge branch '5.5'
[GitHub/WoltLab/com.woltlab.wcf.conversation.git] / files / lib / data / conversation / message / SearchResultConversationMessage.class.php
1 <?php
2
3 namespace wcf\data\conversation\message;
4
5 use wcf\data\conversation\Conversation;
6 use wcf\data\search\ISearchResultObject;
7 use wcf\system\request\LinkHandler;
8 use wcf\system\search\SearchResultTextParser;
9
10 /**
11 * Represents a list of search result.
12 *
13 * @author Marcel Werk
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 *
17 * @property-read string|null $subject
18 */
19 class SearchResultConversationMessage extends ViewableConversationMessage implements ISearchResultObject
20 {
21 /**
22 * conversation object
23 * @var Conversation
24 */
25 public $conversation;
26
27 /**
28 * Returns the conversation object.
29 *
30 * @return Conversation
31 */
32 public function getConversation()
33 {
34 if ($this->conversation === null) {
35 $this->conversation = new Conversation(null, [
36 'conversationID' => $this->conversationID,
37 'subject' => $this->subject,
38 ]);
39 }
40
41 return $this->conversation;
42 }
43
44 /**
45 * @inheritDoc
46 */
47 public function getFormattedMessage()
48 {
49 return SearchResultTextParser::getInstance()->parse(
50 $this->getDecoratedObject()->getSimplifiedFormattedMessage()
51 );
52 }
53
54 /**
55 * @inheritDoc
56 */
57 public function getSubject()
58 {
59 return $this->subject;
60 }
61
62 /**
63 * @inheritDoc
64 */
65 public function getLink($query = '')
66 {
67 if ($query) {
68 return LinkHandler::getInstance()->getLink('Conversation', [
69 'object' => $this->getConversation(),
70 'messageID' => $this->messageID,
71 'highlight' => \urlencode($query),
72 ], '#message' . $this->messageID);
73 }
74
75 return $this->getDecoratedObject()->getLink();
76 }
77
78 /**
79 * @inheritDoc
80 */
81 public function getTime()
82 {
83 return $this->time;
84 }
85
86 /**
87 * @inheritDoc
88 */
89 public function getObjectTypeName()
90 {
91 return 'com.woltlab.wcf.conversation.message';
92 }
93
94 /**
95 * @inheritDoc
96 */
97 public function getContainerTitle()
98 {
99 return '';
100 }
101
102 /**
103 * @inheritDoc
104 */
105 public function getContainerLink()
106 {
107 return '';
108 }
109 }