本文整理汇总了PHP中CommentModel::SetWatch方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::SetWatch方法的具体用法?PHP CommentModel::SetWatch怎么用?PHP CommentModel::SetWatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommentModel
的用法示例。
在下文中一共展示了CommentModel::SetWatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
//.........这里部分代码省略.........
$this->setData('_LatestItem', $LatestItem);
// Set the canonical url to have the proper page title.
$this->canonicalUrl(discussionUrl($this->Discussion, pageNumber($this->Offset, $Limit, 0, false)));
// url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::session()->UserID != 0)), true), Gdn::session()->UserID == 0);
// Load the comments
$this->setData('Comments', $this->CommentModel->getByDiscussion($DiscussionID, $Limit, $this->Offset));
$PageNumber = PageNumber($this->Offset, $Limit);
$this->setData('Page', $PageNumber);
$this->_SetOpenGraph();
if ($PageNumber == 1) {
$this->description(sliceParagraph(Gdn_Format::plainText($this->Discussion->Body, $this->Discussion->Format), 160));
// Add images to head for open graph
$Dom = pQuery::parseStr(Gdn_Format::to($this->Discussion->Body, $this->Discussion->Format));
} else {
$this->Data['Title'] .= sprintf(t(' - Page %s'), PageNumber($this->Offset, $Limit));
$FirstComment = $this->data('Comments')->firstRow();
$FirstBody = val('Body', $FirstComment);
$FirstFormat = val('Format', $FirstComment);
$this->description(sliceParagraph(Gdn_Format::plainText($FirstBody, $FirstFormat), 160));
// Add images to head for open graph
$Dom = pQuery::parseStr(Gdn_Format::to($FirstBody, $FirstFormat));
}
if ($Dom) {
foreach ($Dom->query('img') as $img) {
if ($img->attr('src')) {
$this->image($img->attr('src'));
}
}
}
// Queue notification.
if ($this->Request->get('new') && c('Vanilla.QueueNotifications')) {
$this->addDefinition('NotifyNewDiscussion', 1);
}
// Make sure to set the user's discussion watch records if this is not an API request.
if ($this->deliveryType() !== DELIVERY_TYPE_DATA) {
$this->CommentModel->SetWatch($this->Discussion, $Limit, $this->Offset, $this->Discussion->CountComments);
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->EventArguments['PagerType'] = 'Pager';
$this->fireEvent('BeforeBuildPager');
$this->Pager = $PagerFactory->getPager($this->EventArguments['PagerType'], $this);
$this->Pager->ClientID = 'Pager';
$this->Pager->configure($this->Offset, $Limit, $ActualResponses, array('DiscussionUrl'));
$this->Pager->Record = $this->Discussion;
PagerModule::current($this->Pager);
$this->fireEvent('AfterBuildPager');
// Define the form for the comment input
$this->Form = Gdn::Factory('Form', 'Comment');
$this->Form->Action = url('/post/comment/');
$this->DiscussionID = $this->Discussion->DiscussionID;
$this->Form->addHidden('DiscussionID', $this->DiscussionID);
$this->Form->addHidden('CommentID', '');
// Look in the session stash for a comment
$StashComment = $Session->getPublicStash('CommentForDiscussionID_' . $this->Discussion->DiscussionID);
if ($StashComment) {
$this->Form->setValue('Body', $StashComment);
$this->Form->setFormValue('Body', $StashComment);
}
// Retrieve & apply the draft if there is one:
if (Gdn::session()->UserID) {
$DraftModel = new DraftModel();
$Draft = $DraftModel->getByUser($Session->UserID, 0, 1, $this->Discussion->DiscussionID)->firstRow();
$this->Form->addHidden('DraftID', $Draft ? $Draft->DraftID : '');
if ($Draft && !$this->Form->isPostBack()) {
$this->Form->setValue('Body', $Draft->Body);
$this->Form->setValue('Format', $Draft->Format);
}
}
// Deliver JSON data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->setJson('LessRow', $this->Pager->toString('less'));
$this->setJson('MoreRow', $this->Pager->toString('more'));
$this->View = 'comments';
}
// Inform moderator of checked comments in this discussion
$CheckedComments = $Session->getAttribute('CheckedComments', array());
if (count($CheckedComments) > 0) {
ModerationController::informCheckedComments($this);
}
// Add modules
$this->addModule('DiscussionFilterModule');
$this->addModule('NewDiscussionModule');
$this->addModule('CategoriesModule');
$this->addModule('BookmarkedModule');
$this->CanEditComments = Gdn::session()->checkPermission('Vanilla.Comments.Edit', true, 'Category', 'any') && c('Vanilla.AdminCheckboxes.Use');
// Report the discussion id so js can use it.
$this->addDefinition('DiscussionID', $DiscussionID);
$this->addDefinition('Category', $this->data('Category.Name'));
$this->fireEvent('BeforeDiscussionRender');
$AttachmentModel = AttachmentModel::instance();
if (AttachmentModel::enabled()) {
$AttachmentModel->joinAttachments($this->Data['Discussion'], $this->Data['Comments']);
$this->fireEvent('FetchAttachmentViews');
if ($this->deliveryMethod() === DELIVERY_METHOD_XHTML) {
require_once $this->fetchViewLocation('attachment', 'attachments', 'dashboard');
}
}
$this->render();
}