本文整理汇总了PHP中Summit::VoteablePresentations方法的典型用法代码示例。如果您正苦于以下问题:PHP Summit::VoteablePresentations方法的具体用法?PHP Summit::VoteablePresentations怎么用?PHP Summit::VoteablePresentations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Summit
的用法示例。
在下文中一共展示了Summit::VoteablePresentations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handlePresentations
/**
* @param SS_HTTPRequest $r
* @return SS_HTTPRequest
*/
public function handlePresentations(SS_HTTPRequest $r)
{
$presentations = [];
$offset = $r->getVar('offset') ?: 0;
$m = Member::currentUser();
$list = $m ? $m->getRandomisedPresentations(null, $this->summit) : $this->summit->VoteablePresentations();
if ($list) {
if ($r->getVar('category')) {
$list = $list->filter(['CategoryID' => $r->getVar('category')]);
}
if ($r->getVar('search')) {
$list = Presentation::apply_search_query($list, $r->getVar('search'));
}
$total = $list->count();
$list = $list->limit($this->limit, $offset);
} else {
$list = [];
$total = 0;
}
foreach ($list as $p) {
$vote = $p->getUserVote();
$presentations[] = ['id' => $p->ID, 'title' => $p->Title, 'user_vote' => $vote ? $vote->Vote : null];
}
$result = ['presentations' => $presentations, 'total' => $total];
return (new SS_HTTPResponse(Convert::array2json($result), 200))->addHeader('Content-Type', 'application/json');
}