* @property-read integer $responses number of responses on the comment
* @property-read string $responseIDs serialized array with the ids of the five latest comment responses
* @property-read integer $enableHtml is 1 if HTML will rendered in the comment, otherwise 0
- * @property-read integer $hasEmbeddedObjects number of embedded objects in the comment
*/
class Comment extends DatabaseObject implements IMessage {
use TUserContent;
use wcf\system\exception\UserInputException;
use wcf\system\html\input\HtmlInputProcessor;
use wcf\system\like\LikeHandler;
-use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\user\notification\object\type\ICommentUserNotificationObjectType;
use wcf\system\user\notification\object\type\IMultiRecipientCommentUserNotificationObjectType;
'enableHtml' => 1
]);
- // save embedded objects
- $htmlInputProcessor->setObjectID($this->createdComment->commentID);
- if (MessageEmbeddedObjectManager::getInstance()->registerObjects($htmlInputProcessor)) {
- (new CommentEditor($this->createdComment))->update(['hasEmbeddedObjects' => 1]);
- $this->createdComment = new Comment($this->createdComment->commentID);
- }
-
// update counter
$this->commentProcessor->updateCounter($this->parameters['data']['objectID'], 1);
]);
$action->executeAction();
- if ($this->comment->hasEmbeddedObjects != MessageEmbeddedObjectManager::getInstance()->registerObjects($htmlInputProcessor)) {
- /** @noinspection PhpUndefinedMethodInspection */
- $this->comment->update([
- 'hasEmbeddedObjects' => $this->comment->hasEmbeddedObjects ? 0 : 1
- ]);
- }
-
- // load embedded objects
- MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.comment', [$this->comment->commentID]);
-
return [
'actionName' => 'save',
'message' => (new Comment($this->comment->commentID))->getFormattedMessage()
* @return string
*/
protected function renderComment(Comment $comment) {
- if ($comment->hasEmbeddedObjects) {
- MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.comment', [$comment->commentID]);
- }
-
$comment = new StructuredComment($comment);
$comment->setIsDeletable($this->commentProcessor->canDeleteComment($comment->getDecoratedObject()));
$comment->setIsEditable($this->commentProcessor->canEditComment($comment->getDecoratedObject()));
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\comment\manager\ICommentManager;
use wcf\system\like\LikeHandler;
-use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
/**
* Provides a structured comment list fetching last responses for every comment.
*/
public $responseLoading = true;
- /**
- * enables/disables the loading of embedded objects
- * @var boolean
- */
- protected $embeddedObjectLoading = true;
-
- /**
- * ids of the comments with embedded objects
- * @var integer[]
- */
- protected $embeddedObjectCommentIDs = [];
-
/**
* Creates a new structured comment list.
*
}
}
- if ($this->embeddedObjectLoading && $comment->hasEmbeddedObjects) {
- $this->embeddedObjectCommentIDs[] = $comment->commentID;
- }
-
if ($comment->userID) {
$userIDs[] = $comment->userID;
}
if (!empty($userIDs)) {
UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
}
-
- if ($this->embeddedObjectLoading) {
- $this->readEmbeddedObjects();
- }
}
/**
public function getCommentManager() {
return $this->commentManager;
}
-
- /**
- * Reads the embedded objects of the posts in the list.
- */
- public function readEmbeddedObjects() {
- if (!empty($this->embeddedObjectCommentIDs)) {
- // load embedded objects
- MessageEmbeddedObjectManager::getInstance()->loadObjects('com.woltlab.wcf.comment', $this->embeddedObjectCommentIDs);
- }
- }
}
responses MEDIUMINT(7) NOT NULL DEFAULT '0',
responseIDs VARCHAR(255) NOT NULL DEFAULT '',
enableHtml TINYINT(1) NOT NULL DEFAULT 0,
- hasEmbeddedObjects TINYINT(1) NOT NULL DEFAULT 0,
KEY (objectTypeID, objectID, time),
KEY lastCommentTime (userID, time)