本文整理匯總了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);
}
}