From 43378895eee1946dd98e897ff9d2dc5241d175c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Thu, 21 Nov 2024 14:23:33 +0800 Subject: [PATCH] =?UTF-8?q?TS=E7=BD=91=E7=AB=99=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/config/config.php | 2 +- application/controllers/information.php | 391 ++++++++++++++++++ .../views/bootstrap3/information_edit.php | 57 ++- 3 files changed, 446 insertions(+), 4 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 832a1150..41035b47 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -763,7 +763,7 @@ $config['css_source_ct'] = 'https://data.chinatravel.com/css/min.php?f=/css/css3 $config['css_source_chinatravel'] = 'https://data.chinatravel.com/css/newcss3/base.css'; $config['css_source_shanghai'] = 'https://data.shanghaihighlights.com/css/css3/base.css'; $config['css_source_beijing'] = 'https://www.mybeijingchina.com/css/css3/base.css'; -$config['css_source_trainspread'] = 'https://data.trainspread.com/css/css3/base.css'; +$config['css_source_trainspread'] = 'https://data.trainspread.com/css/base.css'; $config['css_source_ts'] = 'https://www.trainspread.com/css/bootstrap.min.css'; //静态文件生成路径 diff --git a/application/controllers/information.php b/application/controllers/information.php index e9c83523..2a322ce4 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -24,6 +24,7 @@ class Information extends CI_Controller $this->load->model('InfoSMS_model'); $this->load->model('recommends_and_tips_model'); $this->load->model('trippest_model'); //trippest产品 + $this->load->model('infoBokunData_model'); //trainspread产品 $this->load->model('Feedback_model'); $this->load->model('Price_model'); $this->load->model('PrimeLinePrice_model'); @@ -3628,7 +3629,397 @@ class Information extends CI_Controller * TrainSpread网站静态化 */ public function make_www_cache_ts($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 = "
Home"; + foreach ($crumb_data as $index => $item) { + $crumb .= '' . $item['ic_url_title'] . ''; + } + $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)) . '
'; + } + + + /* 详细内容 */ + $ic_content = $information->ic_content; + + /** 替换H1加面包屑,加作者 */ + $ic_content = preg_replace('/

(.*)<\/h1>/i', $crumb . "\r\n" . '

$1

