function render()
 {
     $this->title = 'Ratings';
     // vars used everywhere
     $this->subject_type = $this->params['subject_type'];
     // view-specific stuff
     switch ($this->view) {
         case 'item':
             $this->subject_id = $this->params['subject_id'];
             $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?";
             }
             $this->ratings = $this->get_ratings($this->subject_type, $this->subject_id);
             $genres = split(",", $this->item->genres);
             $this->subject_genre = trim($genres[0]);
             $this->oneliners = Oneliners::get($this->subject_genre, PA::$language);
         case 'top':
             $this->items = Item::get_top_rated($this->subject_type, 5);
             foreach ($this->items as $item) {
                 $item->stars = $this->stars(round($item->average_rating, 1));
             }
             break;
         case 'recent_by_user':
             if (empty($this->uid)) {
                 return "user_id is required";
             }
             $this->ratings = $this->get_recent_by_user($this->uid, 5);
             break;
         default:
             return "Unknown RatingModule view {$this->view}";
     }
     $this->inner_HTML = $this->generate_inner_html();
     return parent::render();
 }
Example #2
0
function peopleaggregator_getItemsByRating($args)
{
    require_once PA::$path . "/api/Item/Item.php";
    $items_out = array();
    foreach (Item::get_top_rated($args['type'], $args['resultsPerPage'], $args['page'], $args['minRatings']) as $item) {
        $items_out[] = item_to_array($item);
    }
    return array("success" => TRUE, "msg" => "Retrieved " . count($items_out) . " item(s)", "items" => $items_out);
}