Inspiration信息推荐

ct-mobile-first
ycc 5 years ago
parent 2f9992fe01
commit 4c9a39f6ae

@ -115,7 +115,7 @@ class Information extends CI_Controller
//删除前备份amp的meta标签-isid。 //删除前备份amp的meta标签-isid。
$meta_value = $this->InfoMetas_model->get($info_detail->ic_id, 'AMP_JSON'); $meta_value = $this->InfoMetas_model->get($info_detail->ic_id, 'AMP_JSON');
if ($meta_value) { if ($meta_value) {
$this->Logs_model->backup_meta($info_detail->ic_id, $meta_value, 'AMP_JSON_'.$is_id); $this->Logs_model->backup_meta($info_detail->ic_id, $meta_value, 'AMP_JSON_' . $is_id);
} }
$this->Logs_model->delete($is_id, $info_detail->ic_content); $this->Logs_model->delete($is_id, $info_detail->ic_content);
@ -138,9 +138,10 @@ class Information extends CI_Controller
} }
} }
//移动优先的编辑 //移动优先的编辑
public function edit_mobile($is_id){ public function edit_mobile($is_id)
//查询结构信息 {
//查询结构信息
$Structure = $this->InfoStructures_model->Detail($is_id); $Structure = $this->InfoStructures_model->Detail($is_id);
if ($Structure == FALSE) { if ($Structure == FALSE) {
show_404(); show_404();
@ -160,11 +161,11 @@ class Information extends CI_Controller
//信息内容 //信息内容
$data['information'] = $this->Information_model->Detail($is_id); $data['information'] = $this->Information_model->Detail($is_id);
$this->load->view('bootstrap3/header', $data); $this->load->view('bootstrap3/header', $data);
$this->load->view('mobile_first/editor'); $this->load->view('mobile_first/editor');
$this->load->view('bootstrap3/footer'); $this->load->view('bootstrap3/footer');
} }
public function edit($is_id) public function edit($is_id)
{ {
@ -230,7 +231,6 @@ class Information extends CI_Controller
} }
if ($Structure->is_sitecode == 'ct') { if ($Structure->is_sitecode == 'ct') {
$data['infoTypeList'] = $this->config->item('InfoType_ct'); $data['infoTypeList'] = $this->config->item('InfoType_ct');
} elseif ($Structure->is_sitecode == 'ah') { } elseif ($Structure->is_sitecode == 'ah') {
@ -278,7 +278,6 @@ class Information extends CI_Controller
} }
$data['templateList'] = $this->config->item('templates'); $data['templateList'] = $this->config->item('templates');
//翰特产品类型 //翰特产品类型
$data['productTypeList'] = $this->config->item('ProductType_HT'); $data['productTypeList'] = $this->config->item('ProductType_HT');
@ -326,15 +325,15 @@ class Information extends CI_Controller
$data['all_tags'] = array_filter($data['all_tags']); $data['all_tags'] = array_filter($data['all_tags']);
} }
//获取移动优先的模板,如果有的话 //获取移动优先的模板,如果有的话
$mobile_first_template_path='mobile_first/'.$this->config->item('site_code'); $mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
if(is_file(APPPATH.'views/'.$mobile_first_template_path.EXT)){ 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模板替换 $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); $data['mobile_first_template'] = $this->load->view($mobile_first_template_path, '', TRUE);
$data['mobile_first_template']=str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $data['mobile_first_template']); $data['mobile_first_template'] = str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $data['mobile_first_template']);
}else{ } else {
$data['mobile_first_template']='没有找到移动模板'; $data['mobile_first_template'] = '没有找到移动模板';
} }
$this->load->view('bootstrap3/header', $data); $this->load->view('bootstrap3/header', $data);
$this->load->view('bootstrap3/information_edit'); $this->load->view('bootstrap3/information_edit');
@ -342,15 +341,15 @@ class Information extends CI_Controller
} }
/** /**
public function redirect($jumpUrl){ * public function redirect($jumpUrl){
*
header('HTTP/1.1 301 Moved Permanently'); * header('HTTP/1.1 301 Moved Permanently');
*
header($jumpUrl);// 301 跳转到设置的 url * header($jumpUrl);// 301 跳转到设置的 url
*
exit(); * exit();
*
} */ * } */
public function test_proxy($url = false) public function test_proxy($url = false)
{ {
$curl = curl_init(); $curl = curl_init();
@ -448,7 +447,7 @@ class Information extends CI_Controller
if (!empty($amp_result)) { if (!empty($amp_result)) {
$amp_result = json_decode($amp_result); $amp_result = json_decode($amp_result);
if ($amp_result->result == 'ok') { if ($amp_result->result == 'ok') {
$amp_save_result = $this->amplib->edit_save($information->ic_id, $amp_result->data->amp, '1'); $amp_save_result = $this->amplib->edit_save($information->ic_id, $amp_result->data->amp, '1');
if (!empty($amp_save_result)) { if (!empty($amp_save_result)) {
$amp_save_result = json_decode($amp_save_result); $amp_save_result = json_decode($amp_save_result);
if ($amp_save_result->name == 'no') { if ($amp_save_result->name == 'no') {
@ -483,17 +482,17 @@ class Information extends CI_Controller
if (strcasecmp($site_code, "gm") == 0 && !empty($auto_update_cache)) { if (strcasecmp($site_code, "gm") == 0 && !empty($auto_update_cache)) {
$update_info_log = $this->update_cache($ic_url, true); $update_info_log = $this->update_cache($ic_url, true);
}else if (strcasecmp($site_code, "ch") == 0 && !empty($auto_update_cache)) { } else if (strcasecmp($site_code, "ch") == 0 && !empty($auto_update_cache)) {
//读取模板生成PC和移动优先文件 //读取模板生成PC和移动优先文件
$this->make_mobile_html($information); $this->make_mobile_html($information);
$this->make_pc_html($information); $this->make_pc_html($information);
} 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)) {
$update_info_log = $this->update_cache($ic_url); $update_info_log = $this->update_cache($ic_url);
} else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0 && strcasecmp($site_code, "ah") != 0) { //非cht站点并且非GM并且非AH } else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0 && strcasecmp($site_code, "ah") != 0) { //非cht站点并且非GM并且非AH
$update_info_log = $this->update_cache($ic_url); $update_info_log = $this->update_cache($ic_url);
}else if (strcasecmp($site_code, "ct") == 0 && !empty($auto_update_cache)) { } else if (strcasecmp($site_code, "ct") == 0 && !empty($auto_update_cache)) {
$update_info_log = $this->update_cache($ic_url); $update_info_log = $this->update_cache($ic_url);
} }
@ -558,154 +557,212 @@ class Information extends CI_Controller
return true; return true;
} }
function make_mobile_html($information){ function make_mobile_html($information)
$data=array(); {
//获取移动优先的模板,如果有的话 $data = array();
$mobile_first_template_path='mobile_first/'.$this->config->item('site_code'); //获取移动优先的模板,如果有的话
if(is_file(APPPATH.'views/'.$mobile_first_template_path.EXT)){ $mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
$mobile_template=$this->load->view($mobile_first_template_path, '', TRUE); if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) {
}else{ $mobile_template = $this->load->view($mobile_first_template_path, '', TRUE);
return false; } else {
} return false;
$mobile_template=str_replace('<!--@TITLE@-->', $this->input->post('ic_seo_title'), $mobile_template); }
$mobile_template=str_replace('<!--@DESCRIPTION@-->', $this->input->post('ic_seo_description'), $mobile_template); $mobile_template = str_replace('<!--@TITLE@-->', $this->input->post('ic_seo_title'), $mobile_template);
$mobile_template=str_replace('<!--@KEYWORDS@-->', $this->input->post('ic_seo_keywords'), $mobile_template); $mobile_template = str_replace('<!--@DESCRIPTION@-->', $this->input->post('ic_seo_description'), $mobile_template);
$mobile_template=str_replace('<!--@CANONICAL@-->', $this->input->post('site_url').$this->input->post('ic_url'), $mobile_template); $mobile_template = str_replace('<!--@KEYWORDS@-->', $this->input->post('ic_seo_keywords'), $mobile_template);
$mobile_template_H1=$this->call_mobile_template_H1($mobile_first_template_path,$this->input->post('is_path'),$this->input->post('ic_author'),$this->input->post('ic_title'),$this->input->post('ic_photo'));//H1模板替换 $mobile_template = str_replace('<!--@CANONICAL@-->', $this->input->post('site_url') . $this->input->post('ic_url'), $mobile_template);
$mobile_template=str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $mobile_template); $mobile_template_H1 = $this->call_mobile_template_H1($mobile_first_template_path, $this->input->post('is_path'), $this->input->post('ic_author'), $this->input->post('ic_title'), $this->input->post('ic_photo'));//H1模板替换
$mobile_template=str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $mobile_template); $mobile_template = str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $mobile_template);
$template_NEXT=$this->call_mobile_template_NEXT($mobile_first_template_path,$this->input->post('is_id')); $mobile_template = str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $mobile_template);
$mobile_template=str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $mobile_template); $template_NEXT = $this->call_mobile_template_NEXT($mobile_first_template_path, $this->input->post('is_id'));
$mobile_template = str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $mobile_template);
//社媒分享图片 //社媒分享图片
if(!empty($information->ic_photo)){ if (!empty($information->ic_photo)) {
$full_ic_photo=$this->config->item('site_image_url').$information->ic_photo; $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
$mobile_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">', $mobile_template); $mobile_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">', $mobile_template);
} }
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
$mobile_html=$this->config->item('cache')[$this->config->item('site_code')]['cache_path'].$this->input->post('ic_url'); $mobile_html = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $this->input->post('ic_url');
$mobile_html=str_replace("\\", "/", $mobile_html); $mobile_html = str_replace("\\", "/", $mobile_html);
if(substr($mobile_html, -1, 1)== '/'){ if (substr($mobile_html, -1, 1) == '/') {
$mobile_html=$mobile_html.'index.htm'; $mobile_html = $mobile_html . 'index.htm';
} }
$mobile_html.='-mobile.htm'; $mobile_html .= '-mobile.htm';
create_folder_by_path(dirname($mobile_html)); create_folder_by_path(dirname($mobile_html));
file_put_contents($mobile_html, $mobile_template, LOCK_EX); file_put_contents($mobile_html, $mobile_template, LOCK_EX);
} }
function make_pc_html($information){ function make_pc_html($information)
$data=array(); {
$data = array();
//获取PC的模板如果有的话 //获取PC的模板如果有的话
$template_path='mobile_first/'.$this->config->item('site_code'); $template_path = 'mobile_first/' . $this->config->item('site_code');
if(is_file(APPPATH.'views/'.$template_path.'-pc'.EXT)){ if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
$template=$this->load->view($template_path.'-pc', '', TRUE); $template = $this->load->view($template_path . '-pc', '', TRUE);
}else{ } else {
return false; return false;
} }
$template=str_replace('<!--@TITLE@-->', $this->input->post('ic_seo_title'), $template); $template = str_replace('<!--@TITLE@-->', $this->input->post('ic_seo_title'), $template);
$template=str_replace('<!--@DESCRIPTION@-->', $this->input->post('ic_seo_description'), $template); $template = str_replace('<!--@DESCRIPTION@-->', $this->input->post('ic_seo_description'), $template);
$template=str_replace('<!--@KEYWORDS@-->', $this->input->post('ic_seo_keywords'), $template); $template = str_replace('<!--@KEYWORDS@-->', $this->input->post('ic_seo_keywords'), $template);
$template=str_replace('<!--@CANONICAL@-->', $this->input->post('site_url').$this->input->post('ic_url'), $template); $template = str_replace('<!--@CANONICAL@-->', $this->input->post('site_url') . $this->input->post('ic_url'), $template);
$template_H1=$this->call_mobile_template_H1($template_path,$this->input->post('is_path'),$this->input->post('ic_author'),$this->input->post('ic_title'),$this->input->post('ic_photo'));//H1模板替换 $template_H1 = $this->call_mobile_template_H1($template_path, $this->input->post('is_path'), $this->input->post('ic_author'), $this->input->post('ic_title'), $this->input->post('ic_photo'));//H1模板替换
$template=str_replace('<!--@HEAD_1@-->', $template_H1, $template); $template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
$template=str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $template); $template = str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $template);
$template_NEXT=$this->call_mobile_template_NEXT($template_path,$this->input->post('is_id')); $template_NEXT = $this->call_mobile_template_NEXT($template_path, $this->input->post('is_id'));
$template=str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $template); $template = str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $template);
//社媒分享图片 //社媒分享图片
if(!empty($information->ic_photo)){ if (!empty($information->ic_photo)) {
$full_ic_photo=$this->config->item('site_image_url').$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 = 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);
} }
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
$html_path=$this->config->item('cache')[$this->config->item('site_code')]['cache_path'].$this->input->post('ic_url'); $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $this->input->post('ic_url');
$html_path=str_replace("\\", "/", $html_path); $html_path = str_replace("\\", "/", $html_path);
if(substr($html_path, -1, 1)== '/'){ if (substr($html_path, -1, 1) == '/') {
$html_path=$html_path.'index.htm'; $html_path = $html_path . 'index.htm';
} }
$html_path.='-pc.htm'; $html_path .= '-pc.htm';
create_folder_by_path(dirname($html_path)); create_folder_by_path(dirname($html_path));
file_put_contents($html_path, $template, LOCK_EX); 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['author']=$this->Operator_model->get_author_nikename($ic_author);//获取作者信息 $data['infocategory'] = $this->Information_model->get_detail_by_path($is_path, 1);//信息所属分类,获取信息顶级节点内容
$data['ic_title']=$ic_title; $data['author'] = $this->Operator_model->get_author_nikename($ic_author);//获取作者信息
$data['ic_photo']=$ic_photo; $data['ic_title'] = $ic_title;
return $this->load->view($mobile_first_template_path.'-h1', $data, TRUE); $data['ic_photo'] = $ic_photo;
return $this->load->view($mobile_first_template_path . '-h1', $data, TRUE);
} }
function call_mobile_template_NEXT($template_path,$is_id){ //通过内容找到第一张图片
$data['detail']=$this->Information_model->Detail($is_id);//信息所属分类,获取信息顶级节点内容 function set_photo_content($ic_photo, $ic_content)
$data['root_detail']=$this->Information_model->get_detail_by_path($data['detail']->is_path,1);//信息所属分类,获取信息顶级节点内容 {
//how to plan if (empty($ic_photo)) {
$data['info_howtoplan']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('how','plan')); $images = get_image_url_by_source($ic_content);
if(empty($data['info_howtoplan'])){//找不到对应信息则显示备用 if (!empty($images)) {
$data['info_howtoplan']=$this->Information_model->Detail('/travelguide/plan-first-trip.htm'); return $images[1][0];
}
$data['info_howtoplan_root']=$this->Information_model->get_detail_by_path($data['info_howtoplan']->is_path,1);//信息所属分类,获取信息顶级节点内容
if(!empty($data['info_howtoplan'])){
if(empty($data['info_howtoplan']->ic_photo)){
$images=get_image_url_by_source($data['info_howtoplan']->ic_content);
if(!empty($images)){
$data['info_howtoplan']->ic_photo=$images[1][0];
}
}else{
$data['info_howtoplan']->ic_photo=$this->config->item('site_image_url').$data['info_howtoplan']->ic_photo;
} }
} else {
return $this->config->item('site_image_url') . $ic_photo;
} }
//best time to visit return '';
$data['info_besttime']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('best','time')); }
if(empty($data['info_besttime'])){
$data['info_besttime']=$this->Information_model->Detail('/weather/china-best-times.htm'); function call_mobile_template_NEXT($template_path, $is_id)
} {
$data['info_besttime_root']=$this->Information_model->get_detail_by_path($data['info_besttime']->is_path,1);//信息所属分类,获取信息顶级节点内容 $data['detail'] = $this->Information_model->Detail($is_id);//信息所属分类,获取信息顶级节点内容
if(!empty($data['info_besttime'])){ $data['type_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 0);//信息所属分组,根据分组进行不同推荐
if(empty($data['info_besttime']->ic_photo)){ $data['root_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 1);//信息所属分类,获取信息顶级节点内容
$images=get_image_url_by_source($data['info_besttime']->ic_content);
if(!empty($images)){ switch (strtolower($data['type_detail']->ic_url_title)) {
$data['info_besttime']->ic_photo=$images[1][0]; case 'inspiration':
//随机获取两个同级节点内容
$random_array = $this->Information_model->random(2, $data['detail']->is_parent_id, array($data['detail']->is_id));
if (!empty($random_array[0])) {
$data['info_howtoplan'] = $random_array[0];
$data['info_howtoplan_root'] = $data['root_detail'];
$data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
} }
}else{ if (!empty($random_array[1])) {
$data['info_besttime']->ic_photo=$this->config->item('site_image_url').$data['info_besttime']->ic_photo; $data['info_besttime'] = $random_array[1];
} $data['info_besttime_root'] = $data['root_detail'];
} $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
//top things to do
$data['info_topthings']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('top','things'));
if(empty($data['info_topthings'])){
$data['info_topthings']=$this->Information_model->Detail('/travelguide/article-top-china-tourist-destination.htm');
}
$data['info_topthings_root']=$this->Information_model->get_detail_by_path($data['info_topthings']->is_path,1);//信息所属分类,获取信息顶级节点内容
if(!empty($data['info_topthings'])){
if(empty($data['info_topthings']->ic_photo)){
$images=get_image_url_by_source($data['info_topthings']->ic_content);
if(!empty($images)){
$data['info_topthings']->ic_photo=$images[1][0];
} }
}else{ //漏斗作用的页面,随机挑选一篇
$data['info_topthings']->ic_photo=$this->config->item('site_image_url').$data['info_topthings']->ic_photo; $random_array = array(
} '/travelguide/china-facts.htm',
} '/travelguide/article-top-china-tourist-destination.htm',
//hotel , where to stay '/travelguide/most-beautiful-places.htm',
$data['info_hotel']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('hotel')); '/weather/china-best-times.htm',
if(empty($data['info_hotel'])){ '/travelguide/article-10-movies-to-watch.htm',
$data['info_hotel']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('where','stay')); '/travelguide/article-culture-shock-in-china.htm',
} '/travelguide/article-what-chinese-eat-for-breakfast.htm',
if(empty($data['info_hotel'])){ '/travelguide/china-top-10-attractions.htm',
$data['info_hotel']=$this->Information_model->Detail('/travelguide/most-beautiful-places.htm'); '/travelguide/chinese-food/eight-chinese-dishes.htm',
} '/travelguide/china-travel-reopen-restrictions.htm'
$data['info_hotel_root']=$this->Information_model->get_detail_by_path($data['info_hotel']->is_path,1);//信息所属分类,获取信息顶级节点内容 );
if(!empty($data['info_hotel'])){ $data['info_topthings'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
if(empty($data['info_hotel']->ic_photo)){ if (!empty($data['info_topthings'])) {
$images=get_image_url_by_source($data['info_hotel']->ic_content); $data['info_topthings_root'] = $data['root_detail'];
if(!empty($images)){ $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
$data['info_hotel']->ic_photo=$images[1][0];
} }
}else{ //文化板块的页面,随机挑选一篇
$data['info_hotel']->ic_photo=$this->config->item('site_image_url').$data['info_hotel']->ic_photo; $random_array = array(
} '/travelguide/chinese-zodiac/',
'/travelguide/culture/china-arts-crafts.htm',
'/beijing/forbidden-city/',
'/travelguide/culture/traditionalmedichine.htm',
'/travelguide/chinese-tea/',
'/travelguide/kungfu/',
'/travelguide/culture/china-history.htm',
'/travelguide/chinese-food/',
'/travelguide/chinese-language/'
);
$data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
if (!empty($data['info_hotel'])) {
$data['info_hotel_root'] = $data['root_detail'];
$data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
}
break;
case 'destination':
//how to plan
$data['info_howtoplan'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('how', 'plan'));
if (empty($data['info_howtoplan'])) {//找不到对应信息则显示备用
$data['info_howtoplan'] = $this->Information_model->Detail('/travelguide/plan-first-trip.htm');
}
$data['info_howtoplan_root'] = $this->Information_model->get_detail_by_path($data['info_howtoplan']->is_path, 1);//信息所属分类,获取信息顶级节点内容
if (!empty($data['info_howtoplan'])) {
$data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
}
//best time to visit
$data['info_besttime'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('best', 'time'));
if (empty($data['info_besttime'])) {
$data['info_besttime'] = $this->Information_model->Detail('/weather/china-best-times.htm');
}
$data['info_besttime_root'] = $this->Information_model->get_detail_by_path($data['info_besttime']->is_path, 1);//信息所属分类,获取信息顶级节点内容
if (!empty($data['info_besttime'])) {
$data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
}
//top things to do
$data['info_topthings'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('top', 'things'));
if (empty($data['info_topthings'])) {
$data['info_topthings'] = $this->Information_model->Detail('/travelguide/article-top-china-tourist-destination.htm');
}
$data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1);//信息所属分类,获取信息顶级节点内容
if (!empty($data['info_topthings'])) {
$data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
}
//hotel , where to stay
$data['info_hotel'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('hotel'));
if (empty($data['info_hotel'])) {
$data['info_hotel'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('where', 'stay'));
}
if (empty($data['info_hotel'])) {
$data['info_hotel'] = $this->Information_model->Detail('/travelguide/most-beautiful-places.htm');
}
$data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);//信息所属分类,获取信息顶级节点内容
if (!empty($data['info_hotel'])) {
$data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
}
break;
case 'planing-1(guide)':
case 'planning-2 (decision tips)':
$random_array = array(
'/feedback/',
'/travelguide/how-chinahighlights-selects-your-hotel.htm',
'/travelguide/article-private-tour-vs-group-tour.htm',
'/aboutus/who-recommended.htm',
'/aboutus/no-shops.htm',
'/aboutus/company-history.htm'
);
break;
default:
} }
return $this->load->view($template_path.'-next', $data, TRUE);
return $this->load->view($template_path . '-next', $data, TRUE);
} }
//更新静态文件 //更新静态文件
@ -746,9 +803,9 @@ class Information extends CI_Controller
//if ($delete_only) { //if ($delete_only) {
// $url = "http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url); // $url = "http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url);
//} else { //} else {
//先删除再生成,部分页面没有在信息平台中 //先删除再生成,部分页面没有在信息平台中
GET_HTTP("http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url)); GET_HTTP("http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url));
$url = "http://144.76.185.44:8029/gm.php/information/detail/?static_html_url=" . $url; $url = "http://144.76.185.44:8029/gm.php/information/detail/?static_html_url=" . $url;
//} //}
break; break;
@ -806,7 +863,7 @@ class Information extends CI_Controller
break; break;
case 'ct': //子站点使用 case 'ct': //子站点使用
$url = 'http://50.97.246.187:22223' . $url; $url = 'http://50.97.246.187:22223' . $url;
break; break;
case 'sht': case 'sht':
case 'gl': case 'gl':
@ -859,8 +916,7 @@ class Information extends CI_Controller
$url = isset($tempu['path']) ? $tempu['path'] : '/'; $url = isset($tempu['path']) ? $tempu['path'] : '/';
$pad = $tempu['host']; $pad = $tempu['host'];
$flag = true; $flag = true;
} } //如果传递进来的url没有域名则使用当前站点的信息进行判断
//如果传递进来的url没有域名则使用当前站点的信息进行判断
else { else {
$url = str_replace($this->config->item('site_url'), '', $url); $url = str_replace($this->config->item('site_url'), '', $url);
$pad = str_replace('http://', '', $this->config->item('site_url')); $pad = str_replace('http://', '', $this->config->item('site_url'));
@ -905,11 +961,11 @@ class Information extends CI_Controller
function backup_content($log_id) function backup_content($log_id)
{ {
$data['log_info'] = $this->Logs_model->read($log_id); $data['log_info'] = $this->Logs_model->read($log_id);
if($data['log_info']->log_action == 'backup_amp'){ if ($data['log_info']->log_action == 'backup_amp') {
$data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id,true); $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id, true);
}else{ } else {
$data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id); $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id);
} }
$this->load->view('bootstrap/header', $data); $this->load->view('bootstrap/header', $data);
$this->load->view('bootstrap/information_backup_content'); $this->load->view('bootstrap/information_backup_content');
$this->load->view('bootstrap/footer'); $this->load->view('bootstrap/footer');

@ -77,6 +77,17 @@ class Information_model extends CI_Model {
return $this->GetList(); return $this->GetList();
} }
//在同级别下随机获取N条数据并且排除某些id
function random($topnum,$is_parent_id,array $exclude_ids){
$this->init();
$this->topNum = $topnum;
$this->search = " AND is_parent_id =". $this->HT->escape($is_parent_id);
$exclude_ids_string=implode(',',$exclude_ids);
$this->search .= " AND is_id NOT in ($exclude_ids_string,0)";
$this->orderBy = " ORDER BY NewID() ";
return $this->GetList();
}
//根据url搜索信息 //根据url搜索信息
function search_url($url) { function search_url($url) {
$this->init(); $this->init();

@ -92,7 +92,7 @@
<li class="start-nav-item"><a href="/guilin/tours.htm">Guilin</a></li> <li class="start-nav-item"><a href="/guilin/tours.htm">Guilin</a></li>
<li class="start-nav-item"><a href="/zhangjiajie/tours.htm">Zhangjiajie</a></li> <li class="start-nav-item"><a href="/zhangjiajie/tours.htm">Zhangjiajie</a></li>
<li class="start-nav-item"><a href="/yunnan/tours.htm">Yunnan</a></li> <li class="start-nav-item"><a href="/yunnan/tours.htm">Yunnan</a></li>
<li class="start-nav-item"><a href="/huangshantours.htm">Huangshan</a></li> <li class="start-nav-item"><a href="/huangshan/tours.htm">Huangshan</a></li>
<li class="start-nav-item"><a href="/xian/tours.htm">Xi&#39;an</a></li> <li class="start-nav-item"><a href="/xian/tours.htm">Xi&#39;an</a></li>
<li class="start-nav-item"><a href="/chengdu/tours.htm">Chengdu</a></li> <li class="start-nav-item"><a href="/chengdu/tours.htm">Chengdu</a></li>
</li> </li>

Loading…
Cancel
Save