' . "\r\n" . $str_author . "\r\n", $ic_content, 1); + + //图片加延迟 + $ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.trainspread.com/images/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 = 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["FloatIcon"] = "
Create My Trip
"; + } else { + $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"] = ''; + } + + //主样式表,内联模式 + $apiweb="http://202.103.68.104:71"; //本地测试 + //$apiweb = "https://www.trainspread.com"; + $cssUrl = $apiweb . "/css/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, "mybeijingchina.com") != 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; + } + + //总JS:为了方便以后js好维护,必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js,所以必须在这里进行判断 + $addBaseJs = false; + $addonJs = ""; + $meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格 + + 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 .= ''; + } + + //列表js + if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) { + $addonJs .= ''; + } + + //天气 + 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 .= ''; + } + + //产品详细页 + $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"] .= ''; + + //一日游表单的替换,放到下面的区分PC端和移动端 + + } + 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/apibj/getCliSn/?param=" . $productCode)); + $data["clisn"] = $tourdata->clisn; + + //调取模板 + $dataform["TourCode"] = $productCode; + $dataform["CLI_SN"] = $tourdata->clisn; + $dataform["TourName"] = $information->ic_title; + + + } + + //表单页 + 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"] .= ''; + } + + $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 = '' . $information->ic_title . ''; + if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) { + $ImgText = ''; + } else if (!empty($meta_addon_picture_text)) { + $ImgText = ''; + } + } else { + $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture'); + $bannerImg = '' . $information->ic_title . ''; + if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) { + $ImgText = ''; + } else if (!empty($meta_addon_picture_text)) { + $ImgText = ''; + } + } + + // 搜索框 + $template_TrainSearch = ""; + if ($information->ic_url == "/" || $information->ic_url == "/test" || $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"] = ''; + } + } 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"] = ''; + } + } + + + if ($meta_ct_page_type == "daytripdetail") { //一日游产品的表单处理放这里,根据PC和移动端有所区别 + $DayTripData['device'] = $device; + + /**替换左右结构的线路表单标签 2024-7-4*/ + if (strpos($ic_content, '') !== false) { + //准备数据 + $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_seo_title; + //成人,儿童,婴儿的年龄显示信息 + $AdultMsg = $this->infoBokunData_model->getBokunMetaList($information->ic_id, "AdultMsg"); + if ($AdultMsg) { + foreach ($AdultMsg as $AdultMsgItem) { + $DayTripData["AdultMsg"] = $AdultMsgItem->ibd_Itemvalue; + } + } else { + $DayTripData["AdultMsg"] = null; + } + + $ChildMsg = $this->infoBokunData_model->getBokunMetaList($information->ic_id, "ChildMsg"); + if ($ChildMsg) { + foreach ($ChildMsg as $ChildMsgItem) { + $DayTripData["ChildMsg"] = $ChildMsgItem->ibd_Itemvalue; + } + } else { + $DayTripData["ChildMsg"] = null; + } + + $InfantMsg = $this->infoBokunData_model->getBokunMetaList($information->ic_id, "InfantMsg"); + if ($InfantMsg) { + foreach ($InfantMsg as $InfantMsgItem) { + $DayTripData["InfantMsg"] = $InfantMsgItem->ibd_Itemvalue; + } + } else { + $DayTripData["InfantMsg"] = null; + } + + //有些接送没有对应的成人及儿童只有一个Other + $Other_Msg = $this->infoBokunData_model->getBokunMetaList($information->ic_id, "Other_Msg"); + if ($Other_Msg) { + foreach ($Other_Msg as $Other_MsgItem) { + $DayTripData["Other_Msg"] = $Other_MsgItem->ibd_Itemvalue; + } + } else { + $DayTripData["Other_Msg"] = null; + } + + $InfoData = new stdClass(); //传递用来计算的信息平台数据 + $MinTravelers = get_meta($information->ic_id, 'meta_trippest_limitperson'); + $InfoData->MinTravelers = $MinTravelers == null ? 0 : $MinTravelers; + + $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/apits/getDaytripDetail/?param=TS-HKALC-1,TS-HKALC-2,TS-HKALC-3 + $TourData = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/apits/getDaytripDetail/?param=" . $paramCode)); + $DayTripData["TourData"] = $TourData; + //替换模板 + $TS_DayTripContent = $ic_content; //因为需要替换,所以要转给零时变量。不然手机端替换完了,PC端就没有了。 + $template_form_daydetail = $this->load->view($template_path . '-daydetail-form', $DayTripData, true); //模板内容 + $TS_DayTripContent = str_replace('', $template_form_daydetail, $TS_DayTripContent); + $data["CUSTOMCONENT"] = $TS_DayTripContent; + } + }else{ + //一日游产品有自己的图片展示效果 + if (!empty($meta_addon_picture)) { + if (!empty($meta_addon_picture_url)) { + $data["TOPBANNER"] = ''; + } else { + $data["TOPBANNER"] = ''; + } + } + } + + //两种设备分别调用两种模板 ,静态化 + 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 } //通过内容找到第一张图片 diff --git a/application/views/bootstrap3/information_edit.php b/application/views/bootstrap3/information_edit.php index 8c378fdf..fe1993c2 100644 --- a/application/views/bootstrap3/information_edit.php +++ b/application/views/bootstrap3/information_edit.php @@ -1067,7 +1067,7 @@ if (!empty($setting_website_nav)) {

- ic_sitecode == "trippest") {?> + ic_sitecode == "trippest" || $information->ic_sitecode == "trainspread") {?>
@@ -2326,8 +2326,59 @@ $meta_subnavi_arr = array( - - + + ic_sitecode == "trainspread") {?> +
+
+ + +
+
+ + +
+
+ + +
+
+