public function get() { $id = JRequest::getInt('id', 0); if (!$id) { $this->plugin->setResponse(null); return; } $related = array(); $cat = JRequest::getVar('catid', ''); if (is_numeric($cat)) { $related = RelateAPIHelper::getRelated($id, $cat); } else { if ($cat == 'photos') { $related = RelateAPIHelper::getPhotos($id); } else { if ($cat == 'videos') { $related = RelateAPIHelper::getVideos($id); } else { $related = RelateAPIHelper::getRelated($id); } } } $this->plugin->setResponse($related); }
public function get() { $id = JRequest::getInt('id', 0); if (!$id) { $this->plugin->setResponse(null); return; } $listing = $this->getListing($id); if (!$listing) { $this->plugin->setResponse(null); return; } unset($listing->email); JLoader::register('RelateAPIHelper', JPATH_SITE . '/plugins/api/relate/helper.php'); if ($listing->catid == 14) { // category 14 - catch reports //$listing->related_fish = $this->getRelatedItem($listing, array(17)); // related fish (category 17) $listing->related_fish = RelateAPIHelper::getRelated($listing->id, array(17)); $listing->fish_count = count($listing->related_fish); $spots = RelateAPIHelper::getRelated($listing->id, array(3, 4)); $listing->spot_id = $spots[0]; $parent = RelateAPIHelper::getRelated($listing->spot_id, array(1, 2, 100)); $listing->parent_spot = $parent[0]; //$listing->related_trips = RelateAPIHelper::getRelated($listing->id, array(14)); $listing->bait = $this->getRelatedItem($listing, array(101, 102)); // bait categories } if ($listing->sectionid == 1) { $listing->related_fish = RelateAPIHelper::getRelated($listing->id, array(17)); $listing->fish_count = count($listing->related_fish); if ($listing->catid == 3 || $listing->catid == 4) { $parent = RelateAPIHelper::getRelated($listing->id, array(1, 2, 100)); $listing->parent_spot = $parent[0]; } else { $listing->related_spots = RelateAPIHelper::getRelated($listing->id, array(3, 4)); } $listing->related_catches = RelateAPIHelper::getRelated($listing->id, array(14)); $listing->catch_count = count($listing->related_catches); $listing->related_techniques = RelateAPIHelper::getRelated($listing->id, array(24, 48.79)); $listing->technique_count = count($listing->related_catches); } $listing->photos = RelateAPIHelper::getPhotos($listing->id); $listing->videos = RelateAPIHelper::getVideos($listing->id); $listing->average_rating = $this->getAverageRating($listing->id); $listing->comment_count = $this->getCommentCount($listing->id); $this->plugin->setResponse($listing); }
public function addRelations(&$listing) { if ($listing->catid == 14) { // category 14 - catch reports $listing->related_fish = RelateAPIHelper::getRelated($listing->id, array(17)); $listing->fish_count = count($listing->related_fish); $spots = RelateAPIHelper::getRelated($listing->id, array(3, 4, 1, 2, 100)); $listing->spot_id = $spots[0]; if ($listing->spot_id) { $parent = RelateAPIHelper::getRelated($listing->spot_id, array(1, 2, 100)); $listing->parent_spot = $parent[0]; } else { $listing->parent_spot = 0; } //$listing->related_trips = RelateAPIHelper::getRelated($listing->id, array(14)); $listing->bait = RelateAPIHelper::getRelated($listing->id, array(101, 102)); // bait categories } if ($listing->sectionid == 1) { $listing->related_fish = RelateAPIHelper::getRelated($listing->id, array(17)); $listing->fish_count = count($listing->related_fish); if ($listing->catid == 3 || $listing->catid == 4) { $parent = RelateAPIHelper::getRelated($listing->id, array(1, 2, 100)); $listing->parent_spot = $parent[0]; } else { $listing->related_spots = RelateAPIHelper::getRelated($listing->id, array(3, 4)); } $listing->related_catches = RelateAPIHelper::getRelated($listing->id, array(14)); $listing->catch_count = count($listing->related_catches); $listing->related_techniques = RelateAPIHelper::getRelated($listing->id, array(24, 48.79)); $listing->technique_count = count($listing->related_catches); $db = JFactory::getDBO(); $query = "SELECT DISTINCT(c.created_by) FROM #__content c WHERE c.catid = 14 AND c.id IN (\n\t\t\t\t\t\tSELECT r.id2 FROM #__relate_listings r WHERE r.id1 = '{$listing->id}'\n\t\t\t\t\t)"; $db->setQuery($query); $listing->related_users = $db->loadResultArray(); } $listing->photos = RelateAPIHelper::getPhotos($listing->id); $listing->videos = RelateAPIHelper::getVideos($listing->id); $listing->average_rating = $this->getAverageRating($listing->id); $listing->comment_count = $this->getCommentCount($listing->id); // check anonymous *ja*, cut out spot_id, zip, state, lat, long if ($listing->ja_catchanonymous == '*ja*' && $listing->created_by != $this->get('user')->id) { $listing->spot_id = null; $listing->parent_spot = null; $listing->jr_state = null; $listing->jr_city = null; $listing->jr_zip = null; $listing->jr_lat = null; $listing->jr_long = null; } }