diff --git a/application/controllers/information.php b/application/controllers/information.php index 0cf70289..41c4f99a 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -783,6 +783,9 @@ class Information extends CI_Controller { } else if (strcasecmp($site_code, "hly") == 0 && ! empty($auto_update_cache)) { $information_new = $this->Information_model->Detail($this->input->post('is_id')); $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)) { $update_info_log = $this->update_cache($ic_url); } 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); } else if ($this->config->item('site_code') == 'hly') { $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') { $this->make_www_cache_gh('pc', $information, $recommand_information); $this->make_www_cache_gh('mobile', $information, $recommand_information); @@ -5739,6 +5744,347 @@ class Information extends CI_Controller { #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"] = "
私人定制
"; + } 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"] = ''; + + //额外样式 + $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, "guilinchina.net") != false) { + $full_ic_photo = $information->ic_photo; + } else { + $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo; + } + $data["OGIMAGE"] = ''; + } + + //结构化标签 + $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"] = ''; + } + + //总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 = ''; + } + /// ----- 总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, ['daytripindex', 'tourindex', 'attractionindex'])) { + $addonJs .= ''; + } + + //页面传递参数 + $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 .= ''; + } else { + //城市名称,产品类用 + $passParam .= ''; + } + + //加信息平台的is_id + $passParam .= ''; + } + + //产品详细页 + $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, '') !== 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¶m=QM-9-A,QM-9-B,QM-9-C + $TourData = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getDaytripDetail/?webcode=hlyen¶m=" . $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('', $template_form_daydetail, $ic_content); + } + } else if (1 == 2) { //默认,暂时没有 + + $addonJs .= ''; + $data["ADDONCSS"] .= ''; + + $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 .= ''; + $data["ADDONCSS"] .= ''; + + } + + //表单页 + if (in_array($meta_ct_page_type, ["customize", "contactus", "pagewithform"])) { + $productType = $meta_ct_page_type; + $addonJs .= ''; + $data["ADDONCSS"] .= ''; + } + + if ($meta_ct_page_type == "daytripform") { + $productType = $meta_ct_page_type; + $addonJs .= ''; + $data["ADDONCSS"] .= ''; + } + + $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 = '' . $information->ic_title . ''; + } else { + $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture'); + $bannerImg = '' . $information->ic_title . ''; + } + + if (! empty($meta_addon_picture)) { + if (! empty($meta_addon_picture_url)) { + $data["TOPBANNER"] = ''; + } else { + $data["TOPBANNER"] = ''; + } + } + + if ($meta_ct_page_type == "tourdetail") { //线路表单,左右结构,用标签来做 + $dataform['device'] = $device; + + if (strpos($ic_content, '') !== 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端就没有标签了 + $ic_content_pc = str_replace('', $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) { if (empty($ic_photo)) {