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