function render()
 {
     $login_uid = @PA::$login_user->user_id;
     $this->subject_type = @$this->params['subject_type'];
     $this->subject_id = @$this->params['subject_id'];
     switch ($this->view) {
         case 'item':
             // get tags
             $this->tags = ItemTags::get_tags_for_item($this->subject_type, $this->subject_id);
             $this->classed_tags = $this->tagCloud();
             break;
         case "tagsearch":
             $this->inner_template = 'tagsearch.php';
             $this->tag = $this->params['search'];
             // fetch results
             $this->result_items = ItemTags::get_items_with_tag($this->tag);
             break;
         case "tagsearch_recent":
             $this->inner_template = 'tagsearch_recent.php';
             $this->tag = $this->params['search'];
             // fetch results
             $this->result_items = ItemTags::get_recent_with_tag($this->tag);
             break;
         case "user":
             $this->inner_template = 'user.tpl';
             // fetch results
             $this->tags = ItemTags::get_tags_for_user($this->uid);
             $this->classed_tags = $this->tagCloud();
             break;
     }
     $tmp_file = dirname(__FILE__) . "/" . $this->skin . "_" . $this->inner_template;
     $inner_html_gen =& new Template($tmp_file, $this);
     $this->inner_HTML = $inner_html_gen->fetch();
     $content = parent::render();
     return $content;
 }
 function render_for_ajax()
 {
     $op = $this->params["op"];
     // if (empty(PA::$login_user) && $op != "paging") return __("Login required");
     switch ($op) {
         case "flagthis":
             if (empty(PA::$login_user)) {
                 $this->err = __("Please log in or register to flag a review!");
                 break;
             }
             // file the abuse report
             try {
                 list($foo, $review_id) = split(':', $this->params['flag']);
                 $abuse_obj = new ReportAbuse();
                 $abuse_obj->parent_type = 'review';
                 $abuse_obj->parent_id = $review_id;
                 $abuse_obj->reporter_id = PA::$login_uid;
                 // TODO: possibly make this user input
                 $abuse_obj->body = "This review was flagged.";
                 $id = $abuse_obj->save();
                 $this->note = "Your abuse report was filed.";
             } catch (PAException $e) {
                 $this->err = __("There was a problem flagging this review: ") . $e->message;
             }
             break;
         case "add_review":
             do {
                 if (empty(PA::$login_user)) {
                     $this->err = __("Please log in or register to add a review!");
                     break;
                 }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = __("Please enter a review!");
                     break;
                 }
                 // validation done - now save the review
                 $rev = new Review();
                 $rev->author_id = PA::$login_user->user_id;
                 $rev->subject_type = $this->params["subject_type"];
                 $rev->subject_id = $this->params["subject_id"];
                 $rev->title = "";
                 // $title;
                 $rev->body = $body;
                 if (!$rev->save()) {
                     $this->err = __("Save failed.");
                     break;
                 }
                 $this->note = __("Review added - thank you for participating!");
                 // handle tags
                 $tags = trim($this->params["tags"]);
                 if (!empty($tags)) {
                     $tags_array = preg_split('/\\s*,\\s*/', $tags);
                     ItemTags::save_tags_for_item(PA::$login_user->user_id, $this->params["subject_type"], $this->params["subject_id"], $tags_array);
                 }
                 // for rivers of people
                 $activity = 'user_post_a_review';
                 $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a review.', 'subject_type' => $rev->subject_type, 'subject_id' => $rev->subject_id));
                 Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity));
             } while (0);
             break;
         default:
             // just ignore unknown ops
             break;
     }
     return $this->render();
 }