public function addToDatabase($para) { try { if ($this->validateAddNew($para)) { BO::autoloadBO("attraction"); $attractionBO = new AttractionBO(); if (isset($para->name)) { $attractionBO->name = $para->name; } if (isset($para->slug)) { $attractionBO->slug = $para->slug; } if (isset($para->description)) { $attractionBO->description = $para->description; } if (isset($para->country) && $para->country != "0") { $attractionBO->country = $para->country; } if (isset($para->parent) && $para->parent != "0") { $attractionBO->parent = $para->parent; } if (isset($para->city) && $para->city != "0") { $attractionBO->city = $para->city; } if (isset($para->destination) && $para->destination != "0") { $attractionBO->destination = $para->destination; } if (isset($para->post_content_1)) { $attractionBO->post_content_1 = $para->post_content_1; } if (isset($para->post_content_2)) { $attractionBO->post_content_2 = $para->post_content_2; } if (isset($para->current_rating)) { $attractionBO->current_rating = $para->current_rating; } if (isset($para->vote_times)) { $attractionBO->vote_times = $para->vote_times; } if (isset($para->tag_list)) { $attractionBO->tag_list = $para->tag_list; } if (isset($para->tag_array)) { $attractionBO->tag_array = $para->tag_array; } if (isset($para->images)) { $attractionBO->images = $para->images; } $attractionBO->count = 0; $attractionBO->term_group = 0; $this->db->beginTransaction(); $attractionBO->term_taxonomy_id = parent::addToDatabase($attractionBO); if ($attractionBO->term_taxonomy_id != NULL) { if (isset($attractionBO->post_content_1) || isset($attractionBO->post_content_2)) { $this->addContent($attractionBO); } $this->db->commit(); $attractionBOAdded = parent::get($attractionBO->term_taxonomy_id); if (isset($attractionBO->country) && $attractionBO->country != "") { $this->addMetaInfoToDatabase($attractionBOAdded->term_id, "country", $attractionBO->country); } if (isset($attractionBO->city) && $attractionBO->city != "") { $this->addMetaInfoToDatabase($attractionBOAdded->term_id, "city", $attractionBO->city); } if (isset($attractionBO->destination) && $attractionBO->destination != "") { $this->addMetaInfoToDatabase($attractionBOAdded->term_id, "destination", $attractionBO->destination); } if (isset($attractionBO->current_rating) && $attractionBO->current_rating != "") { $this->addMetaInfoToDatabase($attractionBOAdded->term_id, "current_rating", $attractionBO->current_rating); } if (isset($attractionBO->vote_times) && $attractionBO->vote_times != "") { $this->addMetaInfoToDatabase($attractionBOAdded->term_id, "vote_times", $attractionBO->vote_times); } $_SESSION["fb_success"][] = ADD_ATTRACTION_SUCCESS; return TRUE; } else { $this->db->rollBack(); $_SESSION["fb_error"][] = ADD_ATTRACTION_SUCCESS; } } } catch (Exception $e) { $_SESSION["fb_error"][] = ERROR_ADD_NEW_ATTRACTION; } return FALSE; }
public function get($taxonomy_id) { $countryBO = parent::get($taxonomy_id); if ($countryBO != null) { Model::autoloadModel("post"); $postModel = new PostModel($this->db); $postBOList = $postModel->getPostRelationshipByTaxonomyId($taxonomy_id, "country"); if (count($postBOList) != 0) { $postBO = $postBOList[0]; $countryBO->postBO = $postBO; if (isset($postBO->post_content)) { $post_content = json_decode($postBO->post_content); if (isset($post_content->overview)) { $countryBO->overview = $post_content->overview; } if (isset($post_content->history)) { $countryBO->history = $post_content->history; } if (isset($post_content->weather)) { $countryBO->weather = $post_content->weather; } if (isset($post_content->passport_visa)) { $countryBO->passport_visa = $post_content->passport_visa; } if (isset($post_content->currency)) { $countryBO->currency = $post_content->currency; } if (isset($post_content->phone_internet_service)) { $countryBO->phone_internet_service = $post_content->phone_internet_service; } if (isset($post_content->transportation)) { $countryBO->transportation = $post_content->transportation; } if (isset($post_content->food_drink)) { $countryBO->food_drink = $post_content->food_drink; } if (isset($post_content->public_holiday)) { $countryBO->public_holiday = $post_content->public_holiday; } if (isset($post_content->predeparture_check_list)) { $countryBO->predeparture_check_list = $post_content->predeparture_check_list; } } Model::autoloadModel('tag'); $tagModel = new TagModel($this->db); $tagList = $tagModel->getTaxonomyRelationshipByObjectId($postBO->ID, 'tag'); if ($tagList != NULL && count($tagList) > 0) { $countryBO->tag_list = $tagList; } if (isset($postBO->image_weather_ids)) { $image_weather_ids = json_decode($postBO->image_weather_ids); Model::autoloadModel('image'); $imageModel = new ImageModel($this->db); $countryBO->image_weathers = array(); foreach ($image_weather_ids as $image_weather_id) { $image_object = $imageModel->get($image_weather_id); if ($image_object != NULL) { $image_info = new stdClass(); $image_info->image_weather_id = $image_weather_id; if (isset($image_object->attachment_metadata) && isset($image_object->attachment_metadata->sizes)) { if (isset($image_object->attachment_metadata->sizes->slider_thumb) && isset($image_object->attachment_metadata->sizes->slider_thumb->url)) { $image_info->slider_thumb_url = $image_object->attachment_metadata->sizes->slider_thumb->url; } // if (isset($image_object->attachment_metadata->sizes->thumbnail) && isset($image_object->attachment_metadata->sizes->thumbnail->url)) { // $image_info->thumbnail_url = $image_object->attachment_metadata->sizes->thumbnail->url; // } // if (isset($image_object->attachment_metadata->sizes->post_thumbnail) && isset($image_object->attachment_metadata->sizes->post_thumbnail->url)) { // $image_info->post_thumbnail_url = $image_object->attachment_metadata->sizes->post_thumbnail->url; // } // if (isset($image_object->attachment_metadata->sizes->medium) && isset($image_object->attachment_metadata->sizes->medium->url)) { // $image_info->medium_url = $image_object->attachment_metadata->sizes->medium->url; // } if (isset($image_object->attachment_metadata->sizes->medium_large) && isset($image_object->attachment_metadata->sizes->medium_large->url)) { $image_info->medium_large_url = $image_object->attachment_metadata->sizes->medium_large->url; } // if (isset($image_object->attachment_metadata->sizes->large) && isset($image_object->attachment_metadata->sizes->large->url)) { // $image_info->large_url = $image_object->attachment_metadata->sizes->large->url; // } } $image_info->image_url = $image_object->guid; if (!isset($image_info->slider_thumb_url)) { $image_info->slider_thumb_url = $image_object->guid; } if (!isset($image_info->medium_large_url)) { $image_info->medium_large_url = $image_object->guid; } $countryBO->image_weathers[] = $image_info; } } } } } return $countryBO; }