当前位置: 首页>>代码示例>>PHP>>正文


PHP Review::get_recent_by_subject方法代码示例

本文整理汇总了PHP中Review::get_recent_by_subject方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::get_recent_by_subject方法的具体用法?PHP Review::get_recent_by_subject怎么用?PHP Review::get_recent_by_subject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Review的用法示例。


在下文中一共展示了Review::get_recent_by_subject方法的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;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:45,代码来源:ReviewModule.php

示例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;
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:99,代码来源:ReviewModule.php


注:本文中的Review::get_recent_by_subject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。