use wcf\system\application\ApplicationHandler;
use wcf\system\html\node\AbstractHtmlNode;
use wcf\system\html\node\HtmlNodeProcessor;
+use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\request\RouteHandler;
use wcf\system\WCF;
use wcf\util\StringUtil;
foreach ($elements as $element) {
$nodeIdentifier = StringUtil::getRandomID();
$htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [
- 'title' => ($element->hasAttribute('data-quote-title')) ? $element->getAttribute('data-quote-title') : '',
- 'url' => ($element->hasAttribute('data-quote-url')) ? $element->getAttribute('data-quote-url') : ''
+ 'author' => ($element->hasAttribute('data-author')) ? $element->getAttribute('data-author') : '',
+ 'url' => ($element->hasAttribute('data-url')) ? $element->getAttribute('data-url') : ''
]);
$htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier);
}
$quoteAuthorObject = null;
- /*
- * TODO: how should the author object be resolved?
- *
- if ($quoteAuthor && !$externalQuoteLink) {
- $quoteAuthorLC = mb_strtolower(StringUtil::decodeHTML($quoteAuthor));
+ if ($data['author'] && !$externalQuoteLink) {
+ $quoteAuthorLC = mb_strtolower(StringUtil::decodeHTML($data['author']));
foreach (MessageEmbeddedObjectManager::getInstance()->getObjects('com.woltlab.wcf.quote') as $user) {
if (mb_strtolower($user->username) == $quoteAuthorLC) {
$quoteAuthorObject = $user;
}
}
}
- */
WCF::getTPL()->assign([
'quoteLink' => $data['url'],
- 'quoteAuthor' => $data['title'],
+ 'quoteAuthor' => $data['author'],
'quoteAuthorObject' => $quoteAuthorObject,
'isExternalQuoteLink' => $externalQuoteLink
]);
namespace wcf\system\message\embedded\object;
use wcf\data\user\UserList;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\html\input\HtmlInputProcessor;
+use wcf\util\StringUtil;
/**
* IMessageEmbeddedObjectHandler implementation for quotes.
/**
* @inheritDoc
*/
- public function parseMessage($message) {
- $usernames = self::getFirstParameters($message, 'quote');
+ public function parse(HtmlInputProcessor $htmlInputProcessor, array $embeddedData) {
+ $usernames = [];
+
+ /** @var \DOMElement $element */
+ foreach ($htmlInputProcessor->getHtmlInputNodeProcessor()->getDocument()->getElementsByTagName('blockquote') as $element) {
+ $username = StringUtil::trim($element->getAttribute('data-author'));
+ if (!empty($username) && !in_array($username, $usernames)) {
+ $usernames[] = $username;
+ }
+ }
+
if (!empty($usernames)) {
$userList = new UserList();
$userList->getConditionBuilder()->add("user_table.username IN (?)", [$usernames]);
return $userList->getObjectIDs();
}
- return false;
+ return [];
}
/**