CT移动优先项目本地测试环境配置完成。

ct-mobile-first
赵鹏 4 years ago
parent b30d24b9fe
commit a7fc13c211

@ -713,6 +713,7 @@ $config['css_source_yz'] = 'https://www.yangtzeriver.org/css/css3/bootstrap/boot
$config['css_source_ah'] = 'https://www.asiahighlights.com/min/?f=/css/global.min.css,/js/bootstrap-datepicker/css/bootstrap-datepicker3.standalone.css,/css/basic.css,/css/homepage.css,/css/contact.css,/css/tailor-make.css,/css/tour.css,/css/tour-detail.css,/css/inquiry-form.css,/css/missing.css';
$config['css_source_gh'] = 'https://www.globalhighlights.com/css/global.css';
$config['css_source_ct'] = 'https://data.chinatravel.com/css/min.php?f=/css/css3/bootstrap/bootstrap.css,/css/css3/style.css,/css/css3/destination-details.css';
$config['css_source_chinatravel'] = 'http://202.103.68.104:100/css/newcss3/pc.css';
$config['css_source_ts'] = 'https://www.trainspread.com/css/bootstrap.min.css';

@ -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)

@ -876,6 +876,26 @@
value="<?php echo get_meta($information->ic_id, 'meta_addon_picture_url'); ?>"/>
</div>
</div>
<?php if ($information->ic_sitecode == 'chinatravel') {
?>
<div>
<div class="col-sm-8">
<label>附加图片说明文字
<a href="javascript:void(0);"
onclick="meta('delete', '<?php echo $information->ic_id; ?>', 'meta_addon_picture_text', $('#meta_addon_picture_text').val())"><i
class="text-muted glyphicon glyphtext-muted glyphicon glyphicon-remove"></i></a>
<a href="javascript:void(0);"
onclick="meta('save', '<?php echo $information->ic_id; ?>', 'meta_addon_picture_text', $('#meta_addon_picture_text').val())"><i
class="text-muted glyphicon glyphtext-muted glyphicon glyphicon-hdd"></i></a>
<a href="javascript:void(0);" title="用于附加的头部大图的alt文字或者图片上的说明文字."><i
class="text-muted glyphicon glyphicon-question-sign"></i></a>
</label>
<input name="meta_addon_picture_text" id="meta_addon_picture_text" type="text"
class="form-control"
value="<?php echo get_meta($information->ic_id, 'meta_addon_picture_text'); ?>"/>
</div>
</div>
<?php } ?>
<input type="hidden" name="ic_photo_width" id="ic_photo_width"
value="<?php echo $information->ic_photo_width; ?>"/>
@ -2201,7 +2221,7 @@
<?php if (!empty($has_html_file)) { ?>
<label class="checkbox col-xs-24"
style="font-weight: normal;margin-top:0;padding-left: 21px;">
<a href="<?php echo site_url('information/html_file_helper/delete?ic_url=' . $information->ic_url); ?>"
<a href="<?php echo site_url('information/html_file_helper/delete?ic_url=') . $information->ic_url; ?>"
target="_blank">静态文件已生成,点击删除</a>
</label>
<?php } ?>

@ -20,8 +20,6 @@
<link rel="dns-prefetch" href="//www.google-analytics.com">
<link rel="dns-prefetch" href="//connect.facebook.net">
<link rel="dns-prefetch" href="//www.facebook.com">
<link href="/css/newcss3/style.css" rel="stylesheet" type="text/css" />
<link href="/css/newcss3/header-pc.css" rel="stylesheet" type="text/css" />
<!--@MAIN-CSS@--><?php echo $MAINCSS ?>
<!--@ADDON-CSS@--><?php echo $ADDONCSS ?>
<!--@CONSTRUCTION-CODE@--><?php echo $ConstructionCode ?>
@ -187,7 +185,7 @@ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-4273670-1',{'siteSpeedSampleRate': 100});
ga('require', 'linkid', 'linkid.js');
ga('require', 'displayfeatures');

Loading…
Cancel
Save