public function search($view, $para) { $internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT; $internalflight = "internalflight"; $userLoginBO = json_decode(Session::get("userInfo")); if ($userLoginBO != NULL) { if (isset($userLoginBO->internalflights_per_page) && is_numeric($userLoginBO->internalflights_per_page)) { $internalflights_per_page = (int) $userLoginBO->internalflights_per_page; } } if (!isset($internalflights_per_page)) { if (!isset($_SESSION['options'])) { $_SESSION['options'] = new stdClass(); $_SESSION['options']->internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT; $internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT; } elseif (!isset($_SESSION['options']->internalflights_per_page)) { $_SESSION['options']->internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT; $internalflights_per_page = INTERNALFLIGHTS_PER_PAGE_DEFAULT; } } $view->internalflights_per_page = $internalflights_per_page; $view->internalflight = $internalflight; try { $paraSQL = []; $sqlSelectAll = "SELECT DISTINCT \n cu.`meta_value` AS current_rating,\n vo.`meta_value` AS vote_times,\n im.`meta_value` AS image_id,\n te.`name` AS city_name,\n ta.`term_taxonomy_id` AS city_id,\n ts.`name` AS country_name,\n tc.`term_taxonomy_id` AS country_id,\n po.* "; $sqlSelectCount = "SELECT COUNT(*) as countInternalflight "; //para: orderby, order, page, s, paged, countries, new_role, new_role2, action, action2 $sqlFrom = " FROM\n posts AS po\n LEFT JOIN `postmeta` AS cu ON po.`ID` = cu.`post_id` AND cu.`meta_key` = 'current_rating' \n LEFT JOIN `postmeta` AS vo ON po.`ID` = vo.`post_id` AND vo.`meta_key` = 'vote_times' \n LEFT JOIN `postmeta` AS im ON po.`ID` = im.`post_id` AND im.`meta_key` = 'image_id' \n LEFT JOIN `term_relationships` AS re ON po.`ID` = re.`object_id` \n JOIN `term_taxonomy` AS ta ON re.`term_taxonomy_id` = ta.`term_taxonomy_id` AND ta.`taxonomy` = 'city' \n LEFT JOIN `terms` AS te ON ta.`term_id` = te.`term_id` \n LEFT JOIN `term_relationships` AS rd ON po.`ID` = rd.`object_id` \n JOIN `term_taxonomy` AS tc ON rd.`term_taxonomy_id` = tc.`term_taxonomy_id` AND tc.`taxonomy` = 'country' \n LEFT JOIN `terms` AS ts ON tc.`term_id` = ts.`term_id` "; $sqlWhere = " WHERE po.`post_type` = 'internalflight' "; if (isset($para->s) && strlen(trim($para->s)) > 0) { $sqlWhere .= " AND (\n po.`post_content` LIKE :s \n OR po.`post_name` LIKE :s \n OR po.`post_title` LIKE :s \n OR te.`name` LIKE :s\n OR ts.`name` LIKE :s\n ) "; $paraSQL[':s'] = "%" . $para->s . "%"; $view->s = $para->s; } $view->orderby = "post_title"; $view->order = "asc"; if (isset($para->orderby) && in_array($para->orderby, array("post_title", "city_name", "country_name", "current_rating", "vote_times"))) { switch ($para->orderby) { case "post_title": $para->orderby = "post_title"; $view->orderby = "post_title"; break; case "current_rating": $para->orderby = "current_rating"; $view->orderby = "current_rating"; break; case "vote_times": $para->orderby = "vote_times"; $view->orderby = "vote_times"; break; case "city_name": $para->orderby = "city_name"; $view->orderby = "city_name"; break; case "country_name": $para->orderby = "country_name"; $view->orderby = "country_name"; break; } if (isset($para->order) && in_array($para->order, array("desc", "asc"))) { $view->order = $para->order; } else { $para->order = "asc"; $view->order = "asc"; } $sqlOrderby = " ORDER BY " . $para->orderby . " " . $para->order; } else { $sqlOrderby = " ORDER BY " . TB_POST_COL_POST_TITLE . " ASC"; } $sqlCount = $sqlSelectCount . $sqlFrom . $sqlWhere; $sth = $this->db->prepare($sqlCount); $sth->execute($paraSQL); $countInternalflight = (int) $sth->fetch()->countInternalflight; $view->pageNumber = 0; $view->page = 1; $sqlLimit = ""; if ($countInternalflight > 0) { $view->count = $countInternalflight; $view->pageNumber = floor($view->count / $view->internalflights_per_page); if ($view->count % $view->internalflights_per_page != 0) { $view->pageNumber++; } if (isset($para->page)) { try { $page = (int) $para->page; if ($para->page <= 0) { $page = 1; } } catch (Exception $e) { $page = 1; } } else { $page = 1; } if ($page > $view->pageNumber) { $page = $view->pageNumber; } $view->page = $page; $startInternalflight = ($page - 1) * $view->internalflights_per_page; $sqlLimit = " LIMIT " . $view->internalflights_per_page . " OFFSET " . $startInternalflight; $sqlAll = $sqlSelectAll . $sqlFrom . $sqlWhere . $sqlOrderby . $sqlLimit; $sth = $this->db->prepare($sqlAll); $sth->execute($paraSQL); $count = $sth->rowCount(); if ($count > 0) { $internalflightList = $sth->fetchAll(); for ($i = 0; $i < sizeof($internalflightList); $i++) { $internalflightInfo = $internalflightList[$i]; Model::autoloadModel('image'); $imageModel = new ImageModel($this->db); if (isset($internalflightInfo->image_id)) { $image_object = $imageModel->get($internalflightInfo->image_id); if ($image_object != NULL) { 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)) { $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->slider_thumb->url; } elseif (isset($image_object->attachment_metadata->sizes->thumbnail) && isset($image_object->attachment_metadata->sizes->thumbnail->url)) { $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->thumbnail->url; } elseif (isset($image_object->attachment_metadata->sizes->post_thumbnail) && isset($image_object->attachment_metadata->sizes->post_thumbnail->url)) { $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->post_thumbnail->url; } elseif (isset($image_object->attachment_metadata->sizes->medium) && isset($image_object->attachment_metadata->sizes->medium->url)) { $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->medium->url; } elseif (isset($image_object->attachment_metadata->sizes->medium_large) && isset($image_object->attachment_metadata->sizes->medium_large->url)) { $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->medium_large->url; } elseif (isset($image_object->attachment_metadata->sizes->large) && isset($image_object->attachment_metadata->sizes->large->url)) { $internalflightInfo->image_url = $image_object->attachment_metadata->sizes->large->url; } else { $internalflightInfo->image_url = $image_object->guid; } } else { $internalflightInfo->image_url = $image_object->guid; } } } $this->autoloadBO('internalflight'); $internalflightBO = new InternalflightBO(); $internalflightBO->setInternalflightInfo($internalflightInfo); $internalflightBO->setPost($internalflightInfo); $internalflightList[$i] = $internalflightBO; } $view->internalflightList = $internalflightList; } else { $view->internalflightList = NULL; } } else { $view->internalflightList = NULL; } } catch (Exception $e) { $view->internalflightList = NULL; } }
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; }
public function get($taxonomy_id) { $attractionBO = parent::get($taxonomy_id); if ($attractionBO != null) { Model::autoloadModel("post"); $postModel = new PostModel($this->db); $postBOList = $postModel->getPostRelationshipByTaxonomyId($taxonomy_id, "attraction"); if (count($postBOList) != 0) { $postBO = $postBOList[0]; $attractionBO->postBO = $postBO; if (isset($postBO->post_content)) { $post_content = json_decode($postBO->post_content); if (isset($post_content->post_content_1)) { $attractionBO->post_content_1 = $post_content->post_content_1; } if (isset($post_content->post_content_2)) { $attractionBO->post_content_2 = $post_content->post_content_2; } } Model::autoloadModel('tag'); $tagModel = new TagModel($this->db); $tagList = $tagModel->getTaxonomyRelationshipByObjectId($postBO->ID, 'tag'); if ($tagList != NULL && count($tagList) > 0) { $attractionBO->tag_list = $tagList; } if (isset($postBO->image_ids)) { $image_ids = json_decode($postBO->image_ids); Model::autoloadModel('image'); $imageModel = new ImageModel($this->db); $attractionBO->images = array(); foreach ($image_ids as $image_id) { $image_object = $imageModel->get($image_id); if ($image_object != NULL) { $image_info = new stdClass(); $image_info->image_id = $image_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->large_url)) { $image_info->large_url = $image_object->guid; } $attractionBO->images[] = $image_info; } } } } } return $attractionBO; }
public function getMetaInfo($user_id) { $sth = $this->db->prepare("SELECT *\n FROM " . TABLE_USERMETA . "\n WHERE " . TB_USERMETA_COL_USER_ID . " = :user_id"); $sth->execute(array(':user_id' => $user_id)); $count = $sth->rowCount(); if ($count > 0) { $userMetaInfoArray = $sth->fetchAll(); foreach ($userMetaInfoArray as $userMeta) { if (isset($userMeta->meta_key) && in_array($userMeta->meta_key, array("manage_users_columns_show", "manage_countries_columns_show", "manage_cities_columns_show", "manage_hotels_columns_show", "manage_restaurants_columns_show", "manage_shoppings_columns_show", "manage_internalflights_columns_show", "manage_internationalflights_columns_show", "manage_activities_columns_show", "manage_nightlifes_columns_show", "manage_tags_columns_show", "manage_destinations_columns_show", "manage_eats_columns_show", "manage_styles_columns_show", "manage_types_columns_show"))) { try { $userMeta->meta_value = json_decode($userMeta->meta_value); } catch (Exception $e) { $userMeta->meta_value = NULL; } } if (isset($userMeta->meta_key) && $userMeta->meta_key == "avatar") { Model::autoloadModel('image'); $imageModel = new ImageModel($this->db); $avatar_object = new stdClass(); $avatar_object->umeta_id = $userMeta->umeta_id; $avatar_object->user_id = $userMeta->user_id; $avatar_object->meta_key = 'avatar_object'; $avatar_object->meta_value = $imageModel->get($userMeta->meta_value); $userMetaInfoArray[] = $avatar_object; } } return $userMetaInfoArray; } else { $_SESSION["fb_error"][] = ERR_LOGIN_FAILED; return false; } }