本文整理汇总了PHP中DiscussionModel::addView方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::addView方法的具体用法?PHP DiscussionModel::addView怎么用?PHP DiscussionModel::addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::addView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gdn_statistics_tick_handler
/**
* Discussion view counter.
*
* @param $Sender
* @param $Args
*/
public function gdn_statistics_tick_handler($Sender, $Args)
{
$Path = Gdn::request()->post('Path');
$Args = Gdn::request()->post('Args');
parse_str($Args, $Args);
$ResolvedPath = trim(Gdn::request()->post('ResolvedPath'), '/');
$ResolvedArgs = Gdn::request()->post('ResolvedArgs');
$DiscussionID = null;
$DiscussionModel = new DiscussionModel();
// Comment permalink
if ($ResolvedPath == 'vanilla/discussion/comment') {
$CommentID = val('CommentID', $ResolvedArgs);
$CommentModel = new CommentModel();
$Comment = $CommentModel->getID($CommentID);
$DiscussionID = val('DiscussionID', $Comment);
} elseif ($ResolvedPath == 'vanilla/discussion/index') {
$DiscussionID = val('DiscussionID', $ResolvedArgs, null);
} elseif ($ResolvedPath == 'vanilla/discussion/embed') {
$ForeignID = val('vanilla_identifier', $Args);
if ($ForeignID) {
// This will be hit a lot so let's try caching it...
$Key = "DiscussionID.ForeignID.page.{$ForeignID}";
$DiscussionID = Gdn::cache()->get($Key);
if (!$DiscussionID) {
$Discussion = $DiscussionModel->getForeignID($ForeignID, 'page');
$DiscussionID = val('DiscussionID', $Discussion);
Gdn::cache()->store($Key, $DiscussionID, array(Gdn_Cache::FEATURE_EXPIRY, 1800));
}
}
}
if ($DiscussionID) {
$DiscussionModel->addView($DiscussionID);
}
}