本文整理汇总了PHP中Review::get_recent_by_subject_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::get_recent_by_subject_type方法的具体用法?PHP Review::get_recent_by_subject_type怎么用?PHP Review::get_recent_by_subject_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::get_recent_by_subject_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
function render()
{
if (empty(PA::$login_user)) {
return __("Login required");
}
$this->title = 'Reviews';
$this->subject_type = $this->params['subject_type'];
$this->subject_id = $this->params['subject_id'];
switch ($this->view) {
case 'default':
if (empty($this->subject_type) || empty($this->subject_id)) {
return "subject_type and subject_id are required";
}
$this->reviews = Review::get_recent_by_subject($this->subject_type, $this->subject_id, 10);
break;
case 'recent_short':
if (empty($this->subject_type)) {
return "subject_type is required";
}
$this->reviews = Review::get_recent_by_subject_type($this->subject_type, 10);
break;
}
// find unique author user_id values
$user_ids = array();
foreach ($this->reviews as $rev) {
$user_ids[$rev->author_id] = 1;
}
if (!empty($user_ids)) {
// load all users
$u = new User();
$users = $u->load_users(array_keys($user_ids));
// map ids to user info
$user_map = array();
foreach ($users as $u) {
$user_map[$u['user_id']] = $u;
}
// and finally put them all in the review objects
foreach ($this->reviews as $rev) {
$rev->author = $user_map[$rev->author_id];
}
}
$this->inner_HTML = $this->generate_inner_html();
$content = parent::render();
return $content;
}
示例2: render
function render()
{
$this->title = __('Reviews');
$this->subject_type = @$this->params['subject_type'];
$this->subject_id = @$this->params['subject_id'];
$this->page = (int) @$this->params['page'] ? (int) $this->params['page'] : 1;
switch ($this->view) {
case 'item':
// reviews on an item
if (empty($this->subject_type) || empty($this->subject_id)) {
return "subject_type and subject_id are required";
}
$this->item = Item::find_by_subject($this->subject_type, $this->subject_id);
if (empty($this->item)) {
return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?";
}
list($this->reviews, $this->n_reviews, $this->n_pages, $this->page, $this->per_page) = Review::get_recent_by_subject($this->subject_type, $this->subject_id, 5, $this->page);
// get tags
$this->tags = ItemTags::get_tags_for_item($this->subject_type, $this->subject_id);
break;
case 'recent_single':
// most recent review of an item (a chosen new release)
if (empty($this->subject_type) || empty($this->subject_id)) {
return "subject_type and subject_id are required";
}
$this->item = Item::find_by_subject($this->subject_type, $this->subject_id);
if (empty($this->item)) {
return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?";
}
list($this->reviews, , , , ) = Review::get_recent_by_subject($this->subject_type, $this->subject_id, 1, 1);
break;
case 'recent':
// recent reviews
if (empty($this->subject_type)) {
return "subject_type is required";
}
$this->reviews = Review::get_recent_by_subject_type($this->subject_type, 3);
foreach ($this->reviews as &$review) {
$review->item = Item::find_by_subject($review->subject_type, $review->subject_id);
if (empty($review->item)) {
return "Item {$this->subject_type}:{$this->subject_id} not found. Is the frontend server sending it correctly?";
}
}
break;
case 'top':
// top reviewers
$this->reviewers = User::get_top_reviewers(8);
foreach ($this->reviewers as &$u) {
foreach ($u->get_profile_fields("videoplay", array("display_login_name", "url", "thumbnail_url")) as $k => $v) {
$u->{$k} = $v;
}
}
break;
case 'recent_by_user':
if (empty($this->uid)) {
return "user_id parameter is required";
}
// recent reviews from a user
list($this->reviews, $this->n_reviews, $this->n_pages, $this->page, $this->per_page) = Review::get_recent_by_user($this->uid, 5, $this->page);
break;
default:
return "Unknown ReviewModule view: {$this->view}";
}
// find unique author user_id values
$user_ids = array();
foreach ($this->reviews as $rev) {
$user_ids[$rev->author_id] = 1;
}
if (!empty($user_ids)) {
// load all users
$us = new User();
$users = $us->load_users(array_keys($user_ids));
// add in videoplay-specific profile data
foreach ($users as &$u) {
$us->user_id = $u['user_id'];
foreach ($us->get_profile_fields("videoplay", array("display_login_name", "url", "thumbnail_url")) as $k => $v) {
$u[$k] = $v;
}
}
unset($u);
// map ids to user info
$user_map = array();
foreach ($users as $u) {
$user_map[$u['user_id']] = $u;
}
// and finally put them all in the review objects
foreach ($this->reviews as $rev) {
$rev->author = $user_map[$rev->author_id];
}
}
$tpl =& new Template(dirname(__FILE__) . "/" . $this->skin . "_" . $this->view . ".tpl", $this);
$this->inner_HTML = $tpl->fetch();
if (preg_match($this->skin, "/_inner\$/")) {
$content = parent::render();
} else {
$content = $this->inner_HTML;
}
return $content;
}