f1faf44ea33842a0a6439efb8beae2500c18d2f9
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\message\embedded\object;
3 use wcf\data\user\UserList;
4 use wcf\system\cache\runtime\UserProfileRuntimeCache;
5 use wcf\system\html\input\HtmlInputProcessor;
6 use wcf\util\StringUtil;
7
8 /**
9 * IMessageEmbeddedObjectHandler implementation for quotes.
10 *
11 * @author Marcel Werk
12 * @copyright 2001-2016 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\Message\Embedded\Object
15 */
16 class QuoteMessageEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandler {
17 /**
18 * @inheritDoc
19 */
20 public function parse(HtmlInputProcessor $htmlInputProcessor, array $embeddedData) {
21 $usernames = [];
22
23 /** @var \DOMElement $element */
24 foreach ($htmlInputProcessor->getHtmlInputNodeProcessor()->getDocument()->getElementsByTagName('woltlab-quote') as $element) {
25 $username = StringUtil::trim($element->getAttribute('data-author'));
26 if (!empty($username) && !in_array($username, $usernames)) {
27 $usernames[] = $username;
28 }
29 }
30
31 if (!empty($usernames)) {
32 $userList = new UserList();
33 $userList->getConditionBuilder()->add("user_table.username IN (?)", [$usernames]);
34 $userList->readObjectIDs();
35 return $userList->getObjectIDs();
36 }
37
38 return [];
39 }
40
41 /**
42 * @inheritDoc
43 */
44 public function loadObjects(array $objectIDs) {
45 return UserProfileRuntimeCache::getInstance()->getObjects($objectIDs);
46 }
47 }