|
|
@ -328,22 +328,25 @@ class Information extends CI_Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取移动优先的模板,如果有的话
|
|
|
|
//获取移动优先的模板,如果有的话
|
|
|
|
$mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
|
|
|
|
//增加判断站点,每个站点需要读取的模板不一样。 20210311 zp
|
|
|
|
if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) {
|
|
|
|
if ($this->config->item('site_code')=="ch"){
|
|
|
|
$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模板替换
|
|
|
|
$mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
|
|
|
|
$data['mobile_first_template'] = $this->load->view($mobile_first_template_path, '', TRUE);
|
|
|
|
if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) {
|
|
|
|
if (empty(get_meta($data['information']->ic_id, 'meta_product_code'))) {
|
|
|
|
$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'] = str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $data['mobile_first_template']);
|
|
|
|
$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('<!--@HEAD_1@-->', $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('<!--@MAIN-CSS@-->', '<style type="text/css">' . $main_css_string . '</style>', $data['mobile_first_template']);
|
|
|
|
//主样式表,内联模式
|
|
|
|
//查找是否有静态文件
|
|
|
|
$main_css_string=compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css'));
|
|
|
|
if ($this->html_file_helper('find', $data['information']->ic_url)) {
|
|
|
|
$data['mobile_first_template'] = str_replace('<!--@MAIN-CSS@-->', '<style type="text/css">' . $main_css_string . '</style>', $data['mobile_first_template']);
|
|
|
|
$data['has_html_file'] = true;
|
|
|
|
//查找是否有静态文件
|
|
|
|
|
|
|
|
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'));
|
|
|
|
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
|
|
|
|
$this->make_www_cache('mobile', $information_new);
|
|
|
|
$this->make_www_cache('mobile', $information_new);
|
|
|
|
$this->make_www_cache('pc', $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)) {
|
|
|
|
} 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, "ah") == 0 && !empty($auto_update_cache)) {
|
|
|
|
} 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);
|
|
|
|
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('<!--@TITLE@-->', $information->ic_seo_title, $template);
|
|
|
|
|
|
|
|
$template = str_replace('<!--@DESCRIPTION@-->', $information->ic_seo_description, $template);
|
|
|
|
|
|
|
|
$template = str_replace('<!--@KEYWORDS@-->', $information->ic_seo_keywords, $template);
|
|
|
|
|
|
|
|
$template = str_replace('<!--@CANONICAL@-->', $this->config->item('site_url') . $information->ic_url, $template);
|
|
|
|
|
|
|
|
//非产品页面
|
|
|
|
|
|
|
|
if (empty(get_meta($information->ic_id, 'meta_product_code'))) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$template = str_replace('<!--@PRODUCT-JS@-->', '<script src="https://data.chinahighlights.com/js/flatpickr.js"></script>', $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('<!--@TOP-BANNER@-->', '<div class="detailtopbanner"><a href="'.$meta_addon_picture_url.'"> <img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '"></a></div>', $template);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$template = str_replace('<!--@TOP-BANNER@-->', '<div class="detailtopbanner"><img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '"></div>', $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('<!--@TOP-VIDEO@-->', '<div class="detailtopbanner"><video autoplay="" controls="controls" id="bgvid" poster="' . $meta_video_picture . '" src="' . $meta_news_video . '" style="position: inherit;"> </video></div>', $template);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//主样式表,内联模式
|
|
|
|
|
|
|
|
$main_css_string=compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css'));
|
|
|
|
|
|
|
|
$template = str_replace('<!--@MAIN-CSS@-->', '<style type="text/css">' . $main_css_string . '</style>', $template);
|
|
|
|
|
|
|
|
//额外样式
|
|
|
|
|
|
|
|
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
|
|
|
|
|
|
|
|
if (!empty($meta_addon_css)) {
|
|
|
|
|
|
|
|
//引用方式 $template = str_replace('<!--@ADDON-CSS@-->', '<link href="' . $meta_addon_css . '" rel="stylesheet">', $template);
|
|
|
|
|
|
|
|
//内联方式
|
|
|
|
|
|
|
|
$meta_addon_css_string=compress_css(GET_HTTP($meta_addon_css));
|
|
|
|
|
|
|
|
$template = str_replace('<!--@ADDON-CSS@-->', '<style type="text/css">' . $meta_addon_css_string . '</style>', $template);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//额外js
|
|
|
|
|
|
|
|
$meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
|
|
|
|
|
|
|
|
if (!empty($meta_addon_js)) {
|
|
|
|
|
|
|
|
$template = str_replace('<!--@ADDON-JS@-->', '<script src="' . $meta_addon_js . '"></script>', $template);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$template = str_replace('<!--@CUSTOM-CONENT@-->', $information->ic_content, $template);
|
|
|
|
|
|
|
|
//Google广告代码
|
|
|
|
|
|
|
|
if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
|
|
|
|
|
|
|
|
$template = str_replace('<!--@Match-Content-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4231674166786366" data-ad-slot="1447610161"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $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@-->', $in_article_google, $template);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//社媒分享图片
|
|
|
|
|
|
|
|
if (!empty($information->ic_photo)) {
|
|
|
|
|
|
|
|
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
|
|
|
|
|
|
|
|
$template = str_replace('<!--@OG:IMAGE@-->', '<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">', $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)
|
|
|
|
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);//信息所属分类,获取信息顶级节点内容
|
|
|
|
$data['infocategory'] = $this->Information_model->get_detail_by_path($is_path, 1);//信息所属分类,获取信息顶级节点内容
|
|
|
|