增加花梨鹰英文站

master
赵鹏 3 months ago
parent 90a615c74a
commit 234c8fd95f

@ -783,6 +783,9 @@ class Information extends CI_Controller {
} else if (strcasecmp($site_code, "hly") == 0 && ! empty($auto_update_cache)) { } else if (strcasecmp($site_code, "hly") == 0 && ! empty($auto_update_cache)) {
$information_new = $this->Information_model->Detail($this->input->post('is_id')); $information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_hly($information_new); $this->make_www_cache_hly($information_new);
} else if (strcasecmp($site_code, "hlyen") == 0 && ! empty($auto_update_cache)) {
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_hlyen($information_new);
} else if (strcasecmp($site_code, "cht") == 0 && ! empty($auto_update_cache)) { } else if (strcasecmp($site_code, "cht") == 0 && ! empty($auto_update_cache)) {
$update_info_log = $this->update_cache($ic_url); $update_info_log = $this->update_cache($ic_url);
} else if (strcasecmp($site_code, "htravel") == 0 && ! empty($auto_update_cache)) { } else if (strcasecmp($site_code, "htravel") == 0 && ! empty($auto_update_cache)) {
@ -883,6 +886,8 @@ class Information extends CI_Controller {
$this->make_www_cache_gl($information); $this->make_www_cache_gl($information);
} else if ($this->config->item('site_code') == 'hly') { } else if ($this->config->item('site_code') == 'hly') {
$this->make_www_cache_hly($information); $this->make_www_cache_hly($information);
} else if ($this->config->item('site_code') == 'hlyen') {
$this->make_www_cache_hlyen($information);
} else if ($this->config->item('site_code') == 'gh') { } else if ($this->config->item('site_code') == 'gh') {
$this->make_www_cache_gh('pc', $information, $recommand_information); $this->make_www_cache_gh('pc', $information, $recommand_information);
$this->make_www_cache_gh('mobile', $information, $recommand_information); $this->make_www_cache_gh('mobile', $information, $recommand_information);
@ -5739,6 +5744,347 @@ class Information extends CI_Controller {
#endregion #endregion
} }
/**
* 花梨鹰 英文站 chiangmaiyipengfestival.com 的静态化方法
*/
public function make_www_cache_hlyen($information){
$data = [];
#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'); //模板位置
/* 详细内容 */
$ic_content = $information->ic_content;
//图片加延迟
$ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.hualiyingtravel.com/image/grey.gif');
$ic_content = $this->html_optimize_lib->set_image_size($ic_content);
//非产品页面
$data["PRODUCTJS"] = "";
$data["ISPRODUCT"] = "no"; //判断是否是产品页
$data["addthis_widget"] = "";
$data["FloatIcon"] = ""; //浮动图标替代addthis
$arrExitUrl = ["/", "/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["FloatIcon"] = "<div class=\"fixed-tm\"><a href=\"/forms/customize\" >私人定制</a></div>";
} else {
$data["ISPRODUCT"] = "yes";
}
//主样式表,内联模式
$apiweb="http://202.103.68.104:107"; //本地测试
//$apiweb = "https://data.hualiyingtravel.com";
$cssUrl = $apiweb . "/css/css3/base.css?v=" . time();
$main_css_string = compress_css(GET_HTTP($cssUrl));
$data["MAINCSS"] = '<style type="text/css">' . $main_css_string . '</style>';
//额外样式
$data["ADDONCSS"] = "";
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
if (! empty($meta_addon_css)) {
//引用方式
//$data["ADDONCSS"]= '<link href="' . $meta_addon_css . '" rel="stylesheet" />';
//内联方式
$meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
$data["ADDONCSS"] = '<style type="text/css">' . $meta_addon_css_string . '</style>';
}
//社媒分享图片
$data["OGIMAGE"] = "";
if (! empty($information->ic_photo)) {
if (strpos($information->ic_photo, "guilinchina.net") != false) {
$full_ic_photo = $information->ic_photo;
} else {
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
}
$data["OGIMAGE"] = '<meta property="og:image" content="' . $full_ic_photo . '"><meta property="og:image:secure_url" content="' . $full_ic_photo . '"><meta property="og:image:width" content="800"><meta property="og:image:height" content="450">';
}
//结构化标签
$data["ConstructionCode"] = "";
$meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
if (! empty($meta_construction_code)) {
$data["ConstructionCode"] = $meta_construction_code;
}
$data["meta_index_set"] = "";
$meta_index_set = get_meta($information->ic_id, 'meta_index_set');
if (! empty($meta_index_set)) {
$data["meta_index_set"] = '<meta name="robots" content="' . $meta_index_set . '" />';
}
//总JS为了方便以后js好维护必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js所以必须在这里进行判断
$addBaseJs = false;
$addonJs = "";
$meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
$meta_ct_page_Carousel = get_meta($information->ic_id, 'meta_ct_page_Carousel'); //是否有顶部轮播图
if ($meta_ct_page_price == "yes") {
$addBaseJs = true;
} else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
$addBaseJs = true;
} else if ($meta_ct_page_Carousel == "yes") {
$addBaseJs = true;
}
if ($addBaseJs) {
$addonJs = '<script src="' . $apiweb . '/js/mobile-first/base.js" defer></script>';
}
/// ----- 总JS判断完成-----
//额外js
$data["ADDONJS"] = "";
$meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
if (! empty($meta_addon_js)) {
$addonJs .= '<script src="' . $meta_addon_js . '" defer></script>';
}
//价格js
if ($meta_ct_page_price == "yes") {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getprice.js" defer></script>';
}
//列表js
if (in_array($meta_ct_page_type, ['daytripindex', 'tourindex', 'attractionindex'])) {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getlist.js" defer></script>';
}
//页面传递参数
$passParam = "";
if (in_array($meta_ct_page_type, ["daytripindex", "tourindex", "attractionindex", "weatherpage"])) { //一日游和线路列表
//产品首页
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
if (in_array($meta_ct_page_type, ["attractionindex"])) {
//旧信息id,景点等信息类
$passParam .= '<input type="hidden" name="param_old_pid" id="param_old_pid" value="' . $meta_ct_page_value . '"/>';
} else {
//城市名称,产品类用
$passParam .= '<input type="hidden" name="param_city" id="param_city" value="' . $meta_ct_page_value . '"/>';
}
//加信息平台的is_id
$passParam .= '<input type="hidden" name="param_parentId" id="param_parentId" value="' . $information->is_id . '"/>';
}
//产品详细页
$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;
}
//一日游表单的替换
$DayTripData["productCode"] = $productCode;
$DayTripData["picture_mobile"] = get_meta($information->ic_id, 'meta_addon_picture_mobile');
$DayTripData["picture_pc"] = get_meta($information->ic_id, 'meta_addon_picture');
$DayTripData["TITLE"] = $information->ic_title;
$arrCAD = ['HLYCAD-S', 'HLYCAD-V', 'HLYCAD-P']; //水灯节
$arrCAD_EN = ['QM-NUT-V', 'QM-NUT-P']; //水灯节英文
//$arrTest = ['QM-9-A','QM-9-B','QM-9-C'];
if (in_array($productCode, $arrCAD) || in_array($productCode, $arrCAD_EN)) { //水灯节,中英文分别调用不同模板
/**替换左右结构的线路表单标签 2024-7-4*/
if (strpos($ic_content, '<!--@DAYTRIP-CAD-FORM@-->') !== false) {
//准备数据
$InfoData = new stdClass(); //传递用来计算的信息平台数据
//附加选项
$t_excludedate = get_meta($information->ic_id, "meta_trippest_excludedate");
$t_includedate = get_meta($information->ic_id, "meta_trippest_includedate");
$t_excludemonth = get_meta($information->ic_id, "meta_trippest_excludemonth");
$InfoData->t_excludedate = $t_excludedate;
$InfoData->t_includedate = $t_includedate;
$InfoData->t_excludemonth = $t_excludemonth;
$DayTripData["InfoData"] = $InfoData; //传递信息平台数据
$linktour = get_meta($information->ic_id, 'meta_trainspread_linktour'); //关联线路
if (! empty($linktour)) {
$paramCode = $productCode . "," . $linktour;
} else {
$paramCode = $productCode;
}
//产品汉特信息,测试地址http://202.103.68.104:61/info.php/thirdparty/ctmobilefirst/api/getDaytripDetail/?webcode=hly&param=QM-9-A,QM-9-B,QM-9-C
$TourData = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getDaytripDetail/?webcode=hlyen&param=" . $paramCode));
$DayTripData["TourData"] = $TourData;
//替换模板
if (in_array($productCode, $arrCAD_EN)) {
$template_form_daydetail = $this->load->view($template_path . '-cad-form-en', $DayTripData, true); //英文模板内容
} else {
$template_form_daydetail = $this->load->view($template_path . '-cad-form', $DayTripData, true); //中文模板内容
}
$ic_content = str_replace('<!--@DAYTRIP-CAD-FORM@-->', $template_form_daydetail, $ic_content);
}
} else if (1 == 2) { //默认,暂时没有
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/daytripdetail.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
$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 . "&webcode=hlyen"));
$data["clisn"] = $tourdata->clisn;
//获取price
$tourprice = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getTourPrice/?param=" . $productCode . "&webcode=hlyen"));
$dataform["tourprice"] = $tourprice->price;
//调取模板
$dataform["TourCode"] = $productCode;
$dataform["CLI_SN"] = $tourdata->clisn;
$dataform["TourName"] = $information->ic_title;
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/tourdetail.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
//表单页
if (in_array($meta_ct_page_type, ["customize", "contactus", "pagewithform"])) {
$productType = $meta_ct_page_type;
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/form.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
if ($meta_ct_page_type == "daytripform") {
$productType = $meta_ct_page_type;
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/daytrip-form.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/form.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
$data["productType"] = $productType;
$data["productCode"] = $productCode;
//页面添加的元素
$data["ADDONJS"] = $addonJs;
$data["passParam"] = $passParam;
//页面详细内容放最后,这样上面都可以进行内容的替换,比如一日游表单
$data["CUSTOMCONENT"] = $ic_content;
#endregion
#region 移动端和PC端差别处理区域
$arrDevice = ["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 = '<img class="image-banner" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '" width="750" height="500">';
} else {
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
$bannerImg = '<img class="image-banner" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '" width="1920" height="600">';
}
if (! empty($meta_addon_picture)) {
if (! empty($meta_addon_picture_url)) {
$data["TOPBANNER"] = '<div class="banner-image"><a href="' . $meta_addon_picture_url . '">' . $bannerImg . ' </a>' . $ImgText . '</div>';
} else {
$data["TOPBANNER"] = '<div class="banner-image">' . $bannerImg . $ImgText . '</div>';
}
}
if ($meta_ct_page_type == "tourdetail") { //线路表单,左右结构,用标签来做
$dataform['device'] = $device;
if (strpos($ic_content, '<!--@TOUR-FORM@-->') !== false) {
$InfoData = new stdClass(); //传递用来计算的信息平台数据
$t_excludedate = get_meta($information->ic_id, "meta_trippest_excludedate");
$t_includedate = get_meta($information->ic_id, "meta_trippest_includedate");
$t_excludemonth = get_meta($information->ic_id, "meta_trippest_excludemonth");
$InfoData->t_excludedate = $t_excludedate;
$InfoData->t_includedate = $t_includedate;
$InfoData->t_excludemonth = $t_excludemonth;
$InfoData->t_defaultDate = get_meta($information->ic_id, "meta_trippest_defaultDate");
$dataform["InfoData"] = $InfoData; //传递信息平台数据
$template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
$ic_content_pc = $ic_content; //需要一个变量来过渡,不然$ic_content改变以后PC端就没有标签<!--@TOUR-FORM@-->
$ic_content_pc = str_replace('<!--@TOUR-FORM@-->', $template_form_tourqi, $ic_content_pc);
$data["CUSTOMCONENT"] = $ic_content_pc;
}
}
//两种设备分别调用两种模板 ,静态化
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 set_photo_content($ic_photo, $ic_content) { public function set_photo_content($ic_photo, $ic_content) {
if (empty($ic_photo)) { if (empty($ic_photo)) {

Loading…
Cancel
Save