|
|
|
@ -349,6 +349,14 @@ class Information extends CI_Controller
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//CT判断是否生成静态文件
|
|
|
|
|
if ($this->config->item("site_code")=="chinatravel"){
|
|
|
|
|
//查找是否有静态文件
|
|
|
|
|
if ($this->html_file_helper('find', $data['information']->ic_url)) {
|
|
|
|
|
$data['has_html_file'] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->load->view('bootstrap3/header', $data);
|
|
|
|
|
$this->load->view('bootstrap3/information_edit');
|
|
|
|
@ -587,9 +595,15 @@ class Information extends CI_Controller
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if ($this->html_file_helper('find', $information->ic_url)) {
|
|
|
|
|
//用于批量更新
|
|
|
|
|
$this->make_www_cache('pc', $information);
|
|
|
|
|
$this->make_www_cache('mobile', $information);
|
|
|
|
|
//用于批量更新,CH和chinatravel分开 ,20210317 zp
|
|
|
|
|
if ($this->config->item('site_code') == 'ch'){
|
|
|
|
|
$this->make_www_cache('pc', $information);
|
|
|
|
|
$this->make_www_cache('mobile', $information);
|
|
|
|
|
}else if ($this->config->item('site_code') == 'chinatravel'){
|
|
|
|
|
$this->make_www_cache_ct('pc', $information);
|
|
|
|
|
$this->make_www_cache_ct('mobile', $information);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo json_encode(array('name' => 'yes', 'data' => '更新成功!'));
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
@ -754,94 +768,127 @@ class Information extends CI_Controller
|
|
|
|
|
*/
|
|
|
|
|
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'))) {
|
|
|
|
|
//先准备数据,CT采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
|
|
|
|
|
$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;
|
|
|
|
|
//详细内容
|
|
|
|
|
$data["CUSTOMCONENT"]=$information->ic_content;
|
|
|
|
|
//非产品页面
|
|
|
|
|
$data["PRODUCTJS"]="";
|
|
|
|
|
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);
|
|
|
|
|
$data["PRODUCTJS"] = '<script src="https://data.chinatravel.com/js/mobile-first/flatpickr.js"></script>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//顶部全屏大图
|
|
|
|
|
$data["TOPBANNER"] ="";
|
|
|
|
|
$ImgText = ""; //图文字
|
|
|
|
|
$meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
|
|
|
|
|
if($device=='mobile'){//移动端读取移动大图
|
|
|
|
|
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
|
|
|
|
|
$bannerImg = '<img class="img-responsive" width="750" height="650" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '">';
|
|
|
|
|
}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');
|
|
|
|
|
$bannerImg = '<img class="img-responsive" width="1920" height="720" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '">';
|
|
|
|
|
$meta_addon_picture_text = get_meta($information->ic_id,'meta_addon_picture_text');
|
|
|
|
|
if(!empty($meta_addon_picture_url)){
|
|
|
|
|
$ImgText = '<div class="carousel-caption"><p class="ads-title"><a href="'.$meta_addon_picture_url.'">'.$meta_addon_picture_text.'</a></p></div>';
|
|
|
|
|
}else{
|
|
|
|
|
$ImgText = '<div class="carousel-caption"><p class="ads-title">'.$meta_addon_picture_text.'</p></div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
$data["TOPBANNER"] = '<div class="banner"><a href="'.$meta_addon_picture_url.'">'.$bannerImg.' </a>'.$ImgText.'</div>';
|
|
|
|
|
}else{
|
|
|
|
|
$template = str_replace('<!--@TOP-BANNER@-->', '<div class="detailtopbanner"><img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '"></div>', $template);
|
|
|
|
|
$data["TOPBANNER"] = '<div class="banner">'.$bannerImg.$ImgText.'</div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//顶部视频
|
|
|
|
|
|
|
|
|
|
//顶部视频
|
|
|
|
|
$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)) {
|
|
|
|
|
$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);
|
|
|
|
|
$data["TOPVIDEO"]='<div class="banner"><video autoplay="" controls="controls" id="bgvid" poster="' . $meta_video_picture . '" src="' . $meta_news_video . '" style="position: inherit;"> </video></div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//主样式表,内联模式
|
|
|
|
|
$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);
|
|
|
|
|
if ($device=="mobile"){
|
|
|
|
|
$cssUrl = "http://202.103.68.104/css/newcss3/mobile.css";
|
|
|
|
|
}else{
|
|
|
|
|
$cssUrl="http://202.103.68.104/css/newcss3/pc.css";
|
|
|
|
|
}
|
|
|
|
|
$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>';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//额外js
|
|
|
|
|
$data["ADDONJS"]="";
|
|
|
|
|
$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);
|
|
|
|
|
$data["ADDONJS"]='<script src="' . $meta_addon_js . '"></script>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//社媒分享图片
|
|
|
|
|
$data["OGIMAGE"]="";
|
|
|
|
|
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);
|
|
|
|
|
$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">';
|
|
|
|
|
}
|
|
|
|
|
//设置图片尺寸
|
|
|
|
|
$template=$this->html_optimize_lib->set_image_size($template);
|
|
|
|
|
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
|
|
|
|
|
|
|
|
|
|
//结构化标签
|
|
|
|
|
$data["ConstructionCode"]="";
|
|
|
|
|
$meta_construction_code = get_meta($information->ic_id,'meta_construction_code');
|
|
|
|
|
if (!empty($meta_construction_code)){
|
|
|
|
|
$data["ConstructionCode"]=$meta_construction_code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//两种模板
|
|
|
|
|
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) == '/') {
|
|
|
|
@ -850,6 +897,25 @@ class Information extends CI_Controller
|
|
|
|
|
$html_path .= $html_path_ext;
|
|
|
|
|
create_folder_by_path(dirname($html_path));
|
|
|
|
|
file_put_contents($html_path, $template, LOCK_EX);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //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);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //设置图片尺寸
|
|
|
|
|
// //$template=$this->html_optimize_lib->set_image_size($template);
|
|
|
|
|
// // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function call_mobile_template_H1($mobile_first_template_path, $is_path, $ic_author, $ic_title, $ic_photo)
|
|
|
|
|