+ $meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
+ if (!empty($meta_addon_picture)) {
+ if (!empty($meta_addon_picture_url)) {
+ $template = str_replace('', '
', $template);
+ } else {
+ $template = str_replace('', '

' . $template_TrainSearch . '
', $template);
- }
- }
- //顶部视频
- $meta_news_video = get_meta($information->ic_id, 'meta_news_video');
- $meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
- if (!empty($meta_news_video) && !empty($meta_video_picture)) {
- $template = str_replace('', '
', $template);
- }
-
- if (is_file('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
- $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css'));
- } else {
- $main_css_string = compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css'));
- }
- $template = str_replace('', '', $template);
-
- // /china-trains/ 节点
- if ($information->is_parent_id == "278008234") {
- $template = str_replace(
- '',
- '
',
- $template
- );
- }
- //额外样式
- $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
- if (!empty($meta_addon_css)) {
- if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) {
- $meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css'));
- } else {
- $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
- }
- $template = str_replace('', '', $template);
- }
- //额外js
- $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
- if (!empty($meta_addon_js)) {
- $template = str_replace('', '', $template);
- }
- //设置内容图片缓加载
- $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.chinahighlights.com/grey.gif');
- $template = str_replace('', $lazy_content, $template);
-
- //替换内容中各种标签
- $tag_why_us = $this->load->view($template_path . '-why-us', false, true);
- $template = str_replace('', $tag_why_us, $template);
-
- //Google广告代码
- //if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
- $template = str_replace('', '
', $template);
- //}
- //社媒分享图片
- $full_ic_photo = '';
- if (!empty($information->ic_photo)) {
- $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
- } else {
- $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- }
- if (!empty($full_ic_photo)) {
- $template = str_replace('', '
', $template);
- }
- //设置图片尺寸
- if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.chinahighlights.com')) {
- $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.chinahighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
- } else {
- $template = $this->html_optimize_lib->set_image_size($template);
- }
- // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
- $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
- $html_path = str_replace("\\", "/", $html_path);
- if (substr($html_path, -1, 1) == '/') {
- $html_path = $html_path . 'index.htm';
- }
- $html_path .= $html_path_ext;
- create_folder_by_path(dirname($html_path));
- file_put_contents($html_path, $template, LOCK_EX);
+ }
+ }
+ //顶部视频
+ $meta_news_video = get_meta($information->ic_id, 'meta_news_video');
+ $meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
+ if (!empty($meta_news_video) && !empty($meta_video_picture)) {
+ $template = str_replace('', '
', $template);
}
- public function test_recommand()
- {
- $information = $this->Information_model->Detail($this->input->get('is_id'));
- $recommand_information = $this->recommand_information($information);
- // var_dump($recommand_information);
- $tips_right_a = [];
- $tips_right_b = [];
- $tips_right_c = [];
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right A_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_a[] = $recommand_information[$key];
- }
- }
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right B_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_b[] = $recommand_information[$key];
- }
- }
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right C_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_c[] = $recommand_information[$key];
- }
- }
+ if (is_file('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
+ $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css'));
+ } else {
+ $main_css_string = compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css'));
+ }
+ $template = str_replace('', '', $template);
+
+ // /china-trains/ 节点
+ if ($information->is_parent_id == "278008234") {
+ $template = str_replace(
+ '',
+ '
',
+ $template
+ );
+ }
+ //额外样式
+ $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
+ if (!empty($meta_addon_css)) {
+ if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) {
+ $meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css'));
+ } else {
+ $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
+ }
+ $template = str_replace('', '', $template);
+ }
+ //额外js
+ $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
+ if (!empty($meta_addon_js)) {
+ $template = str_replace('', '', $template);
+ }
+ //设置内容图片缓加载
+ $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.chinahighlights.com/grey.gif');
+ $template = str_replace('', $lazy_content, $template);
+
+ //替换内容中各种标签
+ $tag_why_us = $this->load->view($template_path . '-why-us', false, true);
+ $template = str_replace('', $tag_why_us, $template);
+
+ //Google广告代码
+ //if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
+ $template = str_replace('', '
', $template);
+ //}
+ //社媒分享图片
+ $full_ic_photo = '';
+ if (!empty($information->ic_photo)) {
+ $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
+ } else {
+ $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ }
+ if (!empty($full_ic_photo)) {
+ $template = str_replace('', '
', $template);
+ }
+ //设置图片尺寸
+ if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.chinahighlights.com')) {
+ $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.chinahighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
+ } else {
+ $template = $this->html_optimize_lib->set_image_size($template);
+ }
+ // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
+ $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
+ $html_path = str_replace("\\", "/", $html_path);
+ if (substr($html_path, -1, 1) == '/') {
+ $html_path = $html_path . 'index.htm';
+ }
+ $html_path .= $html_path_ext;
+ create_folder_by_path(dirname($html_path));
+ file_put_contents($html_path, $template, LOCK_EX);
+ }
+
+ public function test_recommand()
+ {
+ $information = $this->Information_model->Detail($this->input->get('is_id'));
+ $recommand_information = $this->recommand_information($information);
+ // var_dump($recommand_information);
+ $tips_right_a = [];
+ $tips_right_b = [];
+ $tips_right_c = [];
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right A_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_a[] = $recommand_information[$key];
+ }
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right B_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_b[] = $recommand_information[$key];
+ }
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right C_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_c[] = $recommand_information[$key];
+ }
+ }
- echo 'List Tips Right A: ' . COUNT($tips_right_a);
- echo '; List Tips Right B: ' . COUNT($tips_right_b);
- echo '; List Tips Right C: ' . COUNT($tips_right_c);
-
- $tips_right_list_content = $this->load->view(
- 'mobile_first/ah-tips-right-list',
- array(
- 'tips_right_a' => $tips_right_a,
- 'tips_right_b' => $tips_right_b,
- 'tips_right_c' => $tips_right_c
- ),
- true
+ echo 'List Tips Right A: ' . COUNT($tips_right_a);
+ echo '; List Tips Right B: ' . COUNT($tips_right_b);
+ echo '; List Tips Right C: ' . COUNT($tips_right_c);
+
+ $tips_right_list_content = $this->load->view(
+ 'mobile_first/ah-tips-right-list',
+ array(
+ 'tips_right_a' => $tips_right_a,
+ 'tips_right_b' => $tips_right_b,
+ 'tips_right_c' => $tips_right_c
+ ),
+ true
+ );
+ echo $tips_right_list_content;
+ }
+
+ public function test_feedback()
+ {
+ $feedback_newest = $this->Feedback_model->test_feedback_newest();
+ var_dump($feedback_newest);
+ }
+
+ public function test_feedback30()
+ {
+ $feedback30_array = [];
+ preg_match_all('^^', '
', $feedback30_array);
+ if (!empty($feedback30_array)) {
+ foreach ($feedback30_array[0] as $index => $tag_name) {
+ $city_name = $feedback30_array[1][$index];
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 2);
+ $feedback_content = $this->load->view(
+ 'mobile_first/ah-feedback-30-list',
+ array('feedback_list' => $feedback_list),
+ true
);
- echo $tips_right_list_content;
- }
-
- public function test_feedback()
- {
- $feedback_newest = $this->Feedback_model->test_feedback_newest();
- var_dump($feedback_newest);
- }
-
- public function test_feedback30()
- {
- $feedback30_array = [];
- preg_match_all('^^', '
', $feedback30_array);
- if (!empty($feedback30_array)) {
- foreach ($feedback30_array[0] as $index => $tag_name) {
- $city_name = $feedback30_array[1][$index];
- $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 2);
- $feedback_content = $this->load->view(
- 'mobile_first/ah-feedback-30-list',
- array('feedback_list' => $feedback_list),
- true
- );
- echo $feedback_content;
- }
- }
+ echo $feedback_content;
+ }
}
-
- public function test_feedback_city_list()
- {
- $feedback_city_array = [];
- preg_match_all('^^', '
', $feedback_city_array);
- if (!empty($feedback_city_array)) {
- foreach ($feedback_city_array[0] as $index => $tag_name) {
- $city_name_string = $feedback_city_array[1][$index];
- $city_name_list = explode(',', $city_name_string);
- $feedback_city_list = [];
- foreach ($city_name_list as $index => $city_name) {
- $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
- $data_name = str_replace(" ", "_", $city_name);
- $feedback_city_list[$data_name] = $feedback_list;
- }
-
- // header('Content-Type: application/json');
- // echo json_encode($feedback_city_list);
-
- $feedback_content = $this->load->view(
- 'mobile_first/ah-feedback-city-list',
- $feedback_city_list,
- true
- );
- echo $feedback_content;
- }
- }
+ }
+
+ public function test_feedback_city_list()
+ {
+ $feedback_city_array = [];
+ preg_match_all('^^', '
', $feedback_city_array);
+ if (!empty($feedback_city_array)) {
+ foreach ($feedback_city_array[0] as $index => $tag_name) {
+ $city_name_string = $feedback_city_array[1][$index];
+ $city_name_list = explode(',', $city_name_string);
+ $feedback_city_list = [];
+ foreach ($city_name_list as $index => $city_name) {
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
+ $data_name = str_replace(" ", "_", $city_name);
+ $feedback_city_list[$data_name] = $feedback_list;
+ }
+
+ // header('Content-Type: application/json');
+ // echo json_encode($feedback_city_list);
+
+ $feedback_content = $this->load->view(
+ 'mobile_first/ah-feedback-city-list',
+ $feedback_city_list,
+ true
+ );
+ echo $feedback_content;
+ }
}
-
- public function test_price()
- {
- $price_rule = '
#ah-23,st,2#
';
- $price_item_array = $this->price_pregmatch($price_rule);
- var_dump($price_item_array);
- $price_tag_list = $this->parse_price_tag($price_rule);
- var_dump($price_tag_list);
- }
-
- /*!
- * 页面中有价格标签,查出价格并替换内容
- * @author LiaoYijun
- * @date 2023-05-12
- * @param string $price_content 包含价格标签的内容
- * @return array 包含价格与占位符的数组
- */
- public function parse_price_tag($price_content)
- {
- $price_item_array = $this->price_pregmatch($price_content);
- $price_tag_list = [];
- if (!empty($price_item_array)) {
- foreach ($price_item_array as $price_item) {
- $price_date = !empty($price_item->price_date) ? $price_item->price_date : date('Y-m-d', time() + 86400 * 7); //当前时间7天后的价格
- $price_number = '';
- //优先读取新的价格体系
- $price = $this->PrimeLinePrice_model->search($price_item->cli_no, 1, $price_item->cli_grade, $price_item->person_size, $price_date);
- if (!empty($price)) {
- switch (strtoupper($price_item->price_people)) {
- case 'A':
- $price_number = $price->PLP_AdultUnitPrice;
- break;
- case 'C':
- $price_number = $price->PLP_ChildUnitPrice;
- break;
- case 'B':
- $price_number = $price->PLP_BabyUnitPrice;
- break;
- case 'R':
- $price_number = $price->PLP_RoomDiffPrice;
- break;
- case 'AR':
- $price_number = $price->PLP_AdultUnitPrice + $price->PLP_RoomDiffPrice; //成人加单间房差
- break;
- default:
- $price_number = $price->PLP_AdultUnitPrice;
- }
- } else {
- $price = $this->Price_model->search($price_item->cli_no, 1, $price_item->cli_grade, false, $price_date);
- if (!empty($price)) {
-
- switch (strtoupper($price_item->price_people)) {
- case 'A':
- switch ($price_item->person_size) {
- case '1':
- $price_number = $price->CLP_OneAdultPriceRMB;
- break;
- case '2': //25
- $price_number = $price->CLP_TwoToFiveAdultPriceRMB;
- break;
- case '6': //69
- $price_number = $price->CLP_SixToNineAdultPriceRMB;
- break;
- case '10':
- $price_number = $price->CLP_OverTenAdultPriceRMB;
- break;
- default:
- $price_number = $price->CLP_TwoToFiveAdultPriceRMB;
- }
- break;
- case 'C':
- $price_number = 0;
- break;
- case 'B':
- $price_number = 0;
- break;
- case 'R':
- switch ($price_item->person_size) {
- case '1':
- $price_number = $price->CLP_OneRoomDiffPriceRMB;
- break;
- case '2': //25
- $price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB;
- break;
- case '6': //69
- $price_number = $price->CLP_SixToNineRoomDiffPriceRMB;
- break;
- case '10':
- $price_number = $price->CLP_OverTenRoomDiffPriceRMB;
- break;
- default:
- $price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB;
- }
- break;
- case 'AR': //成人加单间房差
- $price_number = 0;
- break;
- default:
- $price_number = 0;
- }
- }
- }
- $site_money = $this->currency->calc_show_price($price_number);
- //把金额格式化为带有逗号(,)方便阅读,如 12,345
- $price_number = is_numeric($price_number) ? number_format($site_money) : $price_number;
- if (!empty($price_number)) {
- $price_tag = [
- 'placeholder' => $price_item->placeholder,
- 'price_number' => $price_number,
- ];
- $price_tag_list[] = $price_tag;
- }
- }
- }
- return $price_tag_list;
- }
-
- //使用正则匹配出价格标签,返回一个价格数组
- private function price_pregmatch($content)
- {
- $price_array = array();
- $temp_array = array();
- $result = false;
- //#ah-1,lx,2,2016-01-23,A#
- //线路代号,等级(st标准、lx豪华、ec经济),人等,时间,人型(A成人、C小孩、B婴儿、R单间房差、AR成人+房差)
- preg_match_all('^#[a-zA-Z0-9,-]+#^', $content, $temp_array);
- foreach ($temp_array[0] as $item) {
- $placeholder = $item;
- $item = str_replace('#', '', $item);
- $price_array = explode(',', $item);
- $cli_no = !empty($price_array[0]) ? $price_array[0] : false; //线路代号
- if (empty($cli_no)) {
- continue; //没有设置线路代号则进入下一条
- }
- $cli_grade = !empty($price_array[1]) ? $price_array[1] : false; //标准7001、豪华7002、经济7003
- switch (strtoupper($cli_grade)) {
- case 'ST':
- $cli_grade = '7001';
- break;
- case 'LX':
- $cli_grade = '7002';
+ }
+
+ public function test_price()
+ {
+ $price_rule = '
#ah-23,st,2#
';
+ $price_item_array = $this->price_pregmatch($price_rule);
+ var_dump($price_item_array);
+ $price_tag_list = $this->parse_price_tag($price_rule);
+ var_dump($price_tag_list);
+ }
+
+ /*!
+ * 页面中有价格标签,查出价格并替换内容
+ * @author LiaoYijun
+ * @date 2023-05-12
+ * @param string $price_content 包含价格标签的内容
+ * @return array 包含价格与占位符的数组
+ */
+ public function parse_price_tag($price_content)
+ {
+ $price_item_array = $this->price_pregmatch($price_content);
+ $price_tag_list = [];
+ if (!empty($price_item_array)) {
+ foreach ($price_item_array as $price_item) {
+ $price_date = !empty($price_item->price_date) ? $price_item->price_date : date('Y-m-d', time() + 86400 * 7); //当前时间7天后的价格
+ $price_number = '';
+ //优先读取新的价格体系
+ $price = $this->PrimeLinePrice_model->search($price_item->cli_no, 1, $price_item->cli_grade, $price_item->person_size, $price_date);
+ if (!empty($price)) {
+ switch (strtoupper($price_item->price_people)) {
+ case 'A':
+ $price_number = $price->PLP_AdultUnitPrice;
+ break;
+ case 'C':
+ $price_number = $price->PLP_ChildUnitPrice;
+ break;
+ case 'B':
+ $price_number = $price->PLP_BabyUnitPrice;
+ break;
+ case 'R':
+ $price_number = $price->PLP_RoomDiffPrice;
+ break;
+ case 'AR':
+ $price_number = $price->PLP_AdultUnitPrice + $price->PLP_RoomDiffPrice; //成人加单间房差
+ break;
+ default:
+ $price_number = $price->PLP_AdultUnitPrice;
+ }
+ } else {
+ $price = $this->Price_model->search($price_item->cli_no, 1, $price_item->cli_grade, false, $price_date);
+ if (!empty($price)) {
+
+ switch (strtoupper($price_item->price_people)) {
+ case 'A':
+ switch ($price_item->person_size) {
+ case '1':
+ $price_number = $price->CLP_OneAdultPriceRMB;
break;
- case 'EC':
- $cli_grade = '7003';
+ case '2': //25
+ $price_number = $price->CLP_TwoToFiveAdultPriceRMB;
break;
- default:
- $cli_grade = '7001';
- }
- $person_size = (!empty($price_array[2]) && is_numeric($price_array[2])) ? $price_array[2] : 2; //人等1,2-5,6-9,10,默认2人等
- //为了兼容以前的人等方式,把算数人等转换为单数 25=>2
- switch ($person_size) {
- case '25':
- $person_size = '2';
+ case '6': //69
+ $price_number = $price->CLP_SixToNineAdultPriceRMB;
break;
- case '69':
- $person_size = '6';
+ case '10':
+ $price_number = $price->CLP_OverTenAdultPriceRMB;
break;
- }
- $price_date = !empty($price_array[3]) ? $price_array[3] : false; //价格时间
- $price_people = !empty($price_array[4]) ? $price_array[4] : 'A'; //A成人、C小孩、B婴儿、R单间房差
- $result[] = (object) array('placeholder' => $placeholder, 'cli_no' => $cli_no, 'cli_grade' => $cli_grade, 'person_size' => $person_size, 'price_date' => $price_date, 'price_people' => $price_people);
- }
- return $result;
- }
-
- public function make_www_cache_gh($device, $information, $recommand_information)
- {
- $data = array();
- switch ($device) {
- case 'mobile':
- //获取移动优先的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
- $template = $this->load->view($template_path, '', true);
- $html_path_ext = '-mobile.htm';
- } else {
- return false;
+ default:
+ $price_number = $price->CLP_TwoToFiveAdultPriceRMB;
}
break;
- case 'pc':
- //获取PC的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
- $template = $this->load->view($template_path . '-pc', '', true);
- $html_path_ext = '-pc.htm';
- } else {
- return false;
- }
+ case 'C':
+ $price_number = 0;
break;
- default:
- }
-
- // GH Home 下层节点名称和链接映射
- $group_map = [
- 278009289 => [
- 'ic_url' => '/destinations',
- 'ic_url_title' => 'Destinations',
- ],
- 278009290 => [
- 'ic_url' => '/about',
- 'ic_url_title' => 'About Us',
- ],
- ];
- $breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map);
-
- $breadcrumb_structured_data_content = $this->load->view(
- $template_path . '-structured-data-breadcrumb',
- array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
- true
- );
- $template = str_replace(
- '',
- $breadcrumb_structured_data_content,
- $template
- );
-
- //替换模板中的标签
- $template = str_replace('', $information->ic_seo_title, $template);
- $template = str_replace('', $information->ic_seo_description, $template);
- $template = str_replace('', $information->ic_seo_keywords, $template);
- $template = str_replace('', $this->config->item('site_url') . $information->ic_url, $template);
-
- //顶部全屏大图
- if ($device == 'mobile') { //移动端读取移动大图
- $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- } else {
- $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
- }
-
- $meta_product_code = get_meta($information->ic_id, 'meta_product_code');
- $ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
- //H1模板替换
- $data_H1 = array();
- $data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
- $data_H1['author'] = ''; //获取作者信息
- $author = $this->Operator_model->get_author_nikename($information->ic_author);
-
- if (!empty($author)) {
- $data_H1['author'] = $author->OPI_FirstName;
- } else {
- $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
- if (!empty($author_web)) {
- $data_H1['author'] = $author_web->a_name;
- }
- }
- $data_H1['ic_title'] = $information->ic_title;
- $data_H1['ic_photo'] = $meta_addon_picture; //$information->ic_photo; 用额外设置的图片替代
- $data_H1['breadcrumb_data'] = $breadcrumb_data;
- $data_H1['ads_by_google'] = $ads_by_google;
- $template_H1 = $this->load->view($template_path . '-h1', $data_H1, true);
- $template = str_replace('', $template_H1, $template);
-
- if (empty($meta_product_code)) {
- $addthis_widget = $this->load->view($template_path . '-add-this', false, true);
- $template = str_replace('', $addthis_widget, $template);
- }
-
- $article_structured_data_content = $this->load->view(
- $template_path . '-structured-data-article',
- array('information' => $information, 'author_name' => $data_H1['author']),
- true
- );
- $template = str_replace('', $article_structured_data_content, $template);
-
- if (!empty($meta_product_code)) {
- //
- $product_code_input = "
";
- $template = str_replace('', $product_code_input, $template);
- }
-
- if (empty($meta_product_code)) {
- $template = str_replace('?product_code=', '', $template);
- } else {
- $template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
- }
-
- //信息推荐
- $template_recommand = $recommand_information; //$this->recommand_information($information); 从外面传进来,pc和移动只需要查一次,减少数据库负担
- $template = str_replace('', $this->load->view($template_path . '-next', array('recommands' => $template_recommand), true), $template);
- // //广告,改叫tips,防止被插件屏蔽
- if (!empty($template_recommand['Tips Right TOP'])) {
- // $template = str_replace('', "
", $template);
- }
- if (!empty($template_recommand['Tips Right'])) {
- $template = str_replace('', "
" . $template_recommand['Tips Right']->it_content . "
", $template);
- }
- // 右侧列表广告
- $tips_right_a = [];
- $tips_right_b = [];
- $tips_right_c = [];
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right A_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_a[] = $recommand_information[$key];
- }
- }
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right B_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_b[] = $recommand_information[$key];
- }
- }
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right C_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_c[] = $recommand_information[$key];
- }
- }
-
- $tips_right_list_content = $this->load->view(
- 'mobile_first/gh-tips-right-list',
- array(
- 'tips_right_a' => $tips_right_a,
- 'tips_right_b' => $tips_right_b,
- 'tips_right_c' => $tips_right_c
- ),
- true
- );
-
- $template = str_replace('', $tips_right_list_content, $template);
- //文中的信息推荐
- if (strpos($information->ic_content, '') !== false) {
- // $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), TRUE), $information->ic_content);
- }
- //文中的线路推荐
- if (strpos($information->ic_content, '') !== false) {
- // $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), TRUE), $information->ic_content);
- }
-
- //替换内容中广告
- $temp_array = array();
- preg_match_all('^^', $information->ic_content, $temp_array);
- if (!empty($temp_array[1])) {
- foreach ($temp_array[1] as $key => $item) {
- $tips_detail = $this->recommends_and_tips_model->tips_detail($item);
- if ($tips_detail) {
- $information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
- }
- }
- }
-
- $why_us_covid_list_pc = $this->load->view(
- $template_path . '-why-us-covid-list-pc',
- array(),
- true
- );
- $information->ic_content = str_replace('', $why_us_covid_list_pc, $information->ic_content);
- $why_us_covid_list_mobile = $this->load->view(
- $template_path . '-why-us-covid-mobile',
- array(),
- true
- );
- $information->ic_content = str_replace('', $why_us_covid_list_mobile, $information->ic_content);
-
- if (empty($meta_product_code)) {
- $info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
- $information->ic_content = str_replace('', $info_page_form_content, $information->ic_content);
- } else {
- $tour_form_content = $this->load->view(
- 'mobile_first/gh-tour-form',
- array('information' => $information, 'meta_product_code' => $meta_product_code),
- true
- );
- $information->ic_content = str_replace('', $tour_form_content, $information->ic_content);
- }
-
- // 动态加载反馈标签,每个城市三十条反馈。
- // HTLM:
- // 解析结果:; Bangkok
- $feedback30_array = [];
- preg_match_all('^^', $information->ic_content, $feedback30_array);
- if (!empty($feedback30_array)) {
- foreach ($feedback30_array[0] as $index => $tag_name) {
- $city_name = $feedback30_array[1][$index];
- $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
- $feedback_30_content = $this->load->view(
- 'mobile_first/gh-feedback-30-list',
- array('feedback_list' => $feedback_list),
- true
- );
- $information->ic_content = str_replace(
- $tag_name,
- $feedback_30_content,
- $information->ic_content
- );
- }
- }
-
- // 集合页面反馈标签
- $feedback_city_array = [];
- preg_match_all('^^', $information->ic_content, $feedback_city_array);
- if (!empty($feedback_city_array)) {
- foreach ($feedback_city_array[0] as $index => $tag_name) {
- $city_name_string = $feedback_city_array[1][$index];
- $city_name_list = explode(',', $city_name_string);
- $feedback_city_list = [];
- foreach ($city_name_list as $index => $city_name) {
- $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
- $data_name = str_replace(" ", "_", $city_name);
- $feedback_city_list[$data_name] = $feedback_list;
- }
-
- $feedback_city_content = $this->load->view(
- 'mobile_first/gh-feedback-city-list',
- $feedback_city_list,
- true
- );
- $information->ic_content = str_replace(
- $tag_name,
- $feedback_city_content,
- $information->ic_content
- );
- }
- }
-
- $feedback_newest = $this->Feedback_model->get_feedback_newest();
- $feedback_newest_content = $this->load->view(
- $template_path . '-feedback-newest',
- array('feedback_list' => $feedback_newest),
- true
- );
- $information->ic_content = str_replace(
- '',
- $feedback_newest_content,
- $information->ic_content
- );
-
- if (is_file('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
- $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css'));
- } else {
- $main_css_string = compress_css(GET_HTTP('https://www.globalhighlights.com/css/gh-global.css'));
- }
- $template = str_replace('', '', $template);
- //额外样式
- $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
- if (!empty($meta_addon_css)) {
- // if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) {
- //$meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css'));
- // } else {
- $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
- // }
- $template = str_replace('', '', $template);
- }
- //额外js
- $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
- if (!empty($meta_addon_js)) {
- $template = str_replace('', '', $template);
- }
- //设置内容图片缓加载
- $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.chinahighlights.com/grey.gif');
- $template = str_replace('', $lazy_content, $template);
-
- //社媒分享图片
- $full_ic_photo = '';
- if (!empty($information->ic_photo)) {
- $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
- } else {
- $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- }
- if (!empty($full_ic_photo)) {
- $template = str_replace('', '
', $template);
- }
- //设置图片尺寸
- if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.globalhighlights.com')) {
- $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.globalhighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
- } else {
- $template = $this->html_optimize_lib->set_image_size($template);
- }
- // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
- $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
- $html_path = str_replace("\\", "/", $html_path);
- if (substr($html_path, -1, 1) == '/') {
- $html_path = $html_path . 'index.htm';
- }
- $html_path .= $html_path_ext;
- create_folder_by_path(dirname($html_path));
- file_put_contents($html_path, $template, LOCK_EX);
- }
-
- public function make_www_cache_ah($device, $information, $recommand_information)
- {
-
- $data = array();
- $data['information'] = $information;
- $recommand_template = '';
- switch ($device) {
- case 'mobile':
- //获取移动优先的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
- $template = $this->load->view($template_path, '', true);
- $html_path_ext = '-mobile.htm';
- } else {
- return false;
- }
- $recommand_template = 'mobile_first/ah-next-mobile';
+ case 'B':
+ $price_number = 0;
break;
- case 'pc':
- //获取PC的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
- $template = $this->load->view($template_path . '-pc', '', true);
- $html_path_ext = '-pc.htm';
- } else {
- return false;
+ case 'R':
+ switch ($price_item->person_size) {
+ case '1':
+ $price_number = $price->CLP_OneRoomDiffPriceRMB;
+ break;
+ case '2': //25
+ $price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB;
+ break;
+ case '6': //69
+ $price_number = $price->CLP_SixToNineRoomDiffPriceRMB;
+ break;
+ case '10':
+ $price_number = $price->CLP_OverTenRoomDiffPriceRMB;
+ break;
+ default:
+ $price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB;
}
- $recommand_template = 'mobile_first/ah-next';
break;
- default:
- }
-
- //替换模板中的标签
- $template = str_replace('', $information->ic_seo_title, $template);
- $template = str_replace('', $information->ic_seo_description, $template);
- $template = str_replace('', $information->ic_seo_keywords, $template);
- $template = str_replace('', $this->config->item('site_url') . $information->ic_url, $template);
-
- //顶部视频
- $data['meta_news_video'] = get_meta($information->ic_id, 'meta_news_video');
- $data['meta_video_picture'] = get_meta($information->ic_id, 'meta_video_picture');
- if (empty($data['meta_news_video']) && empty($data['meta_video_picture'])) {
- //没有顶部视频时候才读取全屏大图
- //顶部全屏大图
- if ($device == 'mobile') { //移动端读取移动大图
- $data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- } else {
- $data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture');
- }
- $data['meta_addon_picture_url'] = get_meta($information->ic_id, 'meta_addon_picture_url');
- }
-
- // AH Home 下层节点名称和链接映射
- $group_map = [
- 278002667 => [
- 'ic_url' => '/destinations',
- 'ic_url_title' => 'Destinations',
- ],
- 278008885 => [
- 'ic_url' => '/about-us',
- 'ic_url_title' => 'About Us',
- ],
- ];
-
- $breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map);
- $ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
- $data['ads_by_google'] = $ads_by_google;
- $data['author'] = ''; //获取作者信息
- $author = $this->Operator_model->get_author_nikename($information->ic_author);
- if (!empty($author)) {
- $data['author'] = $author->OPI_FirstName;
+ case 'AR': //成人加单间房差
+ $price_number = 0;
+ break;
+ default:
+ $price_number = 0;
+ }
+ }
+ }
+ $site_money = $this->currency->calc_show_price($price_number);
+ //把金额格式化为带有逗号(,)方便阅读,如 12,345
+ $price_number = is_numeric($price_number) ? number_format($site_money) : $price_number;
+ if (!empty($price_number)) {
+ $price_tag = [
+ 'placeholder' => $price_item->placeholder,
+ 'price_number' => $price_number,
+ ];
+ $price_tag_list[] = $price_tag;
+ }
+ }
+ }
+ return $price_tag_list;
+ }
+
+ //使用正则匹配出价格标签,返回一个价格数组
+ private function price_pregmatch($content)
+ {
+ $price_array = array();
+ $temp_array = array();
+ $result = false;
+ //#ah-1,lx,2,2016-01-23,A#
+ //线路代号,等级(st标准、lx豪华、ec经济),人等,时间,人型(A成人、C小孩、B婴儿、R单间房差、AR成人+房差)
+ preg_match_all('^#[a-zA-Z0-9,-]+#^', $content, $temp_array);
+ foreach ($temp_array[0] as $item) {
+ $placeholder = $item;
+ $item = str_replace('#', '', $item);
+ $price_array = explode(',', $item);
+ $cli_no = !empty($price_array[0]) ? $price_array[0] : false; //线路代号
+ if (empty($cli_no)) {
+ continue; //没有设置线路代号则进入下一条
+ }
+ $cli_grade = !empty($price_array[1]) ? $price_array[1] : false; //标准7001、豪华7002、经济7003
+ switch (strtoupper($cli_grade)) {
+ case 'ST':
+ $cli_grade = '7001';
+ break;
+ case 'LX':
+ $cli_grade = '7002';
+ break;
+ case 'EC':
+ $cli_grade = '7003';
+ break;
+ default:
+ $cli_grade = '7001';
+ }
+ $person_size = (!empty($price_array[2]) && is_numeric($price_array[2])) ? $price_array[2] : 2; //人等1,2-5,6-9,10,默认2人等
+ //为了兼容以前的人等方式,把算数人等转换为单数 25=>2
+ switch ($person_size) {
+ case '25':
+ $person_size = '2';
+ break;
+ case '69':
+ $person_size = '6';
+ break;
+ }
+ $price_date = !empty($price_array[3]) ? $price_array[3] : false; //价格时间
+ $price_people = !empty($price_array[4]) ? $price_array[4] : 'A'; //A成人、C小孩、B婴儿、R单间房差
+ $result[] = (object) array('placeholder' => $placeholder, 'cli_no' => $cli_no, 'cli_grade' => $cli_grade, 'person_size' => $person_size, 'price_date' => $price_date, 'price_people' => $price_people);
+ }
+ return $result;
+ }
+
+ public function make_www_cache_gh($device, $information, $recommand_information)
+ {
+ $data = array();
+ switch ($device) {
+ case 'mobile':
+ //获取移动优先的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
+ $template = $this->load->view($template_path, '', true);
+ $html_path_ext = '-mobile.htm';
} else {
- $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
- if (!empty($author_web)) {
- $data['author'] = $author_web->a_name;
- }
- }
- $data['breadcrumb_data'] = $breadcrumb_data;
- $template_H1 = $this->load->view($template_path . '-h1', $data, true);
- $template = str_replace('', $template_H1, $template);
- // 结构化标签:Article
- $article_structured_data_content = $this->load->view(
- $template_path . '-structured-data-article',
- array('information' => $information, 'author' => $author),
- true
- );
- $template = str_replace('', $article_structured_data_content, $template);
- // 结构化标签:BreadcrumbList
- $breadcrumb_structured_data_content = $this->load->view(
- $template_path . '-structured-data-breadcrumb',
- array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
- true
- );
- $template = str_replace(
- '',
- $breadcrumb_structured_data_content,
- $template
- );
-
- //推荐信息或者产品
- $template_recommand = $recommand_information;
- $template = str_replace('', $this->load->view($recommand_template, array('recommands' => $template_recommand), true), $template);
- //广告,改叫tips,防止被插件屏蔽
- if (!empty($template_recommand['Tips Right'])) {
- $template = str_replace('', "
" . $template_recommand['Tips Right']->it_content . "
", $template);
- }
- // 右侧列表广告
- $tips_right_a = [];
- $tips_right_b = [];
- $tips_right_c = [];
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right A_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_a[] = $recommand_information[$key];
- }
- }
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right B_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_b[] = $recommand_information[$key];
- }
- }
- for ($i = 1; $i <= 12; $i++) {
- $key = 'List Tips Right C_' . $i;
- if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
- $tips_right_c[] = $recommand_information[$key];
- }
+ return false;
+ }
+ break;
+ case 'pc':
+ //获取PC的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
+ $template = $this->load->view($template_path . '-pc', '', true);
+ $html_path_ext = '-pc.htm';
+ } else {
+ return false;
}
+ break;
+ default:
+ }
- $tips_right_list_content = $this->load->view(
- 'mobile_first/ah-tips-right-list',
- array(
- 'tips_right_a' => $tips_right_a,
- 'tips_right_b' => $tips_right_b,
- 'tips_right_c' => $tips_right_c
- ),
- true
- );
+ // GH Home 下层节点名称和链接映射
+ $group_map = [
+ 278009289 => [
+ 'ic_url' => '/destinations',
+ 'ic_url_title' => 'Destinations',
+ ],
+ 278009290 => [
+ 'ic_url' => '/about',
+ 'ic_url_title' => 'About Us',
+ ],
+ ];
+ $breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map);
+
+ $breadcrumb_structured_data_content = $this->load->view(
+ $template_path . '-structured-data-breadcrumb',
+ array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
+ true
+ );
+ $template = str_replace(
+ '',
+ $breadcrumb_structured_data_content,
+ $template
+ );
+
+ //替换模板中的标签
+ $template = str_replace('', $information->ic_seo_title, $template);
+ $template = str_replace('', $information->ic_seo_description, $template);
+ $template = str_replace('', $information->ic_seo_keywords, $template);
+ $template = str_replace('', $this->config->item('site_url') . $information->ic_url, $template);
+
+ //顶部全屏大图
+ if ($device == 'mobile') { //移动端读取移动大图
+ $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ } else {
+ $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
+ }
- $template = str_replace('', $tips_right_list_content, $template);
+ $meta_product_code = get_meta($information->ic_id, 'meta_product_code');
+ $ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
+ //H1模板替换
+ $data_H1 = array();
+ $data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
+ $data_H1['author'] = ''; //获取作者信息
+ $author = $this->Operator_model->get_author_nikename($information->ic_author);
+
+ if (!empty($author)) {
+ $data_H1['author'] = $author->OPI_FirstName;
+ } else {
+ $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
+ if (!empty($author_web)) {
+ $data_H1['author'] = $author_web->a_name;
+ }
+ }
+ $data_H1['ic_title'] = $information->ic_title;
+ $data_H1['ic_photo'] = $meta_addon_picture; //$information->ic_photo; 用额外设置的图片替代
+ $data_H1['breadcrumb_data'] = $breadcrumb_data;
+ $data_H1['ads_by_google'] = $ads_by_google;
+ $template_H1 = $this->load->view($template_path . '-h1', $data_H1, true);
+ $template = str_replace('', $template_H1, $template);
+
+ if (empty($meta_product_code)) {
+ $addthis_widget = $this->load->view($template_path . '-add-this', false, true);
+ $template = str_replace('', $addthis_widget, $template);
+ }
- //文中的信息推荐
- if (strpos($information->ic_content, '') !== false) {
- $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), true), $information->ic_content);
- }
- //文中的线路推荐
- if (strpos($information->ic_content, '') !== false) {
- $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), true), $information->ic_content);
- }
+ $article_structured_data_content = $this->load->view(
+ $template_path . '-structured-data-article',
+ array('information' => $information, 'author_name' => $data_H1['author']),
+ true
+ );
+ $template = str_replace('', $article_structured_data_content, $template);
+
+ if (!empty($meta_product_code)) {
+ //
+ $product_code_input = "
";
+ $template = str_replace('', $product_code_input, $template);
+ }
- //替换内容中广告
- $temp_array = array();
- preg_match_all('^^', $information->ic_content, $temp_array);
- if (!empty($temp_array[1])) {
- foreach ($temp_array[1] as $key => $item) {
- $tips_detail = $this->recommends_and_tips_model->tips_detail($item);
- if ($tips_detail) {
- $information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
- }
- }
- }
+ if (empty($meta_product_code)) {
+ $template = str_replace('?product_code=', '', $template);
+ } else {
+ $template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
+ }
- $meta_product_code = get_meta($information->ic_id, 'meta_product_code');
- // 非产品页面
- if (empty($meta_product_code)) {
- $addthis_widget = $this->load->view($template_path . '-add-this', false, true);
- $template = str_replace('', $addthis_widget, $template);
- $template = str_replace('?product_code=', '', $template);
- } else {
- $template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
- $inquiry_form_template = $this->load->view(
- $template_path . '-inquiry-form',
- array('meta_product_code' => $meta_product_code, 'information' => $information),
- true
- );
- $information->ic_content = str_replace('', $inquiry_form_template, $information->ic_content);
-
- // GP 表单
- $gp_form_content = $this->load->view(
- $template_path . '-gp-form',
- array('meta_product_code' => $meta_product_code, 'information' => $information),
- true
- );
- $information->ic_content = str_replace('', $gp_form_content, $information->ic_content);
-
- // tour-list 表单
- $tour_list_form_content = $this->load->view(
- $template_path . '-tour-list-form',
- array('meta_product_code' => $meta_product_code, 'information' => $information),
- true
- );
- $information->ic_content = str_replace('', $tour_list_form_content, $information->ic_content);
-
- // 水灯节 GP 线路表单
- $gp_form_content = $this->load->view(
- $template_path . '-lantern-festival-gp-form',
- array('meta_product_code' => $meta_product_code, 'information' => $information),
- true
- );
- $information->ic_content = str_replace('', $gp_form_content, $information->ic_content);
- }
+ //信息推荐
+ $template_recommand = $recommand_information; //$this->recommand_information($information); 从外面传进来,pc和移动只需要查一次,减少数据库负担
+ $template = str_replace('', $this->load->view($template_path . '-next', array('recommands' => $template_recommand), true), $template);
+ // //广告,改叫tips,防止被插件屏蔽
+ if (!empty($template_recommand['Tips Right TOP'])) {
+ // $template = str_replace('', "
", $template);
+ }
+ if (!empty($template_recommand['Tips Right'])) {
+ $template = str_replace('', "
" . $template_recommand['Tips Right']->it_content . "
", $template);
+ }
+ // 右侧列表广告
+ $tips_right_a = [];
+ $tips_right_b = [];
+ $tips_right_c = [];
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right A_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_a[] = $recommand_information[$key];
+ }
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right B_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_b[] = $recommand_information[$key];
+ }
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right C_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_c[] = $recommand_information[$key];
+ }
+ }
- $price_tag_list = $this->parse_price_tag($information->ic_content);
+ $tips_right_list_content = $this->load->view(
+ 'mobile_first/gh-tips-right-list',
+ array(
+ 'tips_right_a' => $tips_right_a,
+ 'tips_right_b' => $tips_right_b,
+ 'tips_right_c' => $tips_right_c
+ ),
+ true
+ );
+
+ $template = str_replace('', $tips_right_list_content, $template);
+ //文中的信息推荐
+ if (strpos($information->ic_content, '') !== false) {
+ // $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), TRUE), $information->ic_content);
+ }
+ //文中的线路推荐
+ if (strpos($information->ic_content, '') !== false) {
+ // $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), TRUE), $information->ic_content);
+ }
- foreach ($price_tag_list as $price_tag) {
- $information->ic_content = str_replace(
- $price_tag['placeholder'],
- $price_tag['price_number'],
- $information->ic_content
- );
+ //替换内容中广告
+ $temp_array = array();
+ preg_match_all('^^', $information->ic_content, $temp_array);
+ if (!empty($temp_array[1])) {
+ foreach ($temp_array[1] as $key => $item) {
+ $tips_detail = $this->recommends_and_tips_model->tips_detail($item);
+ if ($tips_detail) {
+ $information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
}
- // why-us 相关的标签
- $why_us_mobile = $this->load->view($template_path . '-why-us-mobile', false, true);
- $information->ic_content = str_replace('', $why_us_mobile, $information->ic_content);
-
- $why_us_tour_detail_pc = $this->load->view($template_path . '-why-us-tour-detail-pc', false, true);
- $information->ic_content = str_replace('', $why_us_tour_detail_pc, $information->ic_content);
-
- $why_us_tour_list_pc = $this->load->view($template_path . '-why-us-tour-list-pc', false, true);
- $information->ic_content = str_replace('', $why_us_tour_list_pc, $information->ic_content);
+ }
+ }
- $info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
- $information->ic_content = str_replace('', $info_page_form_content, $information->ic_content);
+ $why_us_covid_list_pc = $this->load->view(
+ $template_path . '-why-us-covid-list-pc',
+ array(),
+ true
+ );
+ $information->ic_content = str_replace('', $why_us_covid_list_pc, $information->ic_content);
+ $why_us_covid_list_mobile = $this->load->view(
+ $template_path . '-why-us-covid-mobile',
+ array(),
+ true
+ );
+ $information->ic_content = str_replace('', $why_us_covid_list_mobile, $information->ic_content);
+
+ if (empty($meta_product_code)) {
+ $info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
+ $information->ic_content = str_replace('', $info_page_form_content, $information->ic_content);
+ } else {
+ $tour_form_content = $this->load->view(
+ 'mobile_first/gh-tour-form',
+ array('information' => $information, 'meta_product_code' => $meta_product_code),
+ true
+ );
+ $information->ic_content = str_replace('', $tour_form_content, $information->ic_content);
+ }
- // 水灯节表单
- $lantern_form_content = $this->load->view(
- $template_path . '-lantern-form',
- array('information' => $information),
- true
+ // 动态加载反馈标签,每个城市三十条反馈。
+ // HTLM:
+ // 解析结果:; Bangkok
+ $feedback30_array = [];
+ preg_match_all('^^', $information->ic_content, $feedback30_array);
+ if (!empty($feedback30_array)) {
+ foreach ($feedback30_array[0] as $index => $tag_name) {
+ $city_name = $feedback30_array[1][$index];
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
+ $feedback_30_content = $this->load->view(
+ 'mobile_first/gh-feedback-30-list',
+ array('feedback_list' => $feedback_list),
+ true
);
- $information->ic_content = str_replace('', $lantern_form_content, $information->ic_content);
- // 水灯节在信息页面表单
- $lantern_form_info_page_content = $this->load->view(
- $template_path . '-lantern-form-info-page',
- array('information' => $information),
- true
+ $information->ic_content = str_replace(
+ $tag_name,
+ $feedback_30_content,
+ $information->ic_content
);
- $information->ic_content = str_replace('', $lantern_form_info_page_content, $information->ic_content);
-
- // 动态加载反馈标签,第一个城市不足八条,使用第二城市数据。
- // HTLM:
- // 解析结果:; Siem Reap,Bangkok
- $feedback_array = [];
- preg_match_all('^^', $information->ic_content, $feedback_array);
- if (!empty($feedback_array)) {
- foreach ($feedback_array[0] as $index => $tag_name) {
- $city_name_string = $feedback_array[1][$index];
- $city_name_list = explode(',', $city_name_string);
- $feedback_list = $this->Feedback_model->get_feedback_by_city_list($city_name_list);
- $feedback_content = $this->load->view(
- $template_path . '-feedback-list',
- array('feedback_list' => $feedback_list),
- true
- );
- $information->ic_content = str_replace(
- $tag_name,
- $feedback_content,
- $information->ic_content
- );
- }
- }
-
- // 动态加载反馈标签,每个城市三十条反馈。
- // HTLM:
- // 解析结果:; Bangkok
- $feedback30_array = [];
- preg_match_all('^^', $information->ic_content, $feedback30_array);
- if (!empty($feedback30_array)) {
- foreach ($feedback30_array[0] as $index => $tag_name) {
- $city_name = $feedback30_array[1][$index];
- $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
- $feedback_30_content = $this->load->view(
- 'mobile_first/ah-feedback-30-list',
- array('feedback_list' => $feedback_list),
- true
- );
- $information->ic_content = str_replace(
- $tag_name,
- $feedback_30_content,
- $information->ic_content
- );
- }
- }
-
- // 集合页面反馈标签
- $feedback_city_array = [];
- preg_match_all('^^', $information->ic_content, $feedback_city_array);
- if (!empty($feedback_city_array)) {
- foreach ($feedback_city_array[0] as $index => $tag_name) {
- $city_name_string = $feedback_city_array[1][$index];
- $city_name_list = explode(',', $city_name_string);
- $feedback_city_list = [];
- foreach ($city_name_list as $index => $city_name) {
- $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
- $data_name = str_replace(" ", "_", $city_name);
- $feedback_city_list[$data_name] = $feedback_list;
- }
-
- $feedback_city_content = $this->load->view(
- 'mobile_first/ah-feedback-city-list',
- $feedback_city_list,
- true
- );
- $information->ic_content = str_replace(
- $tag_name,
- $feedback_city_content,
- $information->ic_content
- );
- }
- }
+ }
+ }
- $feedback_newest = $this->Feedback_model->get_feedback_newest();
- $feedback_newest_content = $this->load->view(
- $template_path . '-feedback-newest',
- array('feedback_list' => $feedback_newest),
- true
+ // 集合页面反馈标签
+ $feedback_city_array = [];
+ preg_match_all('^^', $information->ic_content, $feedback_city_array);
+ if (!empty($feedback_city_array)) {
+ foreach ($feedback_city_array[0] as $index => $tag_name) {
+ $city_name_string = $feedback_city_array[1][$index];
+ $city_name_list = explode(',', $city_name_string);
+ $feedback_city_list = [];
+ foreach ($city_name_list as $index => $city_name) {
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
+ $data_name = str_replace(" ", "_", $city_name);
+ $feedback_city_list[$data_name] = $feedback_list;
+ }
+
+ $feedback_city_content = $this->load->view(
+ 'mobile_first/gh-feedback-city-list',
+ $feedback_city_list,
+ true
);
$information->ic_content = str_replace(
- '',
- $feedback_newest_content,
- $information->ic_content
+ $tag_name,
+ $feedback_city_content,
+ $information->ic_content
);
+ }
+ }
- //主样式表,内联模式
- if (is_file('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
- $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css'));
- } else {
- $main_css_string = compress_css(GET_HTTP('https://proxy-data.asiahighlights.com/css/mobile-first.css'));
- }
- $template = str_replace('', '', $template);
- //额外样式
- $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
- if (!empty($meta_addon_css)) {
- //内联方式
- $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
- $template = str_replace('', '', $template);
- }
- //额外js
- $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
- if (!empty($meta_addon_js)) {
- $template = str_replace('', '', $template);
- }
- //设置内容图片缓加载
- $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.asiahighlights.com/grey.gif');
- $template = str_replace('', $lazy_content, $template);
-
- //Google广告代码
- //if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
- $template = str_replace('', '
', $template);
- //}
- //社媒分享图片
-
- $full_ic_photo = '';
- if (!empty($information->ic_photo)) {
- $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
- } else {
- $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- }
- if (!empty($full_ic_photo)) {
- $template = str_replace('', '
', $template);
- }
-
- //设置图片尺寸
- if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.asiahighlights.com')) {
- $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.asiahighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
+ $feedback_newest = $this->Feedback_model->get_feedback_newest();
+ $feedback_newest_content = $this->load->view(
+ $template_path . '-feedback-newest',
+ array('feedback_list' => $feedback_newest),
+ true
+ );
+ $information->ic_content = str_replace(
+ '',
+ $feedback_newest_content,
+ $information->ic_content
+ );
+
+ if (is_file('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
+ $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css'));
+ } else {
+ $main_css_string = compress_css(GET_HTTP('https://www.globalhighlights.com/css/gh-global.css'));
+ }
+ $template = str_replace('', '', $template);
+ //额外样式
+ $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
+ if (!empty($meta_addon_css)) {
+ // if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) {
+ //$meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css'));
+ // } else {
+ $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
+ // }
+ $template = str_replace('', '', $template);
+ }
+ //额外js
+ $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
+ if (!empty($meta_addon_js)) {
+ $template = str_replace('', '', $template);
+ }
+ //设置内容图片缓加载
+ $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.chinahighlights.com/grey.gif');
+ $template = str_replace('', $lazy_content, $template);
+
+ //社媒分享图片
+ $full_ic_photo = '';
+ if (!empty($information->ic_photo)) {
+ $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
+ } else {
+ $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ }
+ if (!empty($full_ic_photo)) {
+ $template = str_replace('', '
', $template);
+ }
+ //设置图片尺寸
+ if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.globalhighlights.com')) {
+ $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.globalhighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
+ } else {
+ $template = $this->html_optimize_lib->set_image_size($template);
+ }
+ // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
+ $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
+ $html_path = str_replace("\\", "/", $html_path);
+ if (substr($html_path, -1, 1) == '/') {
+ $html_path = $html_path . 'index.htm';
+ }
+ $html_path .= $html_path_ext;
+ create_folder_by_path(dirname($html_path));
+ file_put_contents($html_path, $template, LOCK_EX);
+ }
+
+ public function make_www_cache_ah($device, $information, $recommand_information)
+ {
+
+ $data = array();
+ $data['information'] = $information;
+ $recommand_template = '';
+ switch ($device) {
+ case 'mobile':
+ //获取移动优先的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
+ $template = $this->load->view($template_path, '', true);
+ $html_path_ext = '-mobile.htm';
} else {
- $template = $this->html_optimize_lib->set_image_size($template);
- }
- // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
- $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
- $html_path = str_replace("\\", "/", $html_path);
- if (substr($html_path, -1, 1) == '/') {
- $html_path = $html_path . 'index.htm';
- }
- $html_path .= $html_path_ext;
- create_folder_by_path(dirname($html_path));
- file_put_contents($html_path, $template, LOCK_EX);
- }
-
- /**
- * @description: CT用的生成静态文件方法.有些内容的替换,CT这边不一样,需要单独处理 zp
- * @param {type} $device='mobile' or 'pc'
- * @return:
- * @Date Changed:
- */
- public function make_www_cache_ct($information)
- {
- $data = array();
-
- #region 公用数据
- //$apiurl = "http://202.103.68.104:61/info.php"; //本地测试
- $apiurl = "https://ct.mycht.cn/info.php"; //网前
-
- //先准备数据,CT采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
- $data["TITLE"] = $information->ic_seo_title;
- $data["DESCRIPTION"] = $information->ic_seo_description;
- $data["KEYWORDS"] = $information->ic_seo_keywords;
- $data["CANONICAL"] = $this->config->item('site_url') . $information->ic_url;
- $meta_ct_page_type = "";
- $meta_ct_page_type = get_meta($information->ic_id, 'meta_ct_page_type'); //页面类型
- $meta_product_code = get_meta($information->ic_id, 'meta_product_code'); //绑定的产品编号
- $template_path = 'mobile_first/' . $this->config->item('site_code'); //模板位置
-
- //面包屑
- $crumb = "";
- $crumb_data = $this->Information_model->get_path_exclude_ct($information->is_id, $information->is_path);
- if (count($crumb_data) > 0) { //至少有一个父类面包屑才显示
- $crumb = "
";
- }
- $data["crumb"] = $crumb;
-
- //作者字符串,信息页或者城市天气页加载 2022-7-26
- $str_author = "";
- $author = $this->Operator_model->get_author_nikename($information->ic_author);
- if ((empty($meta_product_code) && !($meta_ct_page_type !== false && $meta_ct_page_type != "")) || $meta_ct_page_type == "weatherpage") {
- $OPI_FirstName = !empty($author) ? $author->OPI_FirstName : 'author nickname';
- $str_author = '
Written by ' . $OPI_FirstName . ' Updated ' . date("M. j, Y", strtotime($information->ic_datetime)) . '
';
- }
-
- //火车票详细页搜索框添加 -- zp
- $meta_ct_page_trainform = get_meta($information->ic_id, 'meta_ct_page_trainform'); //是否插入火车票搜索框
- $template_TrainDetailSearch = "";
- if ($meta_ct_page_trainform == "yes" || $information->is_parent_id == "278014609") {
- $template_TrainDetailSearch = $this->load->view($template_path . '-train-detail', null, true);
- }
-
- /* 详细内容 */
- $ic_content = $information->ic_content;
-
- #region old replace
- // /**替换详细内容里面的价格
- /* 直接使用fetch来动态获取价格,这样不用替换标签,直接录标签
- // * // 一日游价格标签, "" 或者 逗号后面是人数
- // * //精华线路标签""
- // */
- // $ic_content = preg_replace_callback('//i',function($match){
- // //处理一日游每次配备
- // $matchItem = $match[1];
- // return '
';;
- // },$ic_content);
- // $ic_content = preg_replace_callback('//i',function($match){
- // //处理精华线路每次配备
- // $matchItem = $match[1];
- // return '
';;
- // },$ic_content);
- #enregion
-
- /** 替换H1加面包屑,加作者 */
- $ic_content = preg_replace('/
(.*)<\/h1>/i', $crumb . "\r\n" . '$1
' . "\r\n" . $str_author . $template_TrainDetailSearch . "\r\n", $ic_content, 1);
-
- /**替换zodiac标签 */
- if (strpos($ic_content, '') !== false) {
- $zodiacCalc = $this->load->view('mobile_first/' . $this->config->item('site_code') . '-zodiac-calc', false, true);
- $ic_content = str_replace('', $zodiacCalc, $ic_content);
+ return false;
+ }
+ $recommand_template = 'mobile_first/ah-next-mobile';
+ break;
+ case 'pc':
+ //获取PC的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
+ $template = $this->load->view($template_path . '-pc', '', true);
+ $html_path_ext = '-pc.htm';
+ } else {
+ return false;
}
+ $recommand_template = 'mobile_first/ah-next';
+ break;
+ default:
+ }
- //图片加延迟
- $ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.chinatravel.com/images/mobile-first/grey.gif');
-
- $ic_content = $this->html_optimize_lib->set_image_size($ic_content);
-
- $data["CUSTOMCONENT"] = $ic_content;
+ //替换模板中的标签
+ $template = str_replace('', $information->ic_seo_title, $template);
+ $template = str_replace('', $information->ic_seo_description, $template);
+ $template = str_replace('', $information->ic_seo_keywords, $template);
+ $template = str_replace('', $this->config->item('site_url') . $information->ic_url, $template);
+
+ //顶部视频
+ $data['meta_news_video'] = get_meta($information->ic_id, 'meta_news_video');
+ $data['meta_video_picture'] = get_meta($information->ic_id, 'meta_video_picture');
+ if (empty($data['meta_news_video']) && empty($data['meta_video_picture'])) {
+ //没有顶部视频时候才读取全屏大图
+ //顶部全屏大图
+ if ($device == 'mobile') { //移动端读取移动大图
+ $data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ } else {
+ $data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture');
+ }
+ $data['meta_addon_picture_url'] = get_meta($information->ic_id, 'meta_addon_picture_url');
+ }
- //非产品页面
- $data["PRODUCTJS"] = "";
- $data["ISPRODUCT"] = "no"; //判断是否是产品页
- $data["addthis_widget"] = "";
- $data["FloatIcon"] = ""; //浮动图标替代addthis
- $arrExitUrl = array("/", "/culture", "/guide", "/tour", "/citytour", "/daytrip", "/asia-tour", "/china-trains");
+ // AH Home 下层节点名称和链接映射
+ $group_map = [
+ 278002667 => [
+ 'ic_url' => '/destinations',
+ 'ic_url_title' => 'Destinations',
+ ],
+ 278008885 => [
+ 'ic_url' => '/about-us',
+ 'ic_url_title' => 'About Us',
+ ],
+ ];
+
+ $breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map);
+ $ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
+ $data['ads_by_google'] = $ads_by_google;
+ $data['author'] = ''; //获取作者信息
+ $author = $this->Operator_model->get_author_nikename($information->ic_author);
+ if (!empty($author)) {
+ $data['author'] = $author->OPI_FirstName;
+ } else {
+ $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
+ if (!empty($author_web)) {
+ $data['author'] = $author_web->a_name;
+ }
+ }
+ $data['breadcrumb_data'] = $breadcrumb_data;
+ $template_H1 = $this->load->view($template_path . '-h1', $data, true);
+ $template = str_replace('', $template_H1, $template);
+ // 结构化标签:Article
+ $article_structured_data_content = $this->load->view(
+ $template_path . '-structured-data-article',
+ array('information' => $information, 'author' => $author),
+ true
+ );
+ $template = str_replace('', $article_structured_data_content, $template);
+ // 结构化标签:BreadcrumbList
+ $breadcrumb_structured_data_content = $this->load->view(
+ $template_path . '-structured-data-breadcrumb',
+ array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
+ true
+ );
+ $template = str_replace(
+ '',
+ $breadcrumb_structured_data_content,
+ $template
+ );
+
+ //推荐信息或者产品
+ $template_recommand = $recommand_information;
+ $template = str_replace('', $this->load->view($recommand_template, array('recommands' => $template_recommand), true), $template);
+ //广告,改叫tips,防止被插件屏蔽
+ if (!empty($template_recommand['Tips Right'])) {
+ $template = str_replace('', "" . $template_recommand['Tips Right']->it_content . "
", $template);
+ }
+ // 右侧列表广告
+ $tips_right_a = [];
+ $tips_right_b = [];
+ $tips_right_c = [];
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right A_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_a[] = $recommand_information[$key];
+ }
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right B_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_b[] = $recommand_information[$key];
+ }
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $key = 'List Tips Right C_' . $i;
+ if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
+ $tips_right_c[] = $recommand_information[$key];
+ }
+ }
- if (empty(get_meta($information->ic_id, 'meta_product_code')) || in_array($information->ic_url, $arrExitUrl)) {
- //$data["addthis_widget"] = $this->load->view($template_path . '-add-this', false, true); //社媒代码addthis
- $data["FloatIcon"] = "";
- } else {
- // $data["PRODUCTJS"] = '';
- $data["ISPRODUCT"] = "yes";
- }
+ $tips_right_list_content = $this->load->view(
+ 'mobile_first/ah-tips-right-list',
+ array(
+ 'tips_right_a' => $tips_right_a,
+ 'tips_right_b' => $tips_right_b,
+ 'tips_right_c' => $tips_right_c
+ ),
+ true
+ );
+
+ $template = str_replace('', $tips_right_list_content, $template);
+
+ //文中的信息推荐
+ if (strpos($information->ic_content, '') !== false) {
+ $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), true), $information->ic_content);
+ }
+ //文中的线路推荐
+ if (strpos($information->ic_content, '') !== false) {
+ $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), true), $information->ic_content);
+ }
- //顶部视频
- $data["TOPVIDEO"] = "";
- $meta_news_video = get_meta($information->ic_id, 'meta_news_video');
- $meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
- if (!empty($meta_news_video) && !empty($meta_video_picture)) {
- $data["TOPVIDEO"] = '
';
+ //替换内容中广告
+ $temp_array = array();
+ preg_match_all('^^', $information->ic_content, $temp_array);
+ if (!empty($temp_array[1])) {
+ foreach ($temp_array[1] as $key => $item) {
+ $tips_detail = $this->recommends_and_tips_model->tips_detail($item);
+ if ($tips_detail) {
+ $information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
}
+ }
+ }
- //主样式表,内联模式
- //$apiweb="http://202.103.68.104"; //本地测试
- $apiweb = "https://data.chinatravel.com";
- $cssUrl = $apiweb . "/css/newcss3/base.css?v=" . time();
- $main_css_string = compress_css(GET_HTTP($cssUrl));
- $data["MAINCSS"] = '';
-
- //额外样式
- $data["ADDONCSS"] = "";
- $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
- if (!empty($meta_addon_css)) {
- //引用方式
- //$data["ADDONCSS"]= '';
- //内联方式
- $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
- $data["ADDONCSS"] = '';
- }
- //社媒分享图片
- $data["OGIMAGE"] = "";
- if (!empty($information->ic_photo)) {
- if (strpos($information->ic_photo, "chinatravel.com") != false) {
- $full_ic_photo = $information->ic_photo;
- } else {
- $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
- }
- $data["OGIMAGE"] = '';
- }
+ $meta_product_code = get_meta($information->ic_id, 'meta_product_code');
+ // 非产品页面
+ if (empty($meta_product_code)) {
+ $addthis_widget = $this->load->view($template_path . '-add-this', false, true);
+ $template = str_replace('', $addthis_widget, $template);
+ $template = str_replace('?product_code=', '', $template);
+ } else {
+ $template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
+ $inquiry_form_template = $this->load->view(
+ $template_path . '-inquiry-form',
+ array('meta_product_code' => $meta_product_code, 'information' => $information),
+ true
+ );
+ $information->ic_content = str_replace('', $inquiry_form_template, $information->ic_content);
+
+ // GP 表单
+ $gp_form_content = $this->load->view(
+ $template_path . '-gp-form',
+ array('meta_product_code' => $meta_product_code, 'information' => $information),
+ true
+ );
+ $information->ic_content = str_replace('', $gp_form_content, $information->ic_content);
+
+ // tour-list 表单
+ $tour_list_form_content = $this->load->view(
+ $template_path . '-tour-list-form',
+ array('meta_product_code' => $meta_product_code, 'information' => $information),
+ true
+ );
+ $information->ic_content = str_replace('', $tour_list_form_content, $information->ic_content);
+
+ // 水灯节 GP 线路表单
+ $gp_form_content = $this->load->view(
+ $template_path . '-lantern-festival-gp-form',
+ array('meta_product_code' => $meta_product_code, 'information' => $information),
+ true
+ );
+ $information->ic_content = str_replace('', $gp_form_content, $information->ic_content);
+ }
- //结构化标签
- $data["ConstructionCode"] = "";
- $meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
- if (!empty($meta_construction_code)) {
- $data["ConstructionCode"] = $meta_construction_code;
- }
+ $price_tag_list = $this->parse_price_tag($information->ic_content);
- //总JS:为了方便以后js好维护,必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js,所以必须在这里进行判断
- $addBaseJs = false;
- $addonJs = "";
- $meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
+ foreach ($price_tag_list as $price_tag) {
+ $information->ic_content = str_replace(
+ $price_tag['placeholder'],
+ $price_tag['price_number'],
+ $information->ic_content
+ );
+ }
+ // why-us 相关的标签
+ $why_us_mobile = $this->load->view($template_path . '-why-us-mobile', false, true);
+ $information->ic_content = str_replace('', $why_us_mobile, $information->ic_content);
+
+ $why_us_tour_detail_pc = $this->load->view($template_path . '-why-us-tour-detail-pc', false, true);
+ $information->ic_content = str_replace('', $why_us_tour_detail_pc, $information->ic_content);
+
+ $why_us_tour_list_pc = $this->load->view($template_path . '-why-us-tour-list-pc', false, true);
+ $information->ic_content = str_replace('', $why_us_tour_list_pc, $information->ic_content);
+
+ $info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
+ $information->ic_content = str_replace('', $info_page_form_content, $information->ic_content);
+
+ // 水灯节表单
+ $lantern_form_content = $this->load->view(
+ $template_path . '-lantern-form',
+ array('information' => $information),
+ true
+ );
+ $information->ic_content = str_replace('', $lantern_form_content, $information->ic_content);
+ // 水灯节在信息页面表单
+ $lantern_form_info_page_content = $this->load->view(
+ $template_path . '-lantern-form-info-page',
+ array('information' => $information),
+ true
+ );
+ $information->ic_content = str_replace('', $lantern_form_info_page_content, $information->ic_content);
+
+ // 动态加载反馈标签,第一个城市不足八条,使用第二城市数据。
+ // HTLM:
+ // 解析结果:; Siem Reap,Bangkok
+ $feedback_array = [];
+ preg_match_all('^^', $information->ic_content, $feedback_array);
+ if (!empty($feedback_array)) {
+ foreach ($feedback_array[0] as $index => $tag_name) {
+ $city_name_string = $feedback_array[1][$index];
+ $city_name_list = explode(',', $city_name_string);
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_list($city_name_list);
+ $feedback_content = $this->load->view(
+ $template_path . '-feedback-list',
+ array('feedback_list' => $feedback_list),
+ true
+ );
+ $information->ic_content = str_replace(
+ $tag_name,
+ $feedback_content,
+ $information->ic_content
+ );
+ }
+ }
- if ($meta_ct_page_price == "yes") {
- $addBaseJs = true;
- } else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
- $addBaseJs = true;
- }
+ // 动态加载反馈标签,每个城市三十条反馈。
+ // HTLM:
+ // 解析结果:; Bangkok
+ $feedback30_array = [];
+ preg_match_all('^^', $information->ic_content, $feedback30_array);
+ if (!empty($feedback30_array)) {
+ foreach ($feedback30_array[0] as $index => $tag_name) {
+ $city_name = $feedback30_array[1][$index];
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
+ $feedback_30_content = $this->load->view(
+ 'mobile_first/ah-feedback-30-list',
+ array('feedback_list' => $feedback_list),
+ true
+ );
+ $information->ic_content = str_replace(
+ $tag_name,
+ $feedback_30_content,
+ $information->ic_content
+ );
+ }
+ }
- if ($addBaseJs) {
- $addonJs = '';
- }
- /// ----- 总JS判断完成-----
+ // 集合页面反馈标签
+ $feedback_city_array = [];
+ preg_match_all('^^', $information->ic_content, $feedback_city_array);
+ if (!empty($feedback_city_array)) {
+ foreach ($feedback_city_array[0] as $index => $tag_name) {
+ $city_name_string = $feedback_city_array[1][$index];
+ $city_name_list = explode(',', $city_name_string);
+ $feedback_city_list = [];
+ foreach ($city_name_list as $index => $city_name) {
+ $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
+ $data_name = str_replace(" ", "_", $city_name);
+ $feedback_city_list[$data_name] = $feedback_list;
+ }
+
+ $feedback_city_content = $this->load->view(
+ 'mobile_first/ah-feedback-city-list',
+ $feedback_city_list,
+ true
+ );
+ $information->ic_content = str_replace(
+ $tag_name,
+ $feedback_city_content,
+ $information->ic_content
+ );
+ }
+ }
- //额外js
- $data["ADDONJS"] = "";
- $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
- if (!empty($meta_addon_js)) {
- $addonJs .= '';
- }
- //价格js
- if ($meta_ct_page_price == "yes") {
- $addonJs .= '';
- }
+ $feedback_newest = $this->Feedback_model->get_feedback_newest();
+ $feedback_newest_content = $this->load->view(
+ $template_path . '-feedback-newest',
+ array('feedback_list' => $feedback_newest),
+ true
+ );
+ $information->ic_content = str_replace(
+ '',
+ $feedback_newest_content,
+ $information->ic_content
+ );
+
+ //主样式表,内联模式
+ if (is_file('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
+ $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css'));
+ } else {
+ $main_css_string = compress_css(GET_HTTP('https://proxy-data.asiahighlights.com/css/mobile-first.css'));
+ }
+ $template = str_replace('', '', $template);
+ //额外样式
+ $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
+ if (!empty($meta_addon_css)) {
+ //内联方式
+ $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
+ $template = str_replace('', '', $template);
+ }
+ //额外js
+ $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
+ if (!empty($meta_addon_js)) {
+ $template = str_replace('', '', $template);
+ }
+ //设置内容图片缓加载
+ $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.asiahighlights.com/grey.gif');
+ $template = str_replace('', $lazy_content, $template);
+
+ //Google广告代码
+ //if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
+ $template = str_replace('', '', $template);
+ //}
+ //社媒分享图片
+
+ $full_ic_photo = '';
+ if (!empty($information->ic_photo)) {
+ $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
+ } else {
+ $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ }
+ if (!empty($full_ic_photo)) {
+ $template = str_replace('', '', $template);
+ }
- //列表js
- if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) {
- $addonJs .= '';
- }
+ //设置图片尺寸
+ if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.asiahighlights.com')) {
+ $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.asiahighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
+ } else {
+ $template = $this->html_optimize_lib->set_image_size($template);
+ }
+ // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
+ $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
+ $html_path = str_replace("\\", "/", $html_path);
+ if (substr($html_path, -1, 1) == '/') {
+ $html_path = $html_path . 'index.htm';
+ }
+ $html_path .= $html_path_ext;
+ create_folder_by_path(dirname($html_path));
+ file_put_contents($html_path, $template, LOCK_EX);
+ }
+
+ /**
+ * @description: CT用的生成静态文件方法.有些内容的替换,CT这边不一样,需要单独处理 zp
+ * @param {type} $device='mobile' or 'pc'
+ * @return:
+ * @Date Changed:
+ */
+ public function make_www_cache_ct($information)
+ {
+ $data = array();
+
+ #region 公用数据
+ //$apiurl = "http://202.103.68.104:61/info.php"; //本地测试
+ $apiurl = "https://ct.mycht.cn/info.php"; //网前
+
+ //先准备数据,CT采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
+ $data["TITLE"] = $information->ic_seo_title;
+ $data["DESCRIPTION"] = $information->ic_seo_description;
+ $data["KEYWORDS"] = $information->ic_seo_keywords;
+ $data["CANONICAL"] = $this->config->item('site_url') . $information->ic_url;
+ $meta_ct_page_type = "";
+ $meta_ct_page_type = get_meta($information->ic_id, 'meta_ct_page_type'); //页面类型
+ $meta_product_code = get_meta($information->ic_id, 'meta_product_code'); //绑定的产品编号
+ $template_path = 'mobile_first/' . $this->config->item('site_code'); //模板位置
+
+ //面包屑
+ $crumb = "";
+ $crumb_data = $this->Information_model->get_path_exclude_ct($information->is_id, $information->is_path);
+ if (count($crumb_data) > 0) { //至少有一个父类面包屑才显示
+ $crumb = "";
+ }
+ $data["crumb"] = $crumb;
+
+ //作者字符串,信息页或者城市天气页加载 2022-7-26
+ $str_author = "";
+ $author = $this->Operator_model->get_author_nikename($information->ic_author);
+ if ((empty($meta_product_code) && !($meta_ct_page_type !== false && $meta_ct_page_type != "")) || $meta_ct_page_type == "weatherpage") {
+ $OPI_FirstName = !empty($author) ? $author->OPI_FirstName : 'author nickname';
+ $str_author = 'Written by ' . $OPI_FirstName . ' Updated ' . date("M. j, Y", strtotime($information->ic_datetime)) . '
';
+ }
- //天气
- if (in_array($meta_ct_page_type, array('weatherpage'))) {
- $addonJs .= '';
- }
+ //火车票详细页搜索框添加 -- zp
+ $meta_ct_page_trainform = get_meta($information->ic_id, 'meta_ct_page_trainform'); //是否插入火车票搜索框
+ $template_TrainDetailSearch = "";
+ if ($meta_ct_page_trainform == "yes" || $information->is_parent_id == "278014609") {
+ $template_TrainDetailSearch = $this->load->view($template_path . '-train-detail', null, true);
+ }
- //页面传递参数
- $passParam = "";
- if (in_array($meta_ct_page_type, array("daytripindex", "tourindex", "attractionindex", "weatherpage"))) { //一日游和线路列表
- //产品首页
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
-
- if (in_array($meta_ct_page_type, array("attractionindex"))) {
- //旧信息id,景点等信息类
- $passParam .= '';
- } else {
- //城市名称,产品类用
- $passParam .= '';
- }
+ /* 详细内容 */
+ $ic_content = $information->ic_content;
+
+ #region old replace
+ // /**替换详细内容里面的价格
+ /* 直接使用fetch来动态获取价格,这样不用替换标签,直接录标签
+ // * // 一日游价格标签, "" 或者 逗号后面是人数
+ // * //精华线路标签""
+ // */
+ // $ic_content = preg_replace_callback('//i',function($match){
+ // //处理一日游每次配备
+ // $matchItem = $match[1];
+ // return '';;
+ // },$ic_content);
+ // $ic_content = preg_replace_callback('//i',function($match){
+ // //处理精华线路每次配备
+ // $matchItem = $match[1];
+ // return '';;
+ // },$ic_content);
+ #enregion
+
+ /** 替换H1加面包屑,加作者 */
+ $ic_content = preg_replace('/(.*)<\/h1>/i', $crumb . "\r\n" . '$1
' . "\r\n" . $str_author . $template_TrainDetailSearch . "\r\n", $ic_content, 1);
+
+ /**替换zodiac标签 */
+ if (strpos($ic_content, '') !== false) {
+ $zodiacCalc = $this->load->view('mobile_first/' . $this->config->item('site_code') . '-zodiac-calc', false, true);
+ $ic_content = str_replace('', $zodiacCalc, $ic_content);
+ }
- //加信息平台的is_id
- $passParam .= '';
- }
+ //图片加延迟
+ $ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.chinatravel.com/images/mobile-first/grey.gif');
- //产品详细页
- $productType = "";
- $productCode = "";
- if ($meta_ct_page_type == "daytripdetail") {
- //一日游
- if (!empty($meta_ct_page_type)) {
- $productType = $meta_ct_page_type;
- }
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
- if (!empty($meta_ct_page_value)) {
- $productCode = $meta_ct_page_value;
- }
- $addonJs .= '';
- //$addonJs .= '';
- $data["ADDONCSS"] .= '';
- }
- if ($meta_ct_page_type == "tourdetail") {
- //线路
- $productType = $meta_ct_page_type;
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
- if (!empty($meta_ct_page_value)) {
- $productCode = $meta_ct_page_value;
- }
+ $ic_content = $this->html_optimize_lib->set_image_size($ic_content);
- //获取cli_sn
- $tourdata = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getCliSn/?param=" . $productCode));
- $data["clisn"] = $tourdata->clisn;
+ $data["CUSTOMCONENT"] = $ic_content;
- //调取模板
- $dataform["TourCode"] = $productCode;
- $dataform["CLI_SN"] = $tourdata->clisn;
- $dataform["TourName"] = $information->ic_title;
+ //非产品页面
+ $data["PRODUCTJS"] = "";
+ $data["ISPRODUCT"] = "no"; //判断是否是产品页
+ $data["addthis_widget"] = "";
+ $data["FloatIcon"] = ""; //浮动图标替代addthis
+ $arrExitUrl = array("/", "/culture", "/guide", "/tour", "/citytour", "/daytrip", "/asia-tour", "/china-trains");
+ if (empty(get_meta($information->ic_id, 'meta_product_code')) || in_array($information->ic_url, $arrExitUrl)) {
+ //$data["addthis_widget"] = $this->load->view($template_path . '-add-this', false, true); //社媒代码addthis
+ $data["FloatIcon"] = "";
+ } else {
+ // $data["PRODUCTJS"] = '';
+ $data["ISPRODUCT"] = "yes";
+ }
- }
+ //顶部视频
+ $data["TOPVIDEO"] = "";
+ $meta_news_video = get_meta($information->ic_id, 'meta_news_video');
+ $meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
+ if (!empty($meta_news_video) && !empty($meta_video_picture)) {
+ $data["TOPVIDEO"] = '
';
+ }
- //游船详细页
- if ($meta_ct_page_type == "cruisedetails") {
- $productType = $meta_ct_page_type;
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
- if (!empty($meta_ct_page_value)) {
- $productCode = $meta_ct_page_value;
- }
- $dataCruise["shipname"] = $productCode;
- $template_curisedetails = $this->load->view($template_path . '-cruisedetails-form', $dataCruise, true);
- $data["template_curisedetails"] = $template_curisedetails;
- }
+ //主样式表,内联模式
+ //$apiweb="http://202.103.68.104"; //本地测试
+ $apiweb = "https://data.chinatravel.com";
+ $cssUrl = $apiweb . "/css/newcss3/base.css?v=" . time();
+ $main_css_string = compress_css(GET_HTTP($cssUrl));
+ $data["MAINCSS"] = '';
+
+ //额外样式
+ $data["ADDONCSS"] = "";
+ $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
+ if (!empty($meta_addon_css)) {
+ //引用方式
+ //$data["ADDONCSS"]= '';
+ //内联方式
+ $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
+ $data["ADDONCSS"] = '';
+ }
+ //社媒分享图片
+ $data["OGIMAGE"] = "";
+ if (!empty($information->ic_photo)) {
+ if (strpos($information->ic_photo, "chinatravel.com") != false) {
+ $full_ic_photo = $information->ic_photo;
+ } else {
+ $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
+ }
+ $data["OGIMAGE"] = '';
+ }
- //表单页
- if (in_array($meta_ct_page_type, array("customize", "contactus", "pagewithform", "tourdetail"))) {
- $productType = $meta_ct_page_type;
- $addonJs .= '';
- $data["ADDONCSS"] .= '';
- }
+ //结构化标签
+ $data["ConstructionCode"] = "";
+ $meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
+ if (!empty($meta_construction_code)) {
+ $data["ConstructionCode"] = $meta_construction_code;
+ }
- $data["productType"] = $productType;
- $data["productCode"] = $productCode;
-
- //页面添加的元素
- $data["ADDONJS"] = $addonJs;
- $data["passParam"] = $passParam;
-
- #endregion
-
- #region 移动端和PC端差别处理区域
- $arrDevice = array("mobile", "pc");
- foreach ($arrDevice as $device) {
- //顶部全屏大图
- $data["TOPBANNER"] = "";
- $ImgText = ""; //图文字
- $meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
- $meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text');
- if ($device == 'mobile') { //移动端读取移动大图
- $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- $bannerImg = '
';
- if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
- $ImgText = '';
- } else if (!empty($meta_addon_picture_text)) {
- $ImgText = '' . $meta_addon_picture_text . '
';
- }
- } else {
- $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
- $bannerImg = '
';
- if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
- $ImgText = '';
- } else if (!empty($meta_addon_picture_text)) {
- $ImgText = '' . $meta_addon_picture_text . '
';
- }
- }
+ //总JS:为了方便以后js好维护,必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js,所以必须在这里进行判断
+ $addBaseJs = false;
+ $addonJs = "";
+ $meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
- // 搜索框
- $template_TrainSearch = "";
- if ($information->ic_url == "/china-trains/hometest" || $information->ic_url == "/china-trains") {
- //火车票首页
- $template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
- $ImgText = "";
- //火车票移动端去掉头部图片,保证搜索框CLS
- if ($device == 'mobile') {
- $meta_addon_picture = "";
- $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
- }
- } else if ($information->ic_url == "/china-flights") {
- //机票首页
- $template_TrainSearch = $this->load->view($template_path . '-flight-index', null, true);
- $ImgText = "";
- //飞机票移动端去掉头部图片,保证搜索框CLS
- if ($device == 'mobile') {
- $meta_addon_picture = "";
- $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
- }
- }
+ if ($meta_ct_page_price == "yes") {
+ $addBaseJs = true;
+ } else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
+ $addBaseJs = true;
+ }
- if (!empty($meta_addon_picture)) {
- if (!empty($meta_addon_picture_url)) {
- $data["TOPBANNER"] = '';
- } else {
- $data["TOPBANNER"] = '' . $bannerImg . $ImgText . $template_TrainSearch . '
';
- }
- }
+ if ($addBaseJs) {
+ $addonJs = '';
+ }
+ /// ----- 总JS判断完成-----
- if ($meta_ct_page_type == "tourdetail") {
- $dataform['device'] = $device;
- $template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
- $data["template_form_tourqi"] = $template_form_tourqi; //表单模板字符串
- }
+ //额外js
+ $data["ADDONJS"] = "";
+ $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
+ if (!empty($meta_addon_js)) {
+ $addonJs .= '';
+ }
+ //价格js
+ if ($meta_ct_page_price == "yes") {
+ $addonJs .= '';
+ }
- //两种设备分别调用两种模板 ,静态化
- switch ($device) {
- case 'mobile':
- //获取移动优先的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
- $template = $this->load->view($template_path, $data, true);
- $html_path_ext = '-mobile.htm';
- } else {
- return false;
- }
- break;
- case 'pc':
- //获取PC的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
- $template = $this->load->view($template_path . '-pc', $data, true);
- $html_path_ext = '-pc.htm';
- } else {
- return false;
- }
- break;
- default:
- }
+ //列表js
+ if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) {
+ $addonJs .= '';
+ }
- //生成静态文件
- $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
- $html_path = str_replace("\\", "/", $html_path);
- if (substr($html_path, -1, 1) == '/') {
- $html_path = $html_path . 'index.htm';
- }
- $html_path .= $html_path_ext;
- create_folder_by_path(dirname($html_path));
- file_put_contents($html_path, $template, LOCK_EX);
- }
- #endregion
-
- }
-
- /**
- * 上海站
- */
- public function make_www_cache_sh($information)
- {
- $data = array();
-
- #region 公用数据
- //$apiurl = "http://202.103.68.104:61/info.php"; //本地测试
- $apiurl = "https://ct.mycht.cn/info.php"; //网前
-
- //先准备数据,采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
- $data["TITLE"] = $information->ic_seo_title;
- $data["DESCRIPTION"] = $information->ic_seo_description;
- $data["KEYWORDS"] = $information->ic_seo_keywords;
- $data["CANONICAL"] = $this->config->item('site_url') . $information->ic_url;
- $meta_ct_page_type = "";
- $meta_ct_page_type = get_meta($information->ic_id, 'meta_ct_page_type'); //页面类型
- $meta_product_code = get_meta($information->ic_id, 'meta_product_code'); //绑定的产品编号
- $template_path = 'mobile_first/' . $this->config->item('site_code'); //模板位置
-
- //面包屑
- $crumb = "";
- $crumb_data = $this->Information_model->get_path_exclude_ct($information->is_id, $information->is_path);
- if (count($crumb_data) > 0) { //至少有一个父类面包屑才显示
- $crumb = "";
- }
- $data["crumb"] = $crumb;
-
- //作者字符串,信息页或者城市天气页加载 2022-7-26
- $str_author = "";
- $author = $this->Operator_model->get_author_nikename($information->ic_author);
- if ((empty($meta_product_code) && !($meta_ct_page_type !== false && $meta_ct_page_type != "")) || $meta_ct_page_type == "weatherpage") {
- $OPI_FirstName = !empty($author) ? $author->OPI_FirstName : 'author nickname';
- $str_author = 'Written by ' . $OPI_FirstName . ' Updated ' . date("M. j, Y", strtotime($information->ic_datetime)) . '
';
- }
+ //天气
+ if (in_array($meta_ct_page_type, array('weatherpage'))) {
+ $addonJs .= '';
+ }
+ //页面传递参数
+ $passParam = "";
+ if (in_array($meta_ct_page_type, array("daytripindex", "tourindex", "attractionindex", "weatherpage"))) { //一日游和线路列表
+ //产品首页
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+
+ if (in_array($meta_ct_page_type, array("attractionindex"))) {
+ //旧信息id,景点等信息类
+ $passParam .= '';
+ } else {
+ //城市名称,产品类用
+ $passParam .= '';
+ }
+
+ //加信息平台的is_id
+ $passParam .= '';
+ }
- /* 详细内容 */
- $ic_content = $information->ic_content;
+ //产品详细页
+ $productType = "";
+ $productCode = "";
+ if ($meta_ct_page_type == "daytripdetail") {
+ //一日游
+ if (!empty($meta_ct_page_type)) {
+ $productType = $meta_ct_page_type;
+ }
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+ if (!empty($meta_ct_page_value)) {
+ $productCode = $meta_ct_page_value;
+ }
+ $addonJs .= '';
+ //$addonJs .= '';
+ $data["ADDONCSS"] .= '';
+ }
+ if ($meta_ct_page_type == "tourdetail") {
+ //线路
+ $productType = $meta_ct_page_type;
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+ if (!empty($meta_ct_page_value)) {
+ $productCode = $meta_ct_page_value;
+ }
- /** 替换H1加面包屑,加作者 */
- $ic_content = preg_replace('/(.*)<\/h1>/i', $crumb . "\r\n" . '$1
' . "\r\n" . $str_author . "\r\n", $ic_content, 1);
+ //获取cli_sn
+ $tourdata = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getCliSn/?param=" . $productCode));
+ $data["clisn"] = $tourdata->clisn;
- //图片加延迟
- $ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.shanghaihighlights.com/image/grey.gif');
+ //调取模板
+ $dataform["TourCode"] = $productCode;
+ $dataform["CLI_SN"] = $tourdata->clisn;
+ $dataform["TourName"] = $information->ic_title;
- $ic_content = $this->html_optimize_lib->set_image_size($ic_content);
+ }
+ //游船详细页
+ if ($meta_ct_page_type == "cruisedetails") {
+ $productType = $meta_ct_page_type;
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+ if (!empty($meta_ct_page_value)) {
+ $productCode = $meta_ct_page_value;
+ }
+ $dataCruise["shipname"] = $productCode;
+ $template_curisedetails = $this->load->view($template_path . '-cruisedetails-form', $dataCruise, true);
+ $data["template_curisedetails"] = $template_curisedetails;
+ }
- //非产品页面
- $data["PRODUCTJS"] = "";
- $data["ISPRODUCT"] = "no"; //判断是否是产品页
- $data["addthis_widget"] = "";
- $data["FloatIcon"] = ""; //浮动图标替代addthis
- $arrExitUrl = array("/", "/culture", "/guide", "/tour", "/citytour", "/daytrip", "/asia-tour", "/china-trains");
+ //表单页
+ if (in_array($meta_ct_page_type, array("customize", "contactus", "pagewithform", "tourdetail"))) {
+ $productType = $meta_ct_page_type;
+ $addonJs .= '';
+ $data["ADDONCSS"] .= '';
+ }
- if (empty(get_meta($information->ic_id, 'meta_product_code')) || in_array($information->ic_url, $arrExitUrl)) {
- $data["FloatIcon"] = "";
+ $data["productType"] = $productType;
+ $data["productCode"] = $productCode;
+
+ //页面添加的元素
+ $data["ADDONJS"] = $addonJs;
+ $data["passParam"] = $passParam;
+
+ #endregion
+
+ #region 移动端和PC端差别处理区域
+ $arrDevice = array("mobile", "pc");
+ foreach ($arrDevice as $device) {
+ //顶部全屏大图
+ $data["TOPBANNER"] = "";
+ $ImgText = ""; //图文字
+ $meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
+ $meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text');
+ if ($device == 'mobile') { //移动端读取移动大图
+ $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ $bannerImg = '
';
+ if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
+ $ImgText = '';
+ } else if (!empty($meta_addon_picture_text)) {
+ $ImgText = '' . $meta_addon_picture_text . '
';
+ }
+ } else {
+ $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
+ $bannerImg = '
';
+ if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
+ $ImgText = '';
+ } else if (!empty($meta_addon_picture_text)) {
+ $ImgText = '' . $meta_addon_picture_text . '
';
+ }
+ }
+
+ // 搜索框
+ $template_TrainSearch = "";
+ if ($information->ic_url == "/china-trains/hometest" || $information->ic_url == "/china-trains") {
+ //火车票首页
+ $template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
+ $ImgText = "";
+ //火车票移动端去掉头部图片,保证搜索框CLS
+ if ($device == 'mobile') {
+ $meta_addon_picture = "";
+ $data["TOPBANNER"] = '
' . $template_TrainSearch . '
';
+ }
+ } else if ($information->ic_url == "/china-flights") {
+ //机票首页
+ $template_TrainSearch = $this->load->view($template_path . '-flight-index', null, true);
+ $ImgText = "";
+ //飞机票移动端去掉头部图片,保证搜索框CLS
+ if ($device == 'mobile') {
+ $meta_addon_picture = "";
+ $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
+ }
+ }
+
+ if (!empty($meta_addon_picture)) {
+ if (!empty($meta_addon_picture_url)) {
+ $data["TOPBANNER"] = '';
} else {
- $data["ISPRODUCT"] = "yes";
- }
+ $data["TOPBANNER"] = '' . $bannerImg . $ImgText . $template_TrainSearch . '
';
+ }
+ }
+
+ if ($meta_ct_page_type == "tourdetail") {
+ $dataform['device'] = $device;
+ $template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
+ $data["template_form_tourqi"] = $template_form_tourqi; //表单模板字符串
+ }
+
+ //两种设备分别调用两种模板 ,静态化
+ switch ($device) {
+ case 'mobile':
+ //获取移动优先的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
+ $template = $this->load->view($template_path, $data, true);
+ $html_path_ext = '-mobile.htm';
+ } else {
+ return false;
+ }
+ break;
+ case 'pc':
+ //获取PC的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
+ $template = $this->load->view($template_path . '-pc', $data, true);
+ $html_path_ext = '-pc.htm';
+ } else {
+ return false;
+ }
+ break;
+ default:
+ }
+
+ //生成静态文件
+ $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
+ $html_path = str_replace("\\", "/", $html_path);
+ if (substr($html_path, -1, 1) == '/') {
+ $html_path = $html_path . 'index.htm';
+ }
+ $html_path .= $html_path_ext;
+ create_folder_by_path(dirname($html_path));
+ file_put_contents($html_path, $template, LOCK_EX);
+ }
+ #endregion
+
+ }
+
+ /**
+ * 上海站
+ */
+ public function make_www_cache_sh($information)
+ {
+ $data = array();
+
+ #region 公用数据
+ //$apiurl = "http://202.103.68.104:61/info.php"; //本地测试
+ $apiurl = "https://ct.mycht.cn/info.php"; //网前
+
+ //先准备数据,采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
+ $data["TITLE"] = $information->ic_seo_title;
+ $data["DESCRIPTION"] = $information->ic_seo_description;
+ $data["KEYWORDS"] = $information->ic_seo_keywords;
+ $data["CANONICAL"] = $this->config->item('site_url') . $information->ic_url;
+ $meta_ct_page_type = "";
+ $meta_ct_page_type = get_meta($information->ic_id, 'meta_ct_page_type'); //页面类型
+ $meta_product_code = get_meta($information->ic_id, 'meta_product_code'); //绑定的产品编号
+ $template_path = 'mobile_first/' . $this->config->item('site_code'); //模板位置
+
+ //面包屑
+ $crumb = "";
+ $crumb_data = $this->Information_model->get_path_exclude_ct($information->is_id, $information->is_path);
+ if (count($crumb_data) > 0) { //至少有一个父类面包屑才显示
+ $crumb = "";
+ }
+ $data["crumb"] = $crumb;
+
+ //作者字符串,信息页或者城市天气页加载 2022-7-26
+ $str_author = "";
+ $author = $this->Operator_model->get_author_nikename($information->ic_author);
+ if ((empty($meta_product_code) && !($meta_ct_page_type !== false && $meta_ct_page_type != "")) || $meta_ct_page_type == "weatherpage") {
+ $OPI_FirstName = !empty($author) ? $author->OPI_FirstName : 'author nickname';
+ $str_author = 'Written by ' . $OPI_FirstName . ' Updated ' . date("M. j, Y", strtotime($information->ic_datetime)) . '
';
+ }
- //顶部视频
- $data["TOPVIDEO"] = "";
- $meta_news_video = get_meta($information->ic_id, 'meta_news_video');
- $meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
- if (!empty($meta_news_video) && !empty($meta_video_picture)) {
- $data["TOPVIDEO"] = '';
- }
- //主样式表,内联模式
- //$apiweb="http://202.103.68.104:81"; //本地测试
- $apiweb = "https://data.shanghaihighlights.com";
- $cssUrl = $apiweb . "/css/css3/base.css?v=" . time();
- $main_css_string = compress_css(GET_HTTP($cssUrl));
- $data["MAINCSS"] = '';
-
- //额外样式
- $data["ADDONCSS"] = "";
- $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
- if (!empty($meta_addon_css)) {
- //引用方式
- //$data["ADDONCSS"]= '';
- //内联方式
- $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
- $data["ADDONCSS"] = '';
- }
- //社媒分享图片
- $data["OGIMAGE"] = "";
- if (!empty($information->ic_photo)) {
- if (strpos($information->ic_photo, "shanghaihighlights.com") != false) {
- $full_ic_photo = $information->ic_photo;
- } else {
- $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
- }
- $data["OGIMAGE"] = '';
- }
+ /* 详细内容 */
+ $ic_content = $information->ic_content;
- //结构化标签
- $data["ConstructionCode"] = "";
- $meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
- if (!empty($meta_construction_code)) {
- $data["ConstructionCode"] = $meta_construction_code;
- }
+ /** 替换H1加面包屑,加作者 */
+ $ic_content = preg_replace('/(.*)<\/h1>/i', $crumb . "\r\n" . '$1
' . "\r\n" . $str_author . "\r\n", $ic_content, 1);
- //总JS:为了方便以后js好维护,必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js,所以必须在这里进行判断
- $addBaseJs = false;
- $addonJs = "";
- $meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
+ //图片加延迟
+ $ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.shanghaihighlights.com/image/grey.gif');
- if ($meta_ct_page_price == "yes") {
- $addBaseJs = true;
- } else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
- $addBaseJs = true;
- }
+ $ic_content = $this->html_optimize_lib->set_image_size($ic_content);
- if ($addBaseJs) {
- $addonJs = '';
- }
- /// ----- 总JS判断完成-----
- //额外js
- $data["ADDONJS"] = "";
- $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
- if (!empty($meta_addon_js)) {
- $addonJs .= '';
- }
- //价格js
- if ($meta_ct_page_price == "yes") {
- $addonJs .= '';
- }
- //列表js
- if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) {
- $addonJs .= '';
- }
+ //非产品页面
+ $data["PRODUCTJS"] = "";
+ $data["ISPRODUCT"] = "no"; //判断是否是产品页
+ $data["addthis_widget"] = "";
+ $data["FloatIcon"] = ""; //浮动图标替代addthis
+ $arrExitUrl = array("/", "/culture", "/guide", "/tour", "/citytour", "/daytrip", "/asia-tour", "/china-trains");
- //天气
- if (in_array($meta_ct_page_type, array('weatherpage'))) {
- $addonJs .= '';
- }
+ if (empty(get_meta($information->ic_id, 'meta_product_code')) || in_array($information->ic_url, $arrExitUrl)) {
+ $data["FloatIcon"] = "";
+ } else {
+ $data["ISPRODUCT"] = "yes";
+ }
- //页面传递参数
- $passParam = "";
- if (in_array($meta_ct_page_type, array("daytripindex", "tourindex", "attractionindex", "weatherpage"))) { //一日游和线路列表
- //产品首页
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
-
- if (in_array($meta_ct_page_type, array("attractionindex"))) {
- //旧信息id,景点等信息类
- $passParam .= '';
- } else {
- //城市名称,产品类用
- $passParam .= '';
- }
+ //顶部视频
+ $data["TOPVIDEO"] = "";
+ $meta_news_video = get_meta($information->ic_id, 'meta_news_video');
+ $meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
+ if (!empty($meta_news_video) && !empty($meta_video_picture)) {
+ $data["TOPVIDEO"] = '
';
+ }
- //加信息平台的is_id
- $passParam .= '';
- }
+ //主样式表,内联模式
+ //$apiweb="http://202.103.68.104:81"; //本地测试
+ $apiweb = "https://data.shanghaihighlights.com";
+ $cssUrl = $apiweb . "/css/css3/base.css?v=" . time();
+ $main_css_string = compress_css(GET_HTTP($cssUrl));
+ $data["MAINCSS"] = '';
+
+ //额外样式
+ $data["ADDONCSS"] = "";
+ $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
+ if (!empty($meta_addon_css)) {
+ //引用方式
+ //$data["ADDONCSS"]= '';
+ //内联方式
+ $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
+ $data["ADDONCSS"] = '';
+ }
+ //社媒分享图片
+ $data["OGIMAGE"] = "";
+ if (!empty($information->ic_photo)) {
+ if (strpos($information->ic_photo, "shanghaihighlights.com") != false) {
+ $full_ic_photo = $information->ic_photo;
+ } else {
+ $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
+ }
+ $data["OGIMAGE"] = '';
+ }
- //产品详细页
- $productType = "";
- $productCode = "";
- if ($meta_ct_page_type == "daytripdetail") {
- //一日游
- if (!empty($meta_ct_page_type)) {
- $productType = $meta_ct_page_type;
- }
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
- if (!empty($meta_ct_page_value)) {
- $productCode = $meta_ct_page_value;
- }
- $addonJs .= '';
- //$addonJs .= '';
- $data["ADDONCSS"] .= '';
-
- //一日游表单的替换
- $DayTripData["productCode"] = $productCode;
- $template_form_daydetail = $this->load->view($template_path . '-daydetail-form', $DayTripData, true); //模板内容
- //使用simple_html_dom_lib库来进行表单添加
- $ic_content = $this->html_optimize_lib->add_htmlcode($ic_content, "#maincontent", $template_form_daydetail);
- }
- if ($meta_ct_page_type == "tourdetail") {
- //线路
- $productType = $meta_ct_page_type;
- $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
- if (!empty($meta_ct_page_value)) {
- $productCode = $meta_ct_page_value;
- }
+ //结构化标签
+ $data["ConstructionCode"] = "";
+ $meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
+ if (!empty($meta_construction_code)) {
+ $data["ConstructionCode"] = $meta_construction_code;
+ }
- //获取cli_sn
- $tourdata = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getCliSn/?param=" . $productCode));
- $data["clisn"] = $tourdata->clisn;
+ //总JS:为了方便以后js好维护,必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js,所以必须在这里进行判断
+ $addBaseJs = false;
+ $addonJs = "";
+ $meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
- //调取模板
- $dataform["TourCode"] = $productCode;
- $dataform["CLI_SN"] = $tourdata->clisn;
- $dataform["TourName"] = $information->ic_title;
- $template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
- $data["template_form_tourqi"] = $template_form_tourqi; //表单模板字符串
+ if ($meta_ct_page_price == "yes") {
+ $addBaseJs = true;
+ } else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
+ $addBaseJs = true;
+ }
- }
+ if ($addBaseJs) {
+ $addonJs = '';
+ }
+ /// ----- 总JS判断完成-----
+ //额外js
+ $data["ADDONJS"] = "";
+ $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
+ if (!empty($meta_addon_js)) {
+ $addonJs .= '';
+ }
+ //价格js
+ if ($meta_ct_page_price == "yes") {
+ $addonJs .= '';
+ }
- //表单页
- if (in_array($meta_ct_page_type, array("customize", "contactus", "pagewithform", "tourdetail"))) {
- $productType = $meta_ct_page_type;
- $addonJs .= '';
- $data["ADDONCSS"] .= '';
- }
+ //列表js
+ if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) {
+ $addonJs .= '';
+ }
- if ($meta_ct_page_type == "daytripform") {
- $productType = $meta_ct_page_type;
- $addonJs .= '';
- $data["ADDONCSS"] .= '';
- }
+ //天气
+ if (in_array($meta_ct_page_type, array('weatherpage'))) {
+ $addonJs .= '';
+ }
- $data["productType"] = $productType;
- $data["productCode"] = $productCode;
-
- //页面添加的元素
- $data["ADDONJS"] = $addonJs;
- $data["passParam"] = $passParam;
-
- //页面详细内容放最后,这样上面都可以进行内容的替换,比如一日游表单
- $data["CUSTOMCONENT"] = $ic_content;
-
- #endregion
-
- #region 移动端和PC端差别处理区域
- $arrDevice = array("mobile", "pc");
- foreach ($arrDevice as $device) {
- //顶部全屏大图
- $data["TOPBANNER"] = "";
- $ImgText = ""; //图文字
- $meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
- $meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text');
- if ($device == 'mobile') { //移动端读取移动大图
- $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
- $bannerImg = '
';
- if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
- $ImgText = '';
- } else if (!empty($meta_addon_picture_text)) {
- $ImgText = '' . $meta_addon_picture_text . '
';
- }
- } else {
- $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
- $bannerImg = '
';
- if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
- $ImgText = '';
- } else if (!empty($meta_addon_picture_text)) {
- $ImgText = '' . $meta_addon_picture_text . '
';
- }
- }
+ //页面传递参数
+ $passParam = "";
+ if (in_array($meta_ct_page_type, array("daytripindex", "tourindex", "attractionindex", "weatherpage"))) { //一日游和线路列表
+ //产品首页
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+
+ if (in_array($meta_ct_page_type, array("attractionindex"))) {
+ //旧信息id,景点等信息类
+ $passParam .= '';
+ } else {
+ //城市名称,产品类用
+ $passParam .= '';
+ }
+
+ //加信息平台的is_id
+ $passParam .= '';
+ }
- // 搜索框
- $template_TrainSearch = "";
- if ($information->ic_url == "/china-trains/hometest" || $information->ic_url == "/china-trains") {
- //火车票首页
- $template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
- $ImgText = "";
- //火车票移动端去掉头部图片,保证搜索框CLS
- if ($device == 'mobile') {
- $meta_addon_picture = "";
- $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
- }
- } else if ($information->ic_url == "/china-flights") {
- //机票首页
- $template_TrainSearch = $this->load->view($template_path . '-flight-index', null, true);
- $ImgText = "";
- //飞机票移动端去掉头部图片,保证搜索框CLS
- if ($device == 'mobile') {
- $meta_addon_picture = "";
- $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
- }
- }
+ //产品详细页
+ $productType = "";
+ $productCode = "";
+ if ($meta_ct_page_type == "daytripdetail") {
+ //一日游
+ if (!empty($meta_ct_page_type)) {
+ $productType = $meta_ct_page_type;
+ }
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+ if (!empty($meta_ct_page_value)) {
+ $productCode = $meta_ct_page_value;
+ }
+ $addonJs .= '';
+ //$addonJs .= '';
+ $data["ADDONCSS"] .= '';
+
+ //一日游表单的替换
+ $DayTripData["productCode"] = $productCode;
+ $template_form_daydetail = $this->load->view($template_path . '-daydetail-form', $DayTripData, true); //模板内容
+ //使用simple_html_dom_lib库来进行表单添加
+ $ic_content = $this->html_optimize_lib->add_htmlcode($ic_content, "#maincontent", $template_form_daydetail);
+ }
+ if ($meta_ct_page_type == "tourdetail") {
+ //线路
+ $productType = $meta_ct_page_type;
+ $meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
+ if (!empty($meta_ct_page_value)) {
+ $productCode = $meta_ct_page_value;
+ }
+
+ //获取cli_sn
+ $tourdata = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getCliSn/?param=" . $productCode));
+ $data["clisn"] = $tourdata->clisn;
+
+ //调取模板
+ $dataform["TourCode"] = $productCode;
+ $dataform["CLI_SN"] = $tourdata->clisn;
+ $dataform["TourName"] = $information->ic_title;
+ $template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
+ $data["template_form_tourqi"] = $template_form_tourqi; //表单模板字符串
- if (!empty($meta_addon_picture)) {
- if (!empty($meta_addon_picture_url)) {
- $data["TOPBANNER"] = '';
- } else {
- $data["TOPBANNER"] = '' . $bannerImg . $ImgText . $template_TrainSearch . '
';
- }
- }
+ }
- //两种设备分别调用两种模板 ,静态化
- switch ($device) {
- case 'mobile':
- //获取移动优先的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
- $template = $this->load->view($template_path, $data, true);
- $html_path_ext = '-mobile.htm';
- } else {
- return false;
- }
- break;
- case 'pc':
- //获取PC的模板,如果有的话
- $template_path = 'mobile_first/' . $this->config->item('site_code');
- if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
- $template = $this->load->view($template_path . '-pc', $data, true);
- $html_path_ext = '-pc.htm';
- } else {
- return false;
- }
- break;
- default:
- }
- //生成静态文件
- $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
- $html_path = str_replace("\\", "/", $html_path);
- if (substr($html_path, -1, 1) == '/') {
- $html_path = $html_path . 'index.htm';
- }
- $html_path .= $html_path_ext;
- create_folder_by_path(dirname($html_path));
- file_put_contents($html_path, $template, LOCK_EX);
- }
- #endregion
+ //表单页
+ if (in_array($meta_ct_page_type, array("customize", "contactus", "pagewithform", "tourdetail"))) {
+ $productType = $meta_ct_page_type;
+ $addonJs .= '';
+ $data["ADDONCSS"] .= '';
+ }
+ if ($meta_ct_page_type == "daytripform") {
+ $productType = $meta_ct_page_type;
+ $addonJs .= '';
+ $data["ADDONCSS"] .= '';
}
- //通过内容找到第一张图片
- public function set_photo_content($ic_photo, $ic_content)
- {
- if (empty($ic_photo)) {
- $images = get_image_url_by_source($ic_content);
- if (!empty($images) and !empty($images[1])) {
- return $images[1][0];
- }
+ $data["productType"] = $productType;
+ $data["productCode"] = $productCode;
+
+ //页面添加的元素
+ $data["ADDONJS"] = $addonJs;
+ $data["passParam"] = $passParam;
+
+ //页面详细内容放最后,这样上面都可以进行内容的替换,比如一日游表单
+ $data["CUSTOMCONENT"] = $ic_content;
+
+ #endregion
+
+ #region 移动端和PC端差别处理区域
+ $arrDevice = array("mobile", "pc");
+ foreach ($arrDevice as $device) {
+ //顶部全屏大图
+ $data["TOPBANNER"] = "";
+ $ImgText = ""; //图文字
+ $meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
+ $meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text');
+ if ($device == 'mobile') { //移动端读取移动大图
+ $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
+ $bannerImg = '
';
+ if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
+ $ImgText = '';
+ } else if (!empty($meta_addon_picture_text)) {
+ $ImgText = '' . $meta_addon_picture_text . '
';
+ }
+ } else {
+ $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
+ $bannerImg = '
';
+ if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
+ $ImgText = '';
+ } else if (!empty($meta_addon_picture_text)) {
+ $ImgText = '' . $meta_addon_picture_text . '
';
+ }
+ }
+
+ // 搜索框
+ $template_TrainSearch = "";
+ if ($information->ic_url == "/china-trains/hometest" || $information->ic_url == "/china-trains") {
+ //火车票首页
+ $template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
+ $ImgText = "";
+ //火车票移动端去掉头部图片,保证搜索框CLS
+ if ($device == 'mobile') {
+ $meta_addon_picture = "";
+ $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
+ }
+ } else if ($information->ic_url == "/china-flights") {
+ //机票首页
+ $template_TrainSearch = $this->load->view($template_path . '-flight-index', null, true);
+ $ImgText = "";
+ //飞机票移动端去掉头部图片,保证搜索框CLS
+ if ($device == 'mobile') {
+ $meta_addon_picture = "";
+ $data["TOPBANNER"] = '' . $template_TrainSearch . '
';
+ }
+ }
+
+ if (!empty($meta_addon_picture)) {
+ if (!empty($meta_addon_picture_url)) {
+ $data["TOPBANNER"] = '';
} else {
- return $this->config->item('site_image_url') . $ic_photo;
- }
- return '';
+ $data["TOPBANNER"] = '' . $bannerImg . $ImgText . $template_TrainSearch . '
';
+ }
+ }
+
+ //两种设备分别调用两种模板 ,静态化
+ switch ($device) {
+ case 'mobile':
+ //获取移动优先的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
+ $template = $this->load->view($template_path, $data, true);
+ $html_path_ext = '-mobile.htm';
+ } else {
+ return false;
+ }
+ break;
+ case 'pc':
+ //获取PC的模板,如果有的话
+ $template_path = 'mobile_first/' . $this->config->item('site_code');
+ if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
+ $template = $this->load->view($template_path . '-pc', $data, true);
+ $html_path_ext = '-pc.htm';
+ } else {
+ return false;
+ }
+ break;
+ default:
+ }
+
+ //生成静态文件
+ $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
+ $html_path = str_replace("\\", "/", $html_path);
+ if (substr($html_path, -1, 1) == '/') {
+ $html_path = $html_path . 'index.htm';
+ }
+ $html_path .= $html_path_ext;
+ create_folder_by_path(dirname($html_path));
+ file_put_contents($html_path, $template, LOCK_EX);
}
-
- //根据推荐规则进行查询
- public function recommand_information_rule($information, $root_information, $recommand, &$exclude_ids)
- {
- $data = array();
- switch ($recommand->ir_rule) {
- case 'rule_same_node_keyword': //同节点关键词
- $keywords = explode(',', $recommand->ir_keyword);
- $data = $this->Information_model->search_by_words_2($root_information->is_path, $keywords, $exclude_ids);
- break;
- case 'rule_same_url_keyword': //同URL关键词
- $keywords = explode(',', $recommand->ir_keyword);
- $url = trim($information->ic_url);
- $url = substr($url, 0, strpos($url, '/', 1) + 1);
- $data = $this->Information_model->search_by_words($url, $keywords, $exclude_ids);
- break;
- case 'rule_same_node_random': //同节点随机
- $data = $this->Information_model->random(1, $root_information->is_path, $exclude_ids);
- break;
- case 'rule_this_node_random': //指定节点下随机
- $ir_pointer = $this->Information_model->Detail($recommand->ir_pointer_is_id, 'is_path');
- if (!empty($ir_pointer)) {
- $data = $this->Information_model->random(1, $ir_pointer->is_path, $exclude_ids);
- }
- break;
- case 'rule_range_random': //范围内随机,同读取备用节点
- break;
- case 'rule_show_tips': //显示广告
- $data = $this->recommends_and_tips_model->tips_detail($recommand->ir_pointer_it_id);
- return array($recommand->ir_name => $data);
- //break;
- case 'rule_no_show': //不显示
- return array($recommand->ir_name => false);
- //break;
- default: //'rule_parent'://继承上级规则则留空,程序会循环一遍分组的规则
- return false;
- }
- //读取备用节点
- if (empty($data) && !empty($recommand->ir_urls)) { //查不到信息并且备选urls不为空,则随机选一条
- // $url_array = explode("\n", $recommand->ir_urls);
- // $data = $this->Information_model->Detail(trim($url_array[rand(0, count($url_array) - 1)]));
- $url_array = explode("\n", $recommand->ir_urls);
- $data = $this->Information_model->random_range(1, $url_array, $exclude_ids);
- }
- if (!empty($data)) {
- $exclude_ids[] = $data->is_id;
- $data->desktop_photo = get_meta($data->ic_id, 'meta_addon_picture');
- $data->mobile_photo = get_meta($data->ic_id, 'meta_addon_picture_mobile');
- if (empty($data->mobile_photo)) {
- if (!empty($data->ic_photo)) {
- $data->mobile_photo = $this->config->item('site_image_url') . $data->ic_photo;
- } else {
- $data->mobile_photo = 'https://data.chinahighlights.com/image/travelguide/article/recommended-info-bottom-cover.jpg';
- }
- }
- }
+ #endregion
+
+ }
+
+ //通过内容找到第一张图片
+ public function set_photo_content($ic_photo, $ic_content)
+ {
+ if (empty($ic_photo)) {
+ $images = get_image_url_by_source($ic_content);
+ if (!empty($images) and !empty($images[1])) {
+ return $images[1][0];
+ }
+ } else {
+ return $this->config->item('site_image_url') . $ic_photo;
+ }
+ return '';
+ }
+
+ //根据推荐规则进行查询
+ public function recommand_information_rule($information, $root_information, $recommand, &$exclude_ids)
+ {
+ $data = array();
+ switch ($recommand->ir_rule) {
+ case 'rule_same_node_keyword': //同节点关键词
+ $keywords = explode(',', $recommand->ir_keyword);
+ $data = $this->Information_model->search_by_words_2($root_information->is_path, $keywords, $exclude_ids);
+ break;
+ case 'rule_same_url_keyword': //同URL关键词
+ $keywords = explode(',', $recommand->ir_keyword);
+ $url = trim($information->ic_url);
+ $url = substr($url, 0, strpos($url, '/', 1) + 1);
+ $data = $this->Information_model->search_by_words($url, $keywords, $exclude_ids);
+ break;
+ case 'rule_same_node_random': //同节点随机
+ $data = $this->Information_model->random(1, $root_information->is_path, $exclude_ids);
+ break;
+ case 'rule_this_node_random': //指定节点下随机
+ $ir_pointer = $this->Information_model->Detail($recommand->ir_pointer_is_id, 'is_path');
+ if (!empty($ir_pointer)) {
+ $data = $this->Information_model->random(1, $ir_pointer->is_path, $exclude_ids);
+ }
+ break;
+ case 'rule_range_random': //范围内随机,同读取备用节点
+ break;
+ case 'rule_show_tips': //显示广告
+ $data = $this->recommends_and_tips_model->tips_detail($recommand->ir_pointer_it_id);
return array($recommand->ir_name => $data);
+ //break;
+ case 'rule_no_show': //不显示
+ return array($recommand->ir_name => false);
+ //break;
+ default: //'rule_parent'://继承上级规则则留空,程序会循环一遍分组的规则
+ return false;
}
-
- //获取当前信息所有的推荐信息和广告内容
- public function recommand_information($information)
- {
- $data = array();
- $group_detail = $this->Information_model->get_detail_by_path($information->is_path, 0); //信息所属分组,根据分组进行不同推荐
- $group_recommands = $this->recommends_and_tips_model->recommends_list($group_detail->is_id); //节点下所有的推荐规则
- $root_detail = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
- $root_recommands = $this->recommends_and_tips_model->recommends_list($root_detail->is_id); //节点下所有的推荐规则
-
- $exclude_ids = array($information->is_id); //需要排除的is_id,防止通过页面显示相同内容,默认排除本身,每个推荐内容都需要排除已经推荐过的
- foreach ($root_recommands as $item) {
- if ($this->config->item('site_code') == 'ah') { //如果是AH的页面,取消重复检测
- $exclude_ids = array(0);
- }
- $result = $this->recommand_information_rule($information, $root_detail, $item, $exclude_ids);
- if (!empty($result)) {
- $data += $result;
- }
+ //读取备用节点
+ if (empty($data) && !empty($recommand->ir_urls)) { //查不到信息并且备选urls不为空,则随机选一条
+ // $url_array = explode("\n", $recommand->ir_urls);
+ // $data = $this->Information_model->Detail(trim($url_array[rand(0, count($url_array) - 1)]));
+ $url_array = explode("\n", $recommand->ir_urls);
+ $data = $this->Information_model->random_range(1, $url_array, $exclude_ids);
+ }
+ if (!empty($data)) {
+ $exclude_ids[] = $data->is_id;
+ $data->desktop_photo = get_meta($data->ic_id, 'meta_addon_picture');
+ $data->mobile_photo = get_meta($data->ic_id, 'meta_addon_picture_mobile');
+ if (empty($data->mobile_photo)) {
+ if (!empty($data->ic_photo)) {
+ $data->mobile_photo = $this->config->item('site_image_url') . $data->ic_photo;
+ } else {
+ $data->mobile_photo = 'https://data.chinahighlights.com/image/travelguide/article/recommended-info-bottom-cover.jpg';
}
+ }
+ }
+ return array($recommand->ir_name => $data);
+ }
+
+ //获取当前信息所有的推荐信息和广告内容
+ public function recommand_information($information)
+ {
+ $data = array();
+ $group_detail = $this->Information_model->get_detail_by_path($information->is_path, 0); //信息所属分组,根据分组进行不同推荐
+ $group_recommands = $this->recommends_and_tips_model->recommends_list($group_detail->is_id); //节点下所有的推荐规则
+ $root_detail = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
+ $root_recommands = $this->recommends_and_tips_model->recommends_list($root_detail->is_id); //节点下所有的推荐规则
+
+ $exclude_ids = array($information->is_id); //需要排除的is_id,防止通过页面显示相同内容,默认排除本身,每个推荐内容都需要排除已经推荐过的
+ foreach ($root_recommands as $item) {
+ if ($this->config->item('site_code') == 'ah') { //如果是AH的页面,取消重复检测
+ $exclude_ids = array(0);
+ }
+ $result = $this->recommand_information_rule($information, $root_detail, $item, $exclude_ids);
+ if (!empty($result)) {
+ $data += $result;
+ }
+ }
- foreach ($group_recommands as $item) {
- if ($this->config->item('site_code') == 'ah' or $this->config->item('site_code') == 'ch' or $this->config->item('site_code') == 'gh') { //如果是AH CH GH的页面,取消重复检测
- $exclude_ids = array(0);
- }
- if (empty($data[$item->ir_name])) {
- $result = $this->recommand_information_rule($information, $root_detail, $item, $exclude_ids);
- if (!empty($result)) {
- $data += $result;
- }
- }
- }
- //print_r($data);
- //log_message('error', 'exclude_ids: '.$information->ic_url.' '.implode(',',$exclude_ids));
- return $data;
- }
-
- public function call_mobile_template_NEXT($template_path, $is_id)
- {
- $data['detail'] = $this->Information_model->Detail($is_id);
- $data['type_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 0); //信息所属分组,根据分组进行不同推荐
- $data['root_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 1); //信息所属分类,获取信息顶级节点内容
-
- switch (strtolower($data['type_detail']->is_id)) {
- case 278008010: //Inspiration
- //随机获取两个同级节点内容
- $random_array = $this->Information_model->random(2, $data['root_detail']->is_path, array($data['detail']->is_id));
- if (!empty($random_array[0])) {
- $data['info_howtoplan'] = $random_array[0];
- $data['info_howtoplan_root'] = $data['root_detail'];
- $data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
- }
- if (!empty($random_array[1])) {
- $data['info_besttime'] = $random_array[1];
- $data['info_besttime_root'] = $data['root_detail'];
- $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
- }
- //漏斗作用的页面,随机挑选一篇
- $random_array = array(
- '/travelguide/china-facts.htm',
- '/travelguide/article-top-china-tourist-destination.htm',
- '/travelguide/most-beautiful-places.htm',
- '/weather/china-best-times.htm',
- '/travelguide/article-10-movies-to-watch.htm',
- '/travelguide/article-culture-shock-in-china.htm',
- '/travelguide/article-what-chinese-eat-for-breakfast.htm',
- '/travelguide/china-top-10-attractions.htm',
- '/travelguide/chinese-food/eight-chinese-dishes.htm',
- '/travelguide/china-travel-reopen-restrictions.htm',
- );
- $data['info_topthings'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
- if (!empty($data['info_topthings'])) {
- $data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1);
- $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
- }
- //文化板块的页面,随机挑选一篇
- $random_array = array(
- '/travelguide/chinese-zodiac/',
- '/travelguide/culture/china-arts-crafts.htm',
- '/beijing/forbidden-city/',
- '/travelguide/culture/traditionalmedichine.htm',
- '/travelguide/chinese-tea/',
- '/travelguide/kungfu/',
- '/travelguide/culture/china-history.htm',
- '/travelguide/chinese-food/',
- '/travelguide/chinese-language/',
- );
- $data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
- if (!empty($data['info_hotel'])) {
- $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);
- $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
- }
- break;
- case 278008012: //'planing-1(guide)':
- case 278008013: //'planning-2 (decision tips)':
- case 278008011: //'destination': //url的第一段表示地区,根据第一段来搜索相关数据如/beijing/ 而不是根据is_parent_id因为可能信息和线路是在不同的分类下
- $destination_url = trim($data['detail']->ic_url);
- $destination_url = substr($destination_url, 0, strpos($destination_url, '/', 1) + 1);
- //how to plan
- $data['info_howtoplan'] = $this->Information_model->search_by_words($destination_url, array('how', 'plan'), array($data['detail']->is_id));
- if (empty($data['info_howtoplan'])) { //找不到对应信息则显示备用
- $data['info_howtoplan'] = $this->Information_model->Detail('/travelguide/plan-first-trip.htm');
- }
- $data['info_howtoplan_root'] = $this->Information_model->get_detail_by_path($data['info_howtoplan']->is_path, 1); //信息所属分类,获取信息顶级节点内容
- if (!empty($data['info_howtoplan'])) {
- $data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
- }
- //best time to visit
- $data['info_besttime'] = $this->Information_model->search_by_words($destination_url, array('best', 'time'), array($data['detail']->is_id));
- if (empty($data['info_besttime'])) {
- $data['info_besttime'] = $this->Information_model->Detail('/weather/china-best-times.htm');
- }
- $data['info_besttime_root'] = $this->Information_model->get_detail_by_path($data['info_besttime']->is_path, 1); //信息所属分类,获取信息顶级节点内容
- if (!empty($data['info_besttime'])) {
- $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
- }
- //top things to do
- $data['info_topthings'] = $this->Information_model->search_by_words($destination_url, array('top', 'things'), array($data['detail']->is_id));
- if (empty($data['info_topthings'])) {
- $data['info_topthings'] = $this->Information_model->Detail('/travelguide/article-top-china-tourist-destination.htm');
- }
- $data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1); //信息所属分类,获取信息顶级节点内容
- if (!empty($data['info_topthings'])) {
- $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
- }
- //第四篇,随机推荐下方url
- $random_array = array(
- '/feedback/',
- '/travelguide/how-chinahighlights-selects-your-hotel.htm',
- '/travelguide/article-private-tour-vs-group-tour.htm',
- '/aboutus/who-recommended.htm',
- '/aboutus/no-shops.htm',
- '/aboutus/company-history.htm',
- );
- $data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
- if (!empty($data['info_hotel'])) {
- $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);
- $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
- }
- break;
- default:
- return '';
+ foreach ($group_recommands as $item) {
+ if ($this->config->item('site_code') == 'ah' or $this->config->item('site_code') == 'ch' or $this->config->item('site_code') == 'gh') { //如果是AH CH GH的页面,取消重复检测
+ $exclude_ids = array(0);
+ }
+ if (empty($data[$item->ir_name])) {
+ $result = $this->recommand_information_rule($information, $root_detail, $item, $exclude_ids);
+ if (!empty($result)) {
+ $data += $result;
}
-
- return $this->load->view($template_path . '-next', $data, true);
- }
-
- //更新静态文件
- //不用参数提交的原因是可能url带有特殊字符,CI会报错
- public function update_cache($static_html_url = false, $delete_only = false)
- {
- $url = !empty($static_html_url) ? $static_html_url : $this->input->post('cache_url');
- $url = str_replace($this->config->item('site_url'), '', $url);
- $original_url = $url; //原始链接
- $delete_only = !empty($delete_only) ? $delete_only : $this->input->get_post('delete_only');
-
- switch ($this->config->item('site_code')) {
- case 'cht':
- $search_list = $this->Information_model->search_url($url);
- $amp_request = false;
- foreach ($search_list as $key => $req_url) {
- $meta_amp_status = get_meta($req_url->ic_id, 'AMP_STATUS');
- if ($meta_amp_status) {
- $amp_request = true;
- }
- }
- if ($amp_request) {
- $url = 'http://169.54.167.189:22224/ampreq' . $url;
- } else {
- $url = 'http://169.54.167.189:22224' . $url;
- }
- break;
- case 'ah':
- if ($delete_only === true) {
- $url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url;
- } else { // static_html_optimize=comeon 启用静态化压缩和js、css延迟加载
- $url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon';
- }
- break;
-
- case 'gm':
- //GET_HTTP("http://148.251.35.42:3300/create-cache/?url=" . urlencode($url)); //请求nodejs静态化更新页面,删除缓存,因为部分页面没有进入信息平台
- //if ($delete_only) {
- // $url = "http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url);
- //} else {
- //先删除再生成,部分页面没有在信息平台中
- GET_HTTP("http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url));
- $url = "http://144.76.185.44:8029/gm.php/information/detail/?static_html_url=" . $url;
- //}
- break;
-
- //国际站
- case 'vac':
- case 'vc':
- case 'it':
- case 'ru':
- case 'jp':
- $information = $this->Information_model->Detail($url);
- $meta_pc_amp = @get_meta($information->ic_id, 'AMP_BODY_PC_STATUS');
- if ($delete_only) {
- //只删除操作,在url修改和不发布信息的时候使用
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
- } else {
- $tmp = $url;
- //判断是否是更新信息
- // 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
- if (!empty($information->ic_content) || !empty($information->ic_summary) || $meta_pc_amp == 'yes') {
- $url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
- } else {
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url;
- //$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
- }
- if (isset($information->ic_type) && $information->ic_type == 'product') {
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
- }
- //int return direct
- $cache_url = $this->input->post('cache_url');
- if ($url && !$cache_url) {
- /*
- ignore_user_abort(true);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_TIMEOUT, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
- curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_exec($ch);
- curl_close($ch);
- */
- $data['async_update'] = $url;
- $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url);
- //如果是外部调用就返回结果,内部就不返回了
- if ($cache_url) {
- echo json_encode($data);
- }
- return $data;
- }
- }
- break;
- //国际站 - GH
- case 'gh_vac':
- case 'gh_vc':
- case 'gh_it':
- case 'gh_ru':
- case 'gh_jp':
- $information = $this->Information_model->Detail($url);
- $meta_pc_amp = @get_meta($information->ic_id, 'AMP_BODY_PC_STATUS');
- if ($delete_only) {
- //只删除操作,在url修改和不发布信息的时候使用
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
- } else {
- $tmp = $url;
- //判断是否是更新信息
- // 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
- if (!empty($information->ic_content) || !empty($information->ic_summary) || $meta_pc_amp == 'yes') {
- $url = $this->config->item('site_url') . '/index.php/gh/info/detail/?static_html_url=' . $url;
- } else {
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url;
- //$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
- }
- if (isset($information->ic_type) && $information->ic_type == 'product') {
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
- }
-
- // GH国际 不发布的时候删除缓存
- if (!$information->ic_status) {
- $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $tmp;
- }
-
- //int return direct
- $cache_url = $this->input->post('cache_url');
- if ($url && !$cache_url) {
- /*
- ignore_user_abort(true);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_TIMEOUT, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
- curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_exec($ch);
- curl_close($ch);
- */
- $data['async_update'] = $url;
- $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url);
- //如果是外部调用就返回结果,内部就不返回了
- if ($cache_url) {
- echo json_encode($data);
- }
- return $data;
- }
- }
- break;
-
- case 'ct': //子站点使用
- $url = 'http://50.97.246.187:22223' . $url;
- break;
- case 'sht':
- case 'gl':
- case 'mbj':
- case 'yz':
- $url = $this->config->item('site_url') . $url . '@cache@refresh';
- break;
- default:
- return false;
- //break;
+ }
+ }
+ //print_r($data);
+ //log_message('error', 'exclude_ids: '.$information->ic_url.' '.implode(',',$exclude_ids));
+ return $data;
+ }
+
+ public function call_mobile_template_NEXT($template_path, $is_id)
+ {
+ $data['detail'] = $this->Information_model->Detail($is_id);
+ $data['type_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 0); //信息所属分组,根据分组进行不同推荐
+ $data['root_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 1); //信息所属分类,获取信息顶级节点内容
+
+ switch (strtolower($data['type_detail']->is_id)) {
+ case 278008010: //Inspiration
+ //随机获取两个同级节点内容
+ $random_array = $this->Information_model->random(2, $data['root_detail']->is_path, array($data['detail']->is_id));
+ if (!empty($random_array[0])) {
+ $data['info_howtoplan'] = $random_array[0];
+ $data['info_howtoplan_root'] = $data['root_detail'];
+ $data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
+ }
+ if (!empty($random_array[1])) {
+ $data['info_besttime'] = $random_array[1];
+ $data['info_besttime_root'] = $data['root_detail'];
+ $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
+ }
+ //漏斗作用的页面,随机挑选一篇
+ $random_array = array(
+ '/travelguide/china-facts.htm',
+ '/travelguide/article-top-china-tourist-destination.htm',
+ '/travelguide/most-beautiful-places.htm',
+ '/weather/china-best-times.htm',
+ '/travelguide/article-10-movies-to-watch.htm',
+ '/travelguide/article-culture-shock-in-china.htm',
+ '/travelguide/article-what-chinese-eat-for-breakfast.htm',
+ '/travelguide/china-top-10-attractions.htm',
+ '/travelguide/chinese-food/eight-chinese-dishes.htm',
+ '/travelguide/china-travel-reopen-restrictions.htm',
+ );
+ $data['info_topthings'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
+ if (!empty($data['info_topthings'])) {
+ $data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1);
+ $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
+ }
+ //文化板块的页面,随机挑选一篇
+ $random_array = array(
+ '/travelguide/chinese-zodiac/',
+ '/travelguide/culture/china-arts-crafts.htm',
+ '/beijing/forbidden-city/',
+ '/travelguide/culture/traditionalmedichine.htm',
+ '/travelguide/chinese-tea/',
+ '/travelguide/kungfu/',
+ '/travelguide/culture/china-history.htm',
+ '/travelguide/chinese-food/',
+ '/travelguide/chinese-language/',
+ );
+ $data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
+ if (!empty($data['info_hotel'])) {
+ $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);
+ $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
+ }
+ break;
+ case 278008012: //'planing-1(guide)':
+ case 278008013: //'planning-2 (decision tips)':
+ case 278008011: //'destination': //url的第一段表示地区,根据第一段来搜索相关数据如/beijing/ 而不是根据is_parent_id因为可能信息和线路是在不同的分类下
+ $destination_url = trim($data['detail']->ic_url);
+ $destination_url = substr($destination_url, 0, strpos($destination_url, '/', 1) + 1);
+ //how to plan
+ $data['info_howtoplan'] = $this->Information_model->search_by_words($destination_url, array('how', 'plan'), array($data['detail']->is_id));
+ if (empty($data['info_howtoplan'])) { //找不到对应信息则显示备用
+ $data['info_howtoplan'] = $this->Information_model->Detail('/travelguide/plan-first-trip.htm');
+ }
+ $data['info_howtoplan_root'] = $this->Information_model->get_detail_by_path($data['info_howtoplan']->is_path, 1); //信息所属分类,获取信息顶级节点内容
+ if (!empty($data['info_howtoplan'])) {
+ $data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
+ }
+ //best time to visit
+ $data['info_besttime'] = $this->Information_model->search_by_words($destination_url, array('best', 'time'), array($data['detail']->is_id));
+ if (empty($data['info_besttime'])) {
+ $data['info_besttime'] = $this->Information_model->Detail('/weather/china-best-times.htm');
+ }
+ $data['info_besttime_root'] = $this->Information_model->get_detail_by_path($data['info_besttime']->is_path, 1); //信息所属分类,获取信息顶级节点内容
+ if (!empty($data['info_besttime'])) {
+ $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
+ }
+ //top things to do
+ $data['info_topthings'] = $this->Information_model->search_by_words($destination_url, array('top', 'things'), array($data['detail']->is_id));
+ if (empty($data['info_topthings'])) {
+ $data['info_topthings'] = $this->Information_model->Detail('/travelguide/article-top-china-tourist-destination.htm');
+ }
+ $data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1); //信息所属分类,获取信息顶级节点内容
+ if (!empty($data['info_topthings'])) {
+ $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
+ }
+ //第四篇,随机推荐下方url
+ $random_array = array(
+ '/feedback/',
+ '/travelguide/how-chinahighlights-selects-your-hotel.htm',
+ '/travelguide/article-private-tour-vs-group-tour.htm',
+ '/aboutus/who-recommended.htm',
+ '/aboutus/no-shops.htm',
+ '/aboutus/company-history.htm',
+ );
+ $data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
+ if (!empty($data['info_hotel'])) {
+ $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);
+ $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
}
+ break;
+ default:
+ return '';
+ }
- $content = GET_HTTP($url);
- if ($content === false) {
- $data[] = array('name' => 'no', 'value' => sprintf($this->lang->line('update_cache_failed'), $url));
+ return $this->load->view($template_path . '-next', $data, true);
+ }
+
+ //更新静态文件
+ //不用参数提交的原因是可能url带有特殊字符,CI会报错
+ public function update_cache($static_html_url = false, $delete_only = false)
+ {
+ $url = !empty($static_html_url) ? $static_html_url : $this->input->post('cache_url');
+ $url = str_replace($this->config->item('site_url'), '', $url);
+ $original_url = $url; //原始链接
+ $delete_only = !empty($delete_only) ? $delete_only : $this->input->get_post('delete_only');
+
+ switch ($this->config->item('site_code')) {
+ case 'cht':
+ $search_list = $this->Information_model->search_url($url);
+ $amp_request = false;
+ foreach ($search_list as $key => $req_url) {
+ $meta_amp_status = get_meta($req_url->ic_id, 'AMP_STATUS');
+ if ($meta_amp_status) {
+ $amp_request = true;
+ }
+ }
+ if ($amp_request) {
+ $url = 'http://169.54.167.189:22224/ampreq' . $url;
} else {
- //手动更新的话,接着更新CDN缓存
- $msg = $this->lang->line('update_cache_success');
-
- if ($this->input->post('updatecdn') == 1) {
- $notice = $this->update_cdn();
- if ($notice == 200) {
- $msg .= $this->lang->line('update_cdn_success');
- } else {
- $msg .= $this->lang->line('update_cdn_failed') . '
' . $notice;
- }
- }
- $data[] = array('name' => 'ok', 'value' => $msg, 'url' => $url);
- }
- //如果是外部调用就返回结果,内部就不返回了
- if ($this->input->post('cache_url')) {
- echo json_encode($data);
- }
- return $data;
- }
-
- //更新CDN缓存
- public function update_cdn($static_html_url = false)
- {
- $flag = false; //false:不更新,true:更新
- $update_site = array('jp', 'ru'); //需要更新CDN的站点
- //需要更新的url
- $url = $static_html_url;
- if (empty($url)) {
- $url = $this->input->post('cache_url');
- }
-
- //如果传递进来的url是带有域名,则对域名进行判断
- $tempu = parse_url($url);
- if (isset($tempu['host'])) {
- $url = isset($tempu['path']) ? $tempu['path'] : '/';
- $pad = $tempu['host'];
- $flag = true;
- } //如果传递进来的url没有域名,则使用当前站点的信息进行判断
- else {
- $url = str_replace($this->config->item('site_url'), '', $url);
- $pad = str_replace('http://', '', $this->config->item('site_url'));
- if (in_array($this->config->item('site_code'), $update_site)) {
- $flag = true;
- }
+ $url = 'http://169.54.167.189:22224' . $url;
+ }
+ break;
+ case 'ah':
+ if ($delete_only === true) {
+ $url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url;
+ } else { // static_html_optimize=comeon 启用静态化压缩和js、css延迟加载
+ $url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon';
+ }
+ break;
+
+ case 'gm':
+ //GET_HTTP("http://148.251.35.42:3300/create-cache/?url=" . urlencode($url)); //请求nodejs静态化更新页面,删除缓存,因为部分页面没有进入信息平台
+ //if ($delete_only) {
+ // $url = "http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url);
+ //} else {
+ //先删除再生成,部分页面没有在信息平台中
+ GET_HTTP("http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url));
+ $url = "http://144.76.185.44:8029/gm.php/information/detail/?static_html_url=" . $url;
+ //}
+ break;
+
+ //国际站
+ case 'vac':
+ case 'vc':
+ case 'it':
+ case 'ru':
+ case 'jp':
+ $information = $this->Information_model->Detail($url);
+ $meta_pc_amp = @get_meta($information->ic_id, 'AMP_BODY_PC_STATUS');
+ if ($delete_only) {
+ //只删除操作,在url修改和不发布信息的时候使用
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
+ } else {
+ $tmp = $url;
+ //判断是否是更新信息
+ // 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
+ if (!empty($information->ic_content) || !empty($information->ic_summary) || $meta_pc_amp == 'yes') {
+ $url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
+ } else {
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url;
+ //$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
+ }
+ if (isset($information->ic_type) && $information->ic_type == 'product') {
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
+ }
+ //int return direct
+ $cache_url = $this->input->post('cache_url');
+ if ($url && !$cache_url) {
+ /*
+ ignore_user_abort(true);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 1);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
+ curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
+ curl_setopt($ch, CURLOPT_NOBODY, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_exec($ch);
+ curl_close($ch);
+ */
+ $data['async_update'] = $url;
+ $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url);
+ //如果是外部调用就返回结果,内部就不返回了
+ if ($cache_url) {
+ echo json_encode($data);
+ }
+ return $data;
+ }
+ }
+ break;
+ //国际站 - GH
+ case 'gh_vac':
+ case 'gh_vc':
+ case 'gh_it':
+ case 'gh_ru':
+ case 'gh_jp':
+ $information = $this->Information_model->Detail($url);
+ $meta_pc_amp = @get_meta($information->ic_id, 'AMP_BODY_PC_STATUS');
+ if ($delete_only) {
+ //只删除操作,在url修改和不发布信息的时候使用
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
+ } else {
+ $tmp = $url;
+ //判断是否是更新信息
+ // 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
+ if (!empty($information->ic_content) || !empty($information->ic_summary) || $meta_pc_amp == 'yes') {
+ $url = $this->config->item('site_url') . '/index.php/gh/info/detail/?static_html_url=' . $url;
+ } else {
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url;
+ //$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
+ }
+ if (isset($information->ic_type) && $information->ic_type == 'product') {
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
+ }
+
+ // GH国际 不发布的时候删除缓存
+ if (!$information->ic_status) {
+ $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $tmp;
+ }
+
+ //int return direct
+ $cache_url = $this->input->post('cache_url');
+ if ($url && !$cache_url) {
+ /*
+ ignore_user_abort(true);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 1);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
+ curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
+ curl_setopt($ch, CURLOPT_NOBODY, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_exec($ch);
+ curl_close($ch);
+ */
+ $data['async_update'] = $url;
+ $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url);
+ //如果是外部调用就返回结果,内部就不返回了
+ if ($cache_url) {
+ echo json_encode($data);
+ }
+ return $data;
+ }
+ }
+ break;
+
+ case 'ct': //子站点使用
+ $url = 'http://50.97.246.187:22223' . $url;
+ break;
+ case 'sht':
+ case 'gl':
+ case 'mbj':
+ case 'yz':
+ $url = $this->config->item('site_url') . $url . '@cache@refresh';
+ break;
+ default:
+ return false;
+ //break;
+ }
+ $content = GET_HTTP($url);
+ if ($content === false) {
+ $data[] = array('name' => 'no', 'value' => sprintf($this->lang->line('update_cache_failed'), $url));
+ } else {
+ //手动更新的话,接着更新CDN缓存
+ $msg = $this->lang->line('update_cache_success');
+
+ if ($this->input->post('updatecdn') == 1) {
+ $notice = $this->update_cdn();
+ if ($notice == 200) {
+ $msg .= $this->lang->line('update_cdn_success');
+ } else {
+ $msg .= $this->lang->line('update_cdn_failed') . '
' . $notice;
}
+ }
+ $data[] = array('name' => 'ok', 'value' => $msg, 'url' => $url);
+ }
+ //如果是外部调用就返回结果,内部就不返回了
+ if ($this->input->post('cache_url')) {
+ echo json_encode($data);
+ }
+ return $data;
+ }
+
+ //更新CDN缓存
+ public function update_cdn($static_html_url = false)
+ {
+ $flag = false; //false:不更新,true:更新
+ $update_site = array('jp', 'ru'); //需要更新CDN的站点
+ //需要更新的url
+ $url = $static_html_url;
+ if (empty($url)) {
+ $url = $this->input->post('cache_url');
+ }
- //默认更新成功,如果不成功,则返回错误提示信息
- $notice = 200;
- if ($flag) {
- $result = GET_HTTP('https://openapi.us.cdnetworks.com/purge/rest/doPurge?user=ycc@chinahighlights.com&pass=cXi2UbsTrw9Urv@&pad=' . $pad . '&type=item&path=' . $url . '&output=json');
- $result = json_decode($result, true);
- if ($result['resultCode'] != 200) {
- $notice = $result['notice'] . $result['details'];
- }
+ //如果传递进来的url是带有域名,则对域名进行判断
+ $tempu = parse_url($url);
+ if (isset($tempu['host'])) {
+ $url = isset($tempu['path']) ? $tempu['path'] : '/';
+ $pad = $tempu['host'];
+ $flag = true;
+ } //如果传递进来的url没有域名,则使用当前站点的信息进行判断
+ else {
+ $url = str_replace($this->config->item('site_url'), '', $url);
+ $pad = str_replace('http://', '', $this->config->item('site_url'));
+ if (in_array($this->config->item('site_code'), $update_site)) {
+ $flag = true;
+ }
- }
- return $notice;
- }
-
- //获取产品信息,提供给用户选择进行绑定
- public function get_products()
- {
- $HT_productType = $this->input->post('product_type');
- $HT_productName = $this->input->post('product_name');
- //产品类型
- switch ($HT_productType) {
- case 't':
- $data['productList'] = $this->Landscape_model->search_list($HT_productName);
- break;
- default:
- $data['productList'] = array();
- break;
- }
- $data['product_type'] = $HT_productType;
- $product_list_page = $this->load->view('bootstrap/information_select_product', $data, true);
- $data = array();
- $data[] = array('name' => 'ok', 'value' => $product_list_page);
- echo json_encode($data);
- return true;
- }
-
- //显示备份的内容
- public function backup_content($log_id)
- {
- $data['log_info'] = $this->Logs_model->read($log_id);
- if ($data['log_info']->log_action == 'backup_amp') {
- $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id, true);
- } else {
- $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id);
- }
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/information_backup_content');
- $this->load->view('bootstrap/footer');
- }
-
- //保存自定义配置
- public function save_meta()
- {
- $im_ic_id = $this->input->post('im_ic_id');
- $im_key = $this->input->post('im_key');
- $im_value = $this->input->post('im_value');
- if ($im_ic_id && $im_key && $im_value !== false) {
- $meta = $this->InfoMetas_model->get($im_ic_id, $im_key);
- if ($meta === false) {
- $this->InfoMetas_model->add($im_ic_id, $im_key, $im_value);
- } else {
- $this->InfoMetas_model->update($im_ic_id, $im_key, $im_value);
- }
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_save_success'));
- } else {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
- }
- echo json_encode($data);
- return true;
}
- //保存自定义配置
- public function delete_meta()
- {
- $im_ic_id = $this->input->post('im_ic_id');
- $im_key = $this->input->post('im_key');
- if ($im_ic_id && $im_key) {
+ //默认更新成功,如果不成功,则返回错误提示信息
+ $notice = 200;
+ if ($flag) {
+ $result = GET_HTTP('https://openapi.us.cdnetworks.com/purge/rest/doPurge?user=ycc@chinahighlights.com&pass=cXi2UbsTrw9Urv@&pad=' . $pad . '&type=item&path=' . $url . '&output=json');
+ $result = json_decode($result, true);
+ if ($result['resultCode'] != 200) {
+ $notice = $result['notice'] . $result['details'];
+ }
- $this->InfoMetas_model->delete($im_ic_id, $im_key);
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_delete_success'));
- } else {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
- }
- echo json_encode($data);
- return true;
}
+ return $notice;
+ }
+
+ //获取产品信息,提供给用户选择进行绑定
+ public function get_products()
+ {
+ $HT_productType = $this->input->post('product_type');
+ $HT_productName = $this->input->post('product_name');
+ //产品类型
+ switch ($HT_productType) {
+ case 't':
+ $data['productList'] = $this->Landscape_model->search_list($HT_productName);
+ break;
+ default:
+ $data['productList'] = array();
+ break;
+ }
+ $data['product_type'] = $HT_productType;
+ $product_list_page = $this->load->view('bootstrap/information_select_product', $data, true);
+ $data = array();
+ $data[] = array('name' => 'ok', 'value' => $product_list_page);
+ echo json_encode($data);
+ return true;
+ }
+
+ //显示备份的内容
+ public function backup_content($log_id)
+ {
+ $data['log_info'] = $this->Logs_model->read($log_id);
+ if ($data['log_info']->log_action == 'backup_amp') {
+ $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id, true);
+ } else {
+ $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id);
+ }
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/information_backup_content');
+ $this->load->view('bootstrap/footer');
+ }
+
+ //保存自定义配置
+ public function save_meta()
+ {
+ $im_ic_id = $this->input->post('im_ic_id');
+ $im_key = $this->input->post('im_key');
+ $im_value = $this->input->post('im_value');
+ if ($im_ic_id && $im_key && $im_value !== false) {
+ $meta = $this->InfoMetas_model->get($im_ic_id, $im_key);
+ if ($meta === false) {
+ $this->InfoMetas_model->add($im_ic_id, $im_key, $im_value);
+ } else {
+ $this->InfoMetas_model->update($im_ic_id, $im_key, $im_value);
+ }
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_save_success'));
+ } else {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
+ }
+ echo json_encode($data);
+ return true;
+ }
+
+ //保存自定义配置
+ public function delete_meta()
+ {
+ $im_ic_id = $this->input->post('im_ic_id');
+ $im_key = $this->input->post('im_key');
+ if ($im_ic_id && $im_key) {
+
+ $this->InfoMetas_model->delete($im_ic_id, $im_key);
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_delete_success'));
+ } else {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
+ }
+ echo json_encode($data);
+ return true;
+ }
}
\ No newline at end of file