function render() { // view-specific stuff switch ($this->view) { case 'item': $this->subject_type = $this->params['subject_type']; $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?"; } // actually get the fans here list($this->fans, $this->n_fans, $this->n_pages, $this->page, $this->per_page) = Fan::get_recent_by_subject($this->subject_type, $this->subject_id, $this->per_page, $this->page); // see if current user isFan $this->isFan = FALSE; foreach ($this->fans as $i => $fan) { if ($fan->user_id == PA::$login_user->user_id) { $this->isFan = TRUE; break; } } break; case 'recent_by_user': if (empty($this->uid)) { return "user_id is required"; } list($this->fanof, $this->n_items, $this->n_pages, $this->page, $this->per_page) = Fan::get_recent_by_user($this->uid, $this->per_page, $this->page); break; case 'top': // $this->items = Item::get_most_fans($this->subject_type, 5); break; default: return "Unknown FansWidgetModule view {$this->view}"; break; } $tpl =& new Template(dirname(__FILE__) . "/" . $this->skin . "_" . $this->view . ".tpl", $this); $this->inner_HTML = $tpl->fetch(); return parent::render(); }