From 3379d71b35a9ef823fcb5212c94effdb7a9d14a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Thu, 11 Mar 2021 11:51:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0CT=E7=9A=84=E9=9D=99=E6=80=81?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/config/config.php | 1 + application/controllers/information.php | 145 ++++++++++++++++-- .../views/bootstrap3/information_edit.php | 8 +- 3 files changed, 135 insertions(+), 19 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 734ecb99..5490eca4 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -725,6 +725,7 @@ $config['cache']['vac']['cache_path'] = 'C:\VHD\Dropbox\wwwcache\viaje-a-china.c $config['cache']['ru']['cache_path'] = 'C:\VHD\Dropbox\wwwcache\chinahighlights.ru'; $config['cache']['it']['cache_path'] = 'C:\VHD\Dropbox\wwwcache\viaggio-in-cina.it'; $config['cache']['ch']['cache_path'] = 'D:\wwwcache\chinahighlights.com'; +$config['cache']['chinatravel']['cache_path'] = 'D:\wwwcache\chinatravel.com'; //静态文件更新接口 $config['cache']['jp']['cache_api'] = '/info.php/information/update_cache/'; diff --git a/application/controllers/information.php b/application/controllers/information.php index 44c969b5..af937176 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -328,22 +328,25 @@ class Information extends CI_Controller } //获取移动优先的模板,如果有的话 - $mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code'); - if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) { - $mobile_template_H1 = $this->call_mobile_template_H1($mobile_first_template_path, $data['information']->is_path, $data['information']->ic_author, $data['information']->ic_title, $data['information']->ic_photo);//H1模板替换 - $data['mobile_first_template'] = $this->load->view($mobile_first_template_path, '', TRUE); - if (empty(get_meta($data['information']->ic_id, 'meta_product_code'))) { - $data['mobile_first_template'] = str_replace('', $mobile_template_H1, $data['mobile_first_template']); - } - //主样式表,内联模式 - $main_css_string=compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css')); - $data['mobile_first_template'] = str_replace('', '', $data['mobile_first_template']); - //查找是否有静态文件 - if ($this->html_file_helper('find', $data['information']->ic_url)) { - $data['has_html_file'] = true; + //增加判断站点,每个站点需要读取的模板不一样。 20210311 zp + if ($this->config->item('site_code')=="ch"){ + $mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code'); + if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) { + $mobile_template_H1 = $this->call_mobile_template_H1($mobile_first_template_path, $data['information']->is_path, $data['information']->ic_author, $data['information']->ic_title, $data['information']->ic_photo);//H1模板替换 + $data['mobile_first_template'] = $this->load->view($mobile_first_template_path, '', TRUE); + if (empty(get_meta($data['information']->ic_id, 'meta_product_code'))) { + $data['mobile_first_template'] = str_replace('', $mobile_template_H1, $data['mobile_first_template']); + } + //主样式表,内联模式 + $main_css_string=compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css')); + $data['mobile_first_template'] = str_replace('', '', $data['mobile_first_template']); + //查找是否有静态文件 + if ($this->html_file_helper('find', $data['information']->ic_url)) { + $data['has_html_file'] = true; + } + } else { + $data['mobile_first_template'] = '没有找到移动模板'; } - } else { - $data['mobile_first_template'] = '没有找到移动模板'; } @@ -499,6 +502,12 @@ class Information extends CI_Controller $information_new = $this->Information_model->Detail($this->input->post('is_id')); $this->make_www_cache('mobile', $information_new); $this->make_www_cache('pc', $information_new); + }else if (strcasecmp($site_code, "chinatravel") == 0 && !empty($auto_update_cache)){ + //chinatravel读取模板生成PC和移动优先文件 + $information_new = $this->Information_model->Detail($this->input->post('is_id')); + $this->make_www_cache_ct('mobile', $information_new); + $this->make_www_cache_ct('pc', $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, "ah") == 0 && !empty($auto_update_cache)) { @@ -737,6 +746,112 @@ class Information extends CI_Controller file_put_contents($html_path, $template, LOCK_EX); } + /** + * @description: CT用的生成静态文件方法.有些内容的替换,CT这边不一样,需要单独处理 zp + * @param {type} $device='mobile' or 'pc' + * @return: + * @Date Changed: + */ + function make_www_cache_ct($device,$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; + } + 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: + } + + //替换模板中的标签 + $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 (empty(get_meta($information->ic_id, 'meta_product_code'))) { + + } else { + $template = str_replace('', '', $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_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('', '
' . $information->ic_title . '
', $template); + }else{ + $template = str_replace('', '
' . $information->ic_title . '
', $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); + } + //主样式表,内联模式 + $main_css_string=compress_css(GET_HTTP('https://proxy-data.chinahighlights.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)) { + //引用方式 $template = str_replace('', '', $template); + //内联方式 + $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); + } + $template = str_replace('', $information->ic_content, $template); + //Google广告代码 + if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) { + $template = str_replace('', '', $template); + } + if (!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) { + $in_article_google=$this->load->view($template_path.'-google-ad', false,true); + $template = str_replace('', $in_article_google, $template); + } + //社媒分享图片 + if (!empty($information->ic_photo)) { + $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo; + $template = str_replace('', '', $template); + } + //设置图片尺寸 + $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); + } + function call_mobile_template_H1($mobile_first_template_path, $is_path, $ic_author, $ic_title, $ic_photo) { $data['infocategory'] = $this->Information_model->get_detail_by_path($is_path, 1);//信息所属分类,获取信息顶级节点内容 diff --git a/application/views/bootstrap3/information_edit.php b/application/views/bootstrap3/information_edit.php index d5785f89..1b507c81 100644 --- a/application/views/bootstrap3/information_edit.php +++ b/application/views/bootstrap3/information_edit.php @@ -569,7 +569,7 @@