Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 public static function create($author_id, $genre, $rating, $body, $is_active = FALSE, $language = 'english')
 {
     $genre = Oneliners::map_genre($genre);
     Dal::query("INSERT INTO {oneliners} (author_id, genre, rating, body, is_active, language, created)  VALUES (?, ?, ?, ?, ?, ?, NOW()�)", array($author_id, $genre, $rating, $body, $is_active, $language));
 }