本文整理汇总了PHP中CommentModel::GetByUser方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::GetByUser方法的具体用法?PHP CommentModel::GetByUser怎么用?PHP CommentModel::GetByUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommentModel
的用法示例。
在下文中一共展示了CommentModel::GetByUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ProfileController_Comments_Create
/**
* Creates virtual 'Comments' method in ProfileController.
*
* @since 2.0.0
* @package Vanilla
*
* @param object $Sender ProfileController.
*/
public function ProfileController_Comments_Create(&$Sender)
{
$View = $Sender->View;
$UserReference = ArrayValue(0, $Sender->RequestArgs, '');
$Username = ArrayValue(1, $Sender->RequestArgs, '');
$Offset = ArrayValue(2, $Sender->RequestArgs, 0);
// Tell the ProfileController what tab to load
$Sender->GetUserInfo($UserReference, $Username);
$Sender->SetTabView('Comments', 'profile', 'Discussion', 'Vanilla');
// Load the data for the requested tab.
if (!is_numeric($Offset) || $Offset < 0) {
$Offset = 0;
}
$Limit = Gdn::Config('Vanilla.Discussions.PerPage', 30);
$CommentModel = new CommentModel();
$Sender->CommentData = $CommentModel->GetByUser($Sender->User->UserID, $Limit, $Offset);
$CountComments = $Offset + $Sender->CommentData->NumRows();
if ($Sender->CommentData->NumRows() == $Limit) {
$CountComments = $Offset + $Limit + 1;
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender);
$Sender->Pager->MoreCode = 'More Comments';
$Sender->Pager->LessCode = 'Newer Comments';
$Sender->Pager->ClientID = 'Pager';
$Sender->Pager->Configure($Offset, $Limit, $CountComments, 'profile/comments/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name) . '/%1$s/');
// Deliver JSON data if necessary
if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) {
$Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
$Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
$Sender->View = 'profilecomments';
}
$Sender->Offset = $Offset;
// Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views
$Sender->HandlerType = HANDLER_TYPE_NORMAL;
// Do not show discussion options
$Sender->ShowOptions = FALSE;
// Render the ProfileController
$Sender->Render();
}