You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/application/controllers/information.php

3685 lines
164 KiB
PHTML

<?php
2 years ago
if (!defined('BASEPATH')) {
1 year ago
exit('No direct script access allowed');
2 years ago
}
class Information extends CI_Controller
{
2 years ago
public function __construct()
{
parent::__construct();
$this->permission->is_admin();
//$this->output->enable_profiler(TRUE);
$this->load->model('Area_model');
$this->load->model('Information_model');
$this->load->model('InfoContents_model');
$this->load->model('InfoStructures_model');
$this->load->model('Landscape_model');
$this->load->model('Operator_model');
$this->load->model('Logs_model');
$this->load->model('InfoMetas_model');
$this->load->model('Infoauthors_model');
$this->load->model('InfoSMS_model');
$this->load->model('recommends_and_tips_model');
$this->load->model('trippest_model'); //trippest产品
$this->load->model('Feedback_model');
$this->load->model('Price_model');
$this->load->model('PrimeLinePrice_model');
$this->load->library('Amplib'); //加载AMP处理类
$this->load->library('Currency');
$this->load->library('html_optimize_lib'); //加载HTML优化类
}
public function index()
{
echo '信息首页';
}
public function add($is_parent_id)
{
//添加空内容.
$this->InfoContents_model->Add('', 'New Information', '', '', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', 0, '', 0, '', '');
$infocontent = $this->InfoContents_model->get_ic_contents($this->InfoContents_model->insert_id);
1 year ago
if (!empty($infocontent) && $this->InfoStructures_model->Add($is_parent_id, $this->InfoContents_model->insert_id)) {
2 years ago
$is_id = $this->InfoStructures_model->insert_id;
$InfoStructures = $this->InfoStructures_model->Detail($is_id);
$InfoStructures->is_id = $is_id;
$data[] = array('name' => 'ok', 'value' => $InfoStructures);
$this->Logs_model->add($this->InfoStructures_model->insert_id);
} else {
$data[] = array('name' => 'no', 'value' => $this->lang->line('form_info_error'));
}
echo json_encode($data);
return true;
}
//移动结构顺序
public function move()
{
//网站会提交一个同级节点id列表字符串按照这个去排序
$parent_id = $this->input->post('pid');
$idsStr = $this->input->post('ids');
$idsArray = explode(',', $idsStr);
foreach ($idsArray as $key => $value) {
if ($value) {
//设置排序
$this->InfoStructures_model->set_sort($value, $key);
//设置path
$this->InfoStructures_model->set_path($parent_id, $value);
}
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('structures_success_move'));
echo json_encode($data);
$this->Logs_model->move($idsStr);
return true;
}
//把文章移动到任意板块文章下
//is_id 信息结构IDis_parent_id即将转移到的信息结构id
public function move_by_is_id()
{
$data = array();
$is_id = $this->input->post('is_id');
$is_parent_id = $this->input->post('is_parent_id');
1 year ago
if ($is_id == $is_parent_id || empty($is_id) || empty($is_parent_id)) {
2 years ago
return false;
}
//即将移动到文章结构信息
$Structure = $this->InfoStructures_model->Detail($is_id);
//目标文章结构信息
$Structure_parent = $this->InfoStructures_model->Detail($is_parent_id);
//只能移动到本站点下
if ($Structure->is_sitecode == $Structure_parent->is_sitecode) {
//不能搬迁到自己的子节点下
if (strpos(',' . $Structure_parent->is_path, ',' . $is_id . ',') == false) {
$this->InfoStructures_model->set_path($is_parent_id, $is_id);
}
//信息的区域类型和id也要修改 todo
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('structures_success_move'));
echo json_encode($data);
$this->Logs_model->move($is_id);
return true;
}
//[国际->国际]复制节点结构到任意站点的节点下面。-- lmr
2 years ago
//is_id 信息结构ID
2 years ago
public function copy_by_is_id($src_is_id, $dest_is_id)
{
1 year ago
if (empty($src_is_id) || empty($src_is_id)) {
echo 'need 2 is_id v1';
return false;
}
$data = array();
1 year ago
if ($src_is_id == $dest_is_id || empty($src_is_id) || empty($dest_is_id)) {
echo 'need 2 is_id v2';
return false;
}
// 源节点
$src = $this->InfoStructures_model->Detail($src_is_id);
$src_path = $this->Information_model->get_list_by_path($src->is_path, false, $src->is_sitecode);
// 源子节点
foreach ($src_path as $n => $item) {
if ($item->is_id === $src->is_id) {
unset($src_path[$n]);
}
}
// 目标节点结构
$dest = $this->InfoStructures_model->Detail($dest_is_id);
$dest_path = $this->Information_model->get_list_by_path($dest->is_path, false, $dest->is_sitecode);
// 目标子节点
foreach ($dest_path as $n => $item) {
if ($item->is_id === $dest->is_id) {
unset($dest_path[$n]);
}
}
// 新旧节点对应表
$node_map = array();
// 循环复制各个层级的节点。
foreach ($src_path as $n => $item) {
// 定位复制的父节点
$target_is_id = $dest->is_id;
foreach ($node_map as $old => $new) {
if ($item->is_parent_id == $old) {
$target_is_id = $new;
}
}
// info_content
$item_info_content = $this->InfoContents_model->get_ic_contents2($item->is_ic_id);
$this->InfoContents_model->Add_with_sitecode(
$item_info_content->ic_url,
$item_info_content->ic_url_title,
$item_info_content->ic_type,
$item_info_content->ic_title,
$item_info_content->ic_content,
$item_info_content->ic_summary,
$item_info_content->ic_seo_title,
$item_info_content->ic_seo_description,
$item_info_content->ic_seo_keywords,
$item_info_content->ic_show_bread_crumbs,
$item_info_content->ic_status,
$item_info_content->ic_template,
$item_info_content->ic_photo,
$item_info_content->ic_photo_width,
$item_info_content->ic_photo_height,
$item_info_content->ic_recommend_tours,
$item_info_content->ic_recommend_packages,
$item_info_content->ic_ht_area_id,
$item_info_content->ic_ht_area_type,
$item_info_content->ic_ht_product_id,
$item_info_content->ic_ht_product_type,
$item_info_content->ic_author,
$dest->is_sitecode
);
// info_meta
$item_meta_amp = $this->InfoMetas_model->get($item->is_ic_id, 'AMP');
$item_meta_ampbody = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_BODY');
$item_meta_ampcss = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_CSS');
$item_meta_ampscript = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_SCRIPT');
$item_meta_ampjson = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_JSON');
$item_meta_ampstatus = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_STATUS');
$item_meta_pcstatus = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_BODY_PC_STATUS');
$item_meta_pcbody = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_BODY_PC');
$item_meta_pccss = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_CSS_PC');
$item_meta_pcschema = $this->InfoMetas_model->get($item->is_ic_id, 'AMP_SCHEMA');
1 year ago
if (!empty($item_meta_amp))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP', $item_meta_amp);
1 year ago
if (!empty($item_meta_ampbody))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_BODY', $item_meta_ampbody);
1 year ago
if (!empty($item_meta_ampcss))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_CSS', $item_meta_ampcss);
1 year ago
if (!empty($item_meta_ampscript))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_SCRIPT', $item_meta_ampscript);
1 year ago
if (!empty($item_meta_ampjson))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_JSON', $item_meta_ampjson);
1 year ago
if (!empty($item_meta_ampstatus))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_STATUS', $item_meta_ampstatus);
1 year ago
if (!empty($item_meta_pcstatus))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_BODY_PC_STATUS', $item_meta_pcstatus);
1 year ago
if (!empty($item_meta_pcbody))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_BODY_PC', $item_meta_pcbody);
1 year ago
if (!empty($item_meta_pccss))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_CSS_PC', $item_meta_pccss);
1 year ago
if (!empty($item_meta_pcschema))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_SCHEMA', $item_meta_pcschema);
// gm 补充meta
$item_meta_addon_css = $this->InfoMetas_model->get($item->is_ic_id, 'meta_addon_css');
1 year ago
if (!empty($item_meta_addon_css))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_addon_css', $item_meta_addon_css);
$item_meta_addon_js = $this->InfoMetas_model->get($item->is_ic_id, 'meta_addon_js');
1 year ago
if (!empty($item_meta_addon_js))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_addon_js', $item_meta_addon_js);
$item_meta_use_list_picture = $this->InfoMetas_model->get($item->is_ic_id, 'meta_use_list_picture');
1 year ago
if (!empty($item_meta_use_list_picture))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_use_list_picture', $item_meta_use_list_picture);
// 添加节点
$this->InfoStructures_model->Add_with_sitecode($target_is_id, $this->InfoContents_model->insert_id, 999, $dest->is_sitecode);
$node_map[$item->is_id] = $this->InfoStructures_model->insert_id;
}
print_r($node_map);
// print_r($src);
// print_r($src_path);
// print_r($dest);
// print_r($dest_path);
//返回状态
$data[] = array('name' => 'ok', 'value' => 'copy_by_is_id() success!');
echo json_encode($data);
return true;
}
1 year ago
//[国际<-][int.mycht.cn]-- lmr
//is_id 信息结构ID
public function copy_by_is_id_gm($src_is_id, $dest_is_id)
{
1 year ago
if (empty($src_is_id) || empty($src_is_id)) {
echo 'need 2 is_id v1';
1 year ago
return false;
}
2 years ago
$data = array();
1 year ago
if ($src_is_id == $dest_is_id || empty($src_is_id) || empty($dest_is_id)) {
echo 'need 2 is_id v2';
2 years ago
return false;
}
2 years ago
// 源节点
$src = $this->InfoStructures_model->Detail_gm($src_is_id);
1 year ago
$src_path = $this->Information_model->get_list_by_path_gm($src->is_path, false, $src->is_sitecode);
2 years ago
// 源子节点
foreach ($src_path as $n => $item) {
2 years ago
if ($item->is_id === $src->is_id) {
2 years ago
unset($src_path[$n]);
2 years ago
}
}
2 years ago
// 目标节点结构
2 years ago
$dest = $this->InfoStructures_model->Detail($dest_is_id);
$dest_path = $this->Information_model->get_list_by_path($dest->is_path, false, $dest->is_sitecode);
2 years ago
// 目标子节点
foreach ($dest_path as $n => $item) {
if ($item->is_id === $dest->is_id) {
unset($dest_path[$n]);
}
}
2 years ago
// 新旧节点对应表
$node_map = array();
// 循环复制各个层级的节点。
foreach ($src_path as $n => $item) {
2 years ago
2 years ago
// 定位复制的父节点
$target_is_id = $dest->is_id;
foreach ($node_map as $old => $new) {
if ($item->is_parent_id == $old) {
$target_is_id = $new;
}
2 years ago
}
2 years ago
// info_content
1 year ago
$item_info_content = $this->InfoContents_model->get_ic_contents2_gm($item->is_ic_id);
2 years ago
$this->InfoContents_model->Add_with_sitecode(
$item_info_content->ic_url,
$item_info_content->ic_url_title,
$item_info_content->ic_type,
$item_info_content->ic_title,
$item_info_content->ic_content,
$item_info_content->ic_summary,
$item_info_content->ic_seo_title,
$item_info_content->ic_seo_description,
$item_info_content->ic_seo_keywords,
$item_info_content->ic_show_bread_crumbs,
$item_info_content->ic_status,
$item_info_content->ic_template,
$item_info_content->ic_photo,
$item_info_content->ic_photo_width,
$item_info_content->ic_photo_height,
$item_info_content->ic_recommend_tours,
$item_info_content->ic_recommend_packages,
$item_info_content->ic_ht_area_id,
$item_info_content->ic_ht_area_type,
$item_info_content->ic_ht_product_id,
$item_info_content->ic_ht_product_type,
$item_info_content->ic_author,
$dest->is_sitecode
);
// info_meta
1 year ago
$item_meta_amp = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP');
$item_meta_ampbody = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_BODY');
$item_meta_ampcss = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_CSS');
$item_meta_ampscript = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_SCRIPT');
$item_meta_ampjson = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_JSON');
$item_meta_ampstatus = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_STATUS');
$item_meta_pcstatus = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_BODY_PC_STATUS');
$item_meta_pcbody = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_BODY_PC');
$item_meta_pccss = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_CSS_PC');
$item_meta_pcschema = $this->InfoMetas_model->get_gm($item->is_ic_id, 'AMP_SCHEMA');
2 years ago
1 year ago
if (!empty($item_meta_amp))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP', $item_meta_amp);
1 year ago
if (!empty($item_meta_ampbody))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_BODY', $item_meta_ampbody);
1 year ago
if (!empty($item_meta_ampcss))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_CSS', $item_meta_ampcss);
1 year ago
if (!empty($item_meta_ampscript))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_SCRIPT', $item_meta_ampscript);
1 year ago
if (!empty($item_meta_ampjson))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_JSON', $item_meta_ampjson);
1 year ago
if (!empty($item_meta_ampstatus))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_STATUS', $item_meta_ampstatus);
1 year ago
if (!empty($item_meta_pcstatus))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_BODY_PC_STATUS', $item_meta_pcstatus);
1 year ago
if (!empty($item_meta_pcbody))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_BODY_PC', $item_meta_pcbody);
1 year ago
if (!empty($item_meta_pccss))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_CSS_PC', $item_meta_pccss);
1 year ago
if (!empty($item_meta_pcschema))
2 years ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_SCHEMA', $item_meta_pcschema);
1 year ago
// gm 补充meta
1 year ago
$item_meta_addon_css = $this->InfoMetas_model->get_gm($item->is_ic_id, 'meta_addon_css');
1 year ago
if (!empty($item_meta_addon_css))
1 year ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_addon_css', $item_meta_addon_css);
1 year ago
$item_meta_addon_js = $this->InfoMetas_model->get_gm($item->is_ic_id, 'meta_addon_js');
1 year ago
if (!empty($item_meta_addon_js))
1 year ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_addon_js', $item_meta_addon_js);
1 year ago
$item_meta_use_list_picture = $this->InfoMetas_model->get_gm($item->is_ic_id, 'meta_use_list_picture');
1 year ago
if (!empty($item_meta_use_list_picture))
1 year ago
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_use_list_picture', $item_meta_use_list_picture);
1 year ago
$item_meta_product_code = $this->InfoMetas_model->get_gm($item->is_ic_id, 'meta_product_code');
if (!empty($item_meta_product_code))
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'meta_product_code', $item_meta_product_code);
2 years ago
// 添加节点
$this->InfoStructures_model->Add_with_sitecode($target_is_id, $this->InfoContents_model->insert_id, 999, $dest->is_sitecode);
$node_map[$item->is_id] = $this->InfoStructures_model->insert_id;
2 years ago
}
print_r($node_map);
2 years ago
// print_r($src);
// print_r($src_path);
// print_r($dest);
// print_r($dest_path);
2 years ago
//返回状态
$data[] = array('name' => 'ok', 'value' => 'copy_by_is_id() success!');
echo json_encode($data);
return true;
}
public function delete($is_id)
{
//查询结构信息
$Structure = $this->InfoStructures_model->Detail($is_id);
if ($Structure == false) {
$data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_notfound'));
echo json_encode($data);
return false;
}
if ($this->InfoStructures_model->HasChild($Structure->is_id)) {
$data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_haschild'));
echo json_encode($data);
return false;
} else {
$info_detail = $this->Information_model->Detail($is_id);
//删除前备份amp的meta标签-isid。
2 years ago
//$meta_value = $this->InfoMetas_model->get($info_detail->ic_id, 'AMP_JSON');
//if ($meta_value) {
// $this->Logs_model->backup_meta($info_detail->ic_id, $meta_value, 'AMP_JSON_' . $is_id);
//}
2 years ago
$this->Logs_model->delete($is_id, $info_detail->ic_content);
1 year ago
if (!empty($info_detail->ic_summary)) {
2 years ago
$this->Logs_model->backup_summary($is_id, $info_detail->ic_summary);
}
$this->InfoStructures_model->Delete($Structure->is_id);
$this->InfoContents_model->Delete($Structure->is_ic_id);
//如果是已经发布的页面,删除静态文件
if ($info_detail->ic_status == 1) {
$this->update_cache($info_detail->ic_url, true);
}
//删除成功后返回一个上级链接给用户
$drumpurl = site_url('information/edit/' . $Structure->is_parent_id);
if ($Structure->is_parent_id == 0) {
$drumpurl = site_url('/');
}
$data[] = array('name' => 'ok', 'value' => $drumpurl);
echo json_encode($data);
return true;
}
}
public function edit($is_id)
{
set_time_limit(30);
//$this->output->enable_profiler(true);
//查询结构信息
$Structure = $this->InfoStructures_model->Detail($is_id);
if ($Structure == false) {
show_404();
}
//查询结构根节点
$rootStructure = $this->InfoStructures_model->GetParent($Structure->is_path, 1);
//没有根节点就从它本身开始查询
if ($rootStructure == false) {
$rootStructure_ID = $Structure->is_id;
} else {
$rootStructure_ID = $rootStructure->is_id;
}
2 years ago
//查询结构列表信息
$data['informationList'] = $this->Information_model->StructureList($rootStructure_ID);
//增加一项,属于这个区域,但是结构数据层次不准确的也要列出来
//信息内容
$data['information'] = $this->Information_model->Detail($is_id);
//检查该信息是否已收录
$data['embody'] = 1;
1 year ago
if (isset($data['information']->ic_id)) {
2 years ago
$embody = $this->InfoMetas_model->get($data['information']->ic_id, 'meta_embody');
if ($embody && $embody != '1') {
$data['embody'] = 0;
}
//设置该信息所有未读消息为已读
$this->InfoSMS_model->readed_for_info($data['information']->ic_id);
}
2 years ago
//主节点信息
$data['rootInformation'] = $this->Information_model->Detail($rootStructure_ID);
//获取未绑定的景点,只有城市有,无视其它区域类型
$data['unlink_landscape_list'] = array();
2 years ago
//可选的展示模板
if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
$this->config->set_item('templates', $this->config->item('templates_i'));
}
2 years ago
//可选的展示模板
1 year ago
if (in_array($this->config->item('site_code'), array('gh_vac', 'gh_vc', 'gh_jp', 'gh_ru', 'gh_it', 'gh_gm'))) {
2 years ago
$this->config->set_item('templates', $this->config->item('templates_gh'));
}
2 years ago
if (in_array($this->config->item('site_code'), array('ah'))) {
$this->config->set_item('templates', $this->config->item('templates_ah'));
}
if (in_array($this->config->item('site_code'), array('pgr'))) {
$this->config->set_item('templates', $this->config->item('templates_pgr'));
}
if (in_array($this->config->item('site_code'), array('ts'))) {
$this->config->set_item('templates', $this->config->item('templates_ts'));
}
if (in_array($this->config->item('site_code'), array('cht'))) {
$this->config->set_item('templates', $this->config->item('templates_cht'));
}
if (in_array($this->config->item('site_code'), array('gm'))) {
$this->config->set_item('templates', $this->config->item('templates_gm'));
}
2 years ago
if ($Structure->is_sitecode == 'ct') {
$data['infoTypeList'] = $this->config->item('InfoType_ct');
} elseif ($Structure->is_sitecode == 'ah') {
$data['infoTypeList'] = $this->config->item('InfoType_ah');
} else {
switch ($data['rootInformation']->ic_ht_area_type) {
case 'c': //城市
$data['infoTypeList'] = $this->config->item('InfoType_city');
$data['unlink_landscape_list'] = $this->Information_model->get_unlink_landscape_list($data['rootInformation']->ic_ht_area_id);
break;
case 'p': //省份
$data['infoTypeList'] = $this->config->item('InfoType_province');
break;
case 'n': //国家
$data['infoTypeList'] = $this->config->item('InfoType_country');
break;
case 't': //特殊区域
$data['infoTypeList'] = $this->config->item('InfoType_special');
break;
case 'e': //大洲
$data['infoTypeList'] = array();
break;
case 'z': //公民游
$data['infoTypeList'] = $this->config->item('InfoType_citizen');
break;
case 'v': //视频
$data['infoTypeList'] = $this->config->item('InfoType_video');
break;
case 'f': //节庆
$data['infoTypeList'] = $this->config->item('InfoType_festival');
break;
case 'pd': //产品管理
$data['infoTypeList'] = $this->config->item('InfoType_product');
//LMR 2016-7-14
if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
$this->config->set_item('templates', $this->config->item('templates_product_i'));
} else if ($this->config->item('site_code') === 'gm') {
$this->config->set_item('templates', $this->config->item('templates_product_gm'));
$data['infoTypeList'] = $this->config->item('InfoType_product_gm');
} else {
$this->config->set_item('templates', $this->config->item('templates_product'));
}
break;
default:
1 year ago
$data['infoTypeList'] = array('不设置' => 'none', '首页' => 'root', '线路' => 'pd_tour');
2 years ago
break;
}
}
2 years ago
$data['templateList'] = $this->config->item('templates');
//翰特产品类型
$data['productTypeList'] = $this->config->item('ProductType_HT');
//获取绑定的产品名称
switch ($data['information']->ic_ht_product_type) {
case 't':
$data['product_title'] = $this->Landscape_model->get_landscape_title($data['information']->ic_ht_product_id);
break;
default:
$data['product_title'] = '';
break;
}
//获取最后更新者信息
$data['last_edit_info'] = $this->Logs_model->get_last_edit($is_id);
//编辑列表
$sites = $this->config->item('site');
$data['editor_list'] = $this->Operator_model->get_site_user($this->config->item('site_code'));
//获取作者列表
$data['author_list'] = $this->Infoauthors_model->get_site_user($this->config->item('site_code'));
//获取备份信息记录
$data['content_backup_list'] = $this->Logs_model->get_backup_list($is_id);
//所属导航栏目
$data['setting_website_nav'] = $this->InfoMetas_model->get_list(0, 'setting_website_nav_' . strtolower($this->config->item('site_code')));
$data['my_tags'] = array();
$data['all_tags'] = array();
if (is_series_site()) {
//信息标签
//$this->InfoTags_model->ic_id = null;
//$data['all_tags'] = $this->InfoTags_model->list_tag();
//$this->InfoTags_model->ic_id = $data['information']->ic_id;
//$data['my_tags'] = $this->InfoTags_model->list_tag();
//差集
foreach ($data['all_tags'] as &$it) {
foreach ($data['my_tags'] as $it2) {
if ($it->it_id == $it2->icit_it_id) {
$it = null;
break;
}
}
}
$data['all_tags'] = array_filter($data['all_tags']);
}
2 years ago
//获取移动优先的模板,如果有的话
//增加判断站点,每个站点需要读取的模板不一样。 20210311 zp
//取消预览,严重影响速度 2023-08-15 ycc
/*
if (is_mobile_first()) {
$mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) {
$data['mobile_first_template'] = $this->load->view($mobile_first_template_path, '', true);
//主样式表,内联模式
$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']);
//查找是否有静态文件
if ($this->html_file_helper('find', $data['information']->ic_url)) {
$data['has_html_file'] = true;
}
2 years ago
} else {
$data['mobile_first_template'] = '没有找到移动模板';
}
2 years ago
}
*/
//判断是否生成静态文件
if (is_mobile_first()) {
//查找是否有静态文件
if ($this->html_file_helper('find', $data['information']->ic_url)) {
$data['has_html_file'] = true;
}
}
2 years ago
$this->load->view('bootstrap3/header', $data);
$this->load->view('bootstrap3/information_edit');
$this->load->view('bootstrap3/footer');
}
public function edit_save()
{
header('Cache-Control: no-cache');
$information = $this->Information_model->Detail($this->input->post('is_id'));
if ($information === false) {
$data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_notfound'));
echo json_encode($data);
return false;
}
2 years ago
$this->form_validation->set_rules('ic_url_title', 'lang:ic_url_title', 'required');
$this->form_validation->set_rules('ic_title', 'lang:ic_title', 'required');
$this->form_validation->set_rules('ic_author', 'lang:ic_author', 'required');
$this->form_validation->set_rules('ic_url', 'lang:ic_url', 'callback_ic_url_check');
//这里比较特别检测两次ic_urlci会冲掉第一个ic_url的规则所以需要在下面也加上callback_ic_url_check
$this->form_validation->set_rules('ic_url', 'lang:ic_url_format', 'callback_ic_url_check|callback_ic_url_format');
2 years ago
if ($this->input->post('ignore_seo_check') === false) {
$this->form_validation->set_rules('ic_seo_title', 'lang:ic_seo_title', 'required');
$this->form_validation->set_rules('ic_seo_description', 'lang:ic_seo_description', 'required|max_length[250]');
}
2 years ago
if ($this->form_validation->run() == false) {
$data = array();
foreach ($this->form_validation->_error_array as $key => $value) {
$data[] = array('name' => $key, 'value' => $value);
}
echo json_encode($data);
} else {
$ic_content = $this->input->post('ic_content');
if (strcasecmp($this->config->item('site_code'), "chinatravel") == 0) { //ct站替换中国大陆的英文
if (stripos($ic_content, 'mainland china') !== false) {
$ic_content = str_ireplace('mainland china', 'the mainland of china', $ic_content);
}
}
$this->InfoContents_model->Update($information->is_ic_id, $this->input->post('ic_url'), $this->input->post('ic_url_title'), $this->input->post('ic_type'), $this->input->post('ic_title'), $ic_content, $this->input->post('ic_summary'), $this->input->post('ic_seo_title'), $this->input->post('ic_seo_description'), $this->input->post('ic_seo_keywords'), $this->input->post('ic_show_bread_crumbs'), $this->input->post('ic_status'), $this->input->post('ic_template'), $this->input->post('ic_photo'), $this->input->post('ic_photo_width'), $this->input->post('ic_photo_height'), $this->input->post('ic_recommend_tours'), $this->input->post('ic_recommend_packages'), $this->input->post('ic_ht_area_id'), $this->input->post('ic_ht_area_type'), $this->input->post('ic_ht_product_id'), $this->input->post('ic_ht_product_type'), $this->input->post('ic_author'));
//AMP更新和生成 beign
$auto_update_amp = $this->input->get_post('auto_update_amp');
1 year ago
if (!empty($auto_update_amp) && $auto_update_amp == 'true' && $this->input->post('ic_status') == 1) {
2 years ago
$amp_result = $this->amplib->auto_create($information->ic_id);
1 year ago
if (!empty($amp_result)) {
2 years ago
$amp_result = json_decode($amp_result);
if ($amp_result->result == 'ok') {
$amp_save_result = $this->amplib->edit_save($information->ic_id, $amp_result->data->amp, '1');
1 year ago
if (!empty($amp_save_result)) {
2 years ago
$amp_save_result = json_decode($amp_save_result);
if ($amp_save_result->name == 'no') {
echo json_encode(array('name' => 'no', 'value' => 'AMP转换语法错误请重新进入AMP编辑器检查'));
return;
}
}
}
}
}
1 year ago
2 years ago
//如果URL有修改也删除静态文件
if ($this->input->post('ic_url') != $information->ic_url) {
$this->update_cache($information->ic_url, true);
}
//如果信息不发布则删除静态文件
if ($this->input->post('ic_status') == '0') {
$this->update_cache($this->input->post('ic_url'), true);
}
//德语站FAQ版块需要删除原来的文件才能更新静态
$site_code = $this->config->item('site_code');
$ic_url = $this->input->post('ic_url');
$auto_update_cache = $this->input->get_post('auto_update_cache_checkbox');
1 year ago
if (strcasecmp($site_code, "gm") == 0 && !empty($auto_update_cache)) {
2 years ago
$update_info_log = $this->update_cache($ic_url, true);
1 year ago
} else if (strcasecmp($site_code, "ch") == 0 && !empty($auto_update_cache)) {
2 years ago
//读取模板生成PC和移动优先文件
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
//$this->benchmark->mark('000');
$recommand_information = $this->recommand_information($information);
//$this->benchmark->mark('111');
$this->make_www_cache('mobile', $information_new, $recommand_information);
$this->make_www_cache('pc', $information_new, $recommand_information);
//echo ' |000~111: '.$this->benchmark->elapsed_time('000', '111');
1 year ago
} else if (strcasecmp($site_code, "ah") == 0 && !empty($auto_update_cache)) {
2 years ago
//读取模板生成PC和移动优先文件
$recommand_information = $this->recommand_information($information);
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_ah('mobile', $information_new, $recommand_information);
$this->make_www_cache_ah('pc', $information_new, $recommand_information);
1 year ago
} else if (strcasecmp($site_code, "gh") == 0 && !empty($auto_update_cache)) {
2 years ago
$recommand_information = $this->recommand_information($information);
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_gh('mobile', $information_new, $recommand_information);
$this->make_www_cache_gh('pc', $information_new, $recommand_information);
1 year ago
} else if (strcasecmp($site_code, "chinatravel") == 0 && !empty($auto_update_cache)) {
2 years ago
//chinatravel读取模板生成PC和移动优先文件
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_ct($information_new);
// $this->make_www_cache_ct('pc', $information_new);
1 year ago
} else if (strcasecmp($site_code, "shanghai") == 0 && !empty($auto_update_cache)) {
2 years ago
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_sh($information_new);
1 year ago
} else if (strcasecmp($site_code, "cht") == 0 && !empty($auto_update_cache)) {
2 years ago
$update_info_log = $this->update_cache($ic_url);
1 year ago
} else if (strcasecmp($site_code, "ah") == 0 && !empty($auto_update_cache)) {
2 years ago
//$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
$update_info_log = $this->update_cache($ic_url);
1 year ago
} else if (strcasecmp($site_code, "ct") == 0 && !empty($auto_update_cache)) {
2 years ago
$update_info_log = $this->update_cache($ic_url);
}
1 year ago
if (empty($update_info_log) || count($update_info_log) == 0 || !isset($update_info_log[0]['url'])) {
2 years ago
$update_info_log = 'not found update info log';
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('form_info_success'), 'update_info_log' => $update_info_log);
$this->Logs_model->backup($information->is_id, $ic_content);
$this->Logs_model->backup_summary($information->is_id, $this->input->post('ic_summary'));
//作者个人页面更新
if ($this->config->item('site_code') == 'cht') {
$author_pages = array(
'zzy' => 'http://www.chinahighlights.com/author/ruru-zhou/',
'Gavin' => 'http://www.chinahighlights.com/author/gavin-van-hinsbergh/',
'WBL' => 'http://www.chinahighlights.com/author/annie-wu/',
'PKL' => 'http://www.chinahighlights.com/author/kelly/',
'210000017' => 'http://www.chinahighlights.com/author/lynne-buddin/',
'202000027' => 'http://www.chinahighlights.com/author/margaux/',
'202000019' => 'http://www.chinahighlights.com/author/anusuya-mitra/',
'210000018' => 'http://www.chinahighlights.com/author/connie/',
'210000016' => 'http://www.chinahighlights.com/author/ben/',
'200000008' => 'http://www.chinahighlights.com/author/pete-marchetto/',
'210000019' => 'http://www.chinahighlights.com/author/oscar/',
'210000021' => 'http://www.chinahighlights.com/author/matthew/',
'200000013' => 'http://www.chinahighlights.com/author/kit-onslow-smith/',
'202000018' => 'http://www.chinahighlights.com/author/klaus-capra/',
'202000017' => 'http://www.chinahighlights.com/author/christy-campbell/',
);
$key = $this->input->post('ic_author');
1 year ago
if (isset($author_pages[$key])) {
2 years ago
$this->update_cache($author_pages[$key]);
}
2 years ago
}
2 years ago
echo json_encode($data);
}
2 years ago
}
2 years ago
//URL不重复检查
public function ic_url_check()
{
if ($this->input->post('ignore_url_check')) {
return true;
}
2 years ago
$url = $this->input->post('ic_url');
if ($url === '') {
return true;
}
$is_id = $this->input->post('is_id');
return $this->Information_model->URLcheck($is_id, $url);
}
//URL格式检查不能包含大小写、空格等特殊字符
public function ic_url_format($url)
{
if ($url != mb_strtolower($url) || strpos($url, ' ') !== false || strpos($url, '--') !== false || strpos($url, ')') !== false || strpos($url, '(') !== false || strpos($url, '//') !== false || strpos($url, '\\') !== false) {
return false;
}
return true;
}
public function update_www_cache($ic_id)
{
$information = $this->Information_model->detail_by_ic_id($ic_id);
1 year ago
if (empty($information)) {
2 years ago
echo json_encode(array('name' => 'no', 'data' => '找不到这个页面'));
return false;
}
if ($this->html_file_helper('find', $information->ic_url)) {
$recommand_information = $this->recommand_information($information);
//用于批量更新,CH和chinatravel分开 20210317 zp
if ($this->config->item('site_code') == 'ch') {
$this->make_www_cache('pc', $information, $recommand_information);
$this->make_www_cache('mobile', $information, $recommand_information);
} else if ($this->config->item('site_code') == 'ah') {
$this->make_www_cache_ah('pc', $information, $recommand_information);
$this->make_www_cache_ah('mobile', $information, $recommand_information);
} else if ($this->config->item('site_code') == 'chinatravel') {
$this->make_www_cache_ct($information);
// $this->make_www_cache_ct('mobile', $information);
} else if ($this->config->item('site_code') == 'shanghai') {
$this->make_www_cache_sh($information);
} else if ($this->config->item('site_code') == 'gh') {
$this->make_www_cache_gh('pc', $information, $recommand_information);
$this->make_www_cache_gh('mobile', $information, $recommand_information);
}
echo json_encode(array('name' => 'yes', 'data' => '更新成功!'));
return true;
} else {
echo json_encode(array('name' => 'no', 'data' => '没有发布静态页面: ' . $information->ic_url));
return false;
}
}
2 years ago
//静态文件操作
public function html_file_helper($active = 'find', $ic_url = false)
{
1 year ago
if (empty($ic_url)) {
2 years ago
$ic_url = $this->input->get_post('ic_url');
}
1 year ago
if (empty($ic_url)) {
2 years ago
return false;
}
$html_file = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $ic_url;
$html_file = str_replace("\\", "/", $html_file);
if (substr($html_file, -1, 1) == '/') {
$html_file = $html_file . 'index.htm';
}
$html_file_mobile = $html_file . '-mobile.htm';
$html_file_pc = $html_file . '-pc.htm';
2 years ago
switch ($active) {
case 'find': //寻找静态文件
if (is_file($html_file_mobile) || is_file($html_file_pc)) {
return true;
} else {
return false;
}
2 years ago
// break;
case 'delete':
if (is_file($html_file_mobile)) {
unlink($html_file_mobile);
}
2 years ago
if (is_file($html_file_pc)) {
unlink($html_file_pc);
}
2 years ago
echo '删除静态文件成功! ' . $ic_url;
break;
default:
return false;
}
2 years ago
return false;
}
//生成静态文件 $device='mobile' or 'pc'
public function make_www_cache($device, $information, $recommand_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;
}
2 years ago
break;
default:
}
$breadcrumb_data = $this->Information_model->get_path_exclude_self($information->is_id, $information->is_path);
$breadcrumb_structured_data_content = $this->load->view(
$template_path . '-structured-data-breadcrumb',
array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
true
);
$template = str_replace(
'<!--@STRUCTURED-DATA-BREADCRUMB-BLOCK@-->',
$breadcrumb_structured_data_content,
$template
);
//替换模板中的标签
$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);
// 动态加载反馈标签,第一个城市不足八条,使用第二城市数据。
// HTLM: <div><!--@FEEDBACK_Shanghai,Beijing@--></div>
// 解析结果:<!--@FEEDBACK_Shanghai,Beijing@-->; Shanghai,Beijing
$feedback_array = [];
preg_match_all('^<!--@FEEDBACK_(.*)@-->^', $information->ic_content, $feedback_array);
1 year ago
if (!empty($feedback_array)) {
2 years ago
foreach ($feedback_array[0] as $index => $tag_name) {
$city_name_string = $feedback_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_list = $this->Feedback_model->get_feedback_by_city_list($city_name_list);
// 防止触发 Google 网络垃圾政策只返回前三条
$top3_feedback_list = array_slice($feedback_list, 0, 3);
2 years ago
$feedback_content = $this->load->view(
'mobile_first/ch-feedback-list',
array('feedback_list' => $top3_feedback_list),
2 years ago
true
2 years ago
);
2 years ago
$information->ic_content = str_replace(
$tag_name,
$feedback_content,
$information->ic_content
2 years ago
);
2 years ago
}
}
2 years ago
// 动态加载反馈标签,每个城市三十条反馈。
// HTLM: <div><!--@FEEDBACK-30_Bangkok@--></div>
// 解析结果:<!--@FEEDBACK-30_Bangkok@-->; Bangkok
$feedback30_array = [];
preg_match_all('^<!--@FEEDBACK-30_(.*)@-->^', $information->ic_content, $feedback30_array);
1 year ago
if (!empty($feedback30_array)) {
2 years ago
foreach ($feedback30_array[0] as $index => $tag_name) {
$city_name = $feedback30_array[1][$index];
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
$feedback_30_content = $this->load->view(
'mobile_first/ch-feedback-30-list',
array('feedback_list' => $feedback_list),
true
);
$information->ic_content = str_replace(
2 years ago
$tag_name,
$feedback_30_content,
$information->ic_content
);
2 years ago
}
}
2 years ago
// 集合页面反馈标签
$feedback_city_array = [];
preg_match_all('^<!--@FEEDBACK-CITY-LIST_(.*)@-->^', $information->ic_content, $feedback_city_array);
1 year ago
if (!empty($feedback_city_array)) {
2 years ago
foreach ($feedback_city_array[0] as $index => $tag_name) {
$city_name_string = $feedback_city_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_city_list = [];
foreach ($city_name_list as $index => $city_name) {
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
$data_name = str_replace(" ", "_", $city_name);
$feedback_city_list[$data_name] = $feedback_list;
}
$feedback_city_content = $this->load->view(
'mobile_first/ch-feedback-city-list',
$feedback_city_list,
true
2 years ago
);
$information->ic_content = str_replace(
2 years ago
$tag_name,
$feedback_city_content,
$information->ic_content
2 years ago
);
2 years ago
}
}
2 years ago
// 天气预报模板
$weather_forecast_content = $this->load->view(
$template_path . '-weather-forecast',
array(),
true
);
$information->ic_content = str_replace(
'<!--@WEATHER-FORECAST-BLOCK@-->',
$weather_forecast_content,
$information->ic_content
);
// 火车票首页搜索框 --zp
$template_TrainSearch = "";
if ($information->ic_url == "/china-trains/hometest.htm" || $information->ic_url == "/china-trains/") {
$template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
$information->ic_content = str_replace(
'<!--@TRAIN-INDEX-SEARCHFORM@-->',
$template_TrainSearch,
$information->ic_content
);
}
2 years ago
//火车票搜索框添加 -- zp
if ($information->is_parent_id == "278008234" && $information->ic_url != "/china-trains/") { //20240403 字节
2 years ago
//本地测试的火车父类ID为278035939 。网前为278008234
$meta_train_city = get_meta($information->ic_id, 'meta_train_city'); //默认的出发及目的地城市 beijing|shanghai
$data_TrainCity = array();
$data_TrainCity["from"] = "";
$data_TrainCity["to"] = "";
1 year ago
if (!empty($meta_train_city)) {
2 years ago
if (strpos($meta_train_city, '|') !== false) {
$arrTrainCity = explode('|', $meta_train_city);
$data_TrainCity["from"] = $arrTrainCity[0];
$data_TrainCity["to"] = $arrTrainCity[1];
}
}
$template_TrainSearch = $this->load->view($template_path . '-train-detail', $data_TrainCity, true);
$template = str_replace('<!--@TRAIN-SEARCH@-->', $template_TrainSearch, $template);
}
2 years ago
$meta_product_code = get_meta($information->ic_id, 'meta_product_code');
$meta_google_ad_article = get_meta($information->ic_id, 'meta_google_ad_article');
$ads_by_google = !empty($meta_google_ad_article);
//H1模板替换
$data_H1 = array();
$data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
$data_H1['author'] = ''; //获取作者信息
$data_H1['meta_news_createdate'] = get_meta($information->ic_id, 'meta_news_createdate');
$author = $this->Operator_model->get_author_nikename($information->ic_author);
1 year ago
if (!empty($author)) {
$data_H1['author'] = $author->OPI_FirstName;
} else {
$author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
1 year ago
if (!empty($author_web)) {
$data_H1['author'] = $author_web->a_name;
}
}
// 检查图片地址格式
$parsed_photo = $information->ic_photo;
$parsed_photo_url = parse_url($information->ic_photo);
if (
1 year ago
(!isset($parsed_photo_url['host']) || !isset($parsed_photo_url['scheme'])) && isset($parsed_photo_url['path'])
) {
$parsed_photo = 'https://images.chinahighlights.com' . $parsed_photo_url['path'];
}
2 years ago
$data_H1['ic_title'] = $information->ic_title;
$data_H1['ic_photo'] = $parsed_photo;
$data_H1['breadcrumb_data'] = $breadcrumb_data;
$data_H1['ads_by_google'] = $ads_by_google;
$data_H1['ic_datetime'] = $information->ic_datetime;
$template_H1 = $this->load->view($template_path . '-h1', $data_H1, true);
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
1 year ago
//非产品页面
1 year ago
if (empty($meta_product_code)) {
2 years ago
$template = str_replace('?product_code=', '', $template);
$article_structured_data_content = $this->load->view(
$template_path . '-structured-data-article',
array('information' => $information, 'author' => $author),
true
);
$template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template);
$info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
$information->ic_content = str_replace('<!--@INFO-PAGE-FORM@-->', $info_page_form_content, $information->ic_content);
$visa_free_tester_content = $this->load->view($template_path . '-visa-free-tester', false, true);
$information->ic_content = str_replace('<!--@VISA-FREE-TESTER@-->', $visa_free_tester_content, $information->ic_content);
} else {
$inquiry_form_template = $this->load->view($template_path . '-inquiry-form', array('meta_product_code' => $meta_product_code), true);
$template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
$information->ic_content = str_replace('<!--@INQUIRY-FORM@-->', $inquiry_form_template, $information->ic_content);
}
// CH: 1; AH: 28; GH : 33
$price_tag_list = $this->parse_price_tag($information->ic_content, 1);
foreach ($price_tag_list as $price_tag) {
$information->ic_content = str_replace(
$price_tag['placeholder'],
$price_tag['price_number'],
$information->ic_content
);
}
2 years ago
//---day tours--- 20210922 zp
//本地 278035929
//网前 278008224
if ($information->is_parent_id == "278008224") {
$template = str_replace(
'<!--@CHINA-TRAINS-CSS@-->',
'<link href="https://proxy-data.chinahighlights.com/css/daytrip/tpbase.css" rel="stylesheet">',
$template
);
1 year ago
if (!empty($meta_product_code)) {
2 years ago
//准备需要的数据
$dataTrippest = [];
$dataTrippest["ic_title"] = $information->ic_title;
//附加选项
$t_Type = get_meta($information->ic_id, 'meta_trippest_type');
1 year ago
if (isset($t_Type)) {
2 years ago
$dataTrippest["t_Type"] = $t_Type;
} else {
2 years ago
$dataTrippest["t_Type"] = "general";
}
$t_package = get_meta($information->ic_id, 'meta_trippest_package');
$dataTrippest["t_package"] = explode("|", $t_package);
$t_excludedate = get_meta($information->ic_id, 'meta_trippest_excludedate');
$dataTrippest["t_excludedate"] = $t_excludedate;
$t_includedate = get_meta($information->ic_id, 'meta_trippest_includedate');
$dataTrippest["t_includedate"] = $t_includedate;
$t_excludemonth = get_meta($information->ic_id, 'meta_trippest_excludemonth');
$dataTrippest["t_excludemonth"] = $t_excludemonth;
$dataTrippest["t_limitperson"] = get_meta($information->ic_id, 'meta_trippest_limitperson');
//获取翰特对应信息
$dataTrippest['PagDetail'] = $this->trippest_model->get_pagdetail($meta_product_code);
//所属那个目的地 select SYC_SN,SYC2_CodeDiscribe from dbo.V_System_Code where SYC_Type=132 and LGC_LGC=2
// 132001 北京目的地
// 132002 上海目的地
// 132003 西安目的地
// 132004 桂林目的地
// 132005 成都目的地
1 year ago
if (isset($dataTrippest['PagDetail']) && $dataTrippest['PagDetail'] != null) {
$PAG_SourceType = $dataTrippest['PagDetail']->PAG_SourceType;
switch ($PAG_SourceType) {
case '132001':
$dataTrippest['PAG_SourceType'] = "beijing";
break;
case '132002':
$dataTrippest['PAG_SourceType'] = "shanghai";
break;
case '132003':
$dataTrippest['PAG_SourceType'] = "xian";
break;
case '132004':
$dataTrippest['PAG_SourceType'] = "guilin";
break;
case '132005':
$dataTrippest['PAG_SourceType'] = "chengdu";
break;
case '132006':
$dataTrippest['PAG_SourceType'] = "zhangjiajie";
break;
case '132007':
$dataTrippest['PAG_SourceType'] = "huangshan";
break;
default:
$dataTrippest['PAG_SourceType'] = "";
break;
}
1 year ago
//每周发团
$PAG_Scheme = $dataTrippest['PagDetail']->PAG_Scheme;
$dataTrippest['PAG_Scheme'] = $PAG_Scheme;
//接送
if ($dataTrippest["t_Type"] == "transfer" || 1 == 1) {
$PagList = $this->trippest_model->GetTransfer($dataTrippest['PagDetail']->PAG_SN);
$dataTrippest["PagList"] = $PagList;
}
2 years ago
//价格
// $price = $this->trippest_model->get_price("BJALC-1",2);
$price = $this->trippest_model->get_price($dataTrippest['PagDetail']->PAG_Code, 2);
$showPrice = "";
1 year ago
if (!empty($price)) {
$PKP_AdultNetPrice = $price->PKP_AdultNetPrice;
$PKP_AdultSpecialPrice = $price->PKP_AdultSpecialPrice;
if ($PKP_AdultSpecialPrice > 0) {
$showPrice = $PKP_AdultSpecialPrice;
} else {
$showPrice = $PKP_AdultNetPrice;
}
2 years ago
}
$dataTrippest["showPrice"] = $showPrice;
2 years ago
//替换内容
$trippest_detail_template = $this->load->view($template_path . '-daytours-detail', $dataTrippest, true);
2 years ago
// print_r($trippest_detail_template);
// die();
$information->ic_content = str_replace('<!--@TRIPPEST-FORM@-->', $trippest_detail_template, $information->ic_content);
}
2 years ago
}
}
2 years ago
//---day tours end ----
2 years ago
//信息推荐
$template_recommand = $recommand_information; //$this->recommand_information($information); 从外面传进来pc和移动只需要查一次减少数据库负担
$template = str_replace('<!--@ARTICLENEXT@-->', $this->load->view($template_path . '-next', array('recommands' => $template_recommand), true), $template);
$meta_show_advertise = get_meta($information->ic_id, 'meta_show_advertise');
2 years ago
// //广告改叫tips防止被插件屏蔽
1 year ago
if (!empty($template_recommand['Tips Right TOP']) && ($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
$template = str_replace('<!--@TIPS-RIGHT-TOP@-->', "<div class='right_brand_info'>" . $template_recommand['Tips Right TOP']->it_content . "</div>", $template);
2 years ago
}
1 year ago
if (!empty($template_recommand['Tips Right']) && ($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
2 years ago
$template = str_replace('<!--@TIPS-RIGHT@-->', "<div class='right_tour'>" . $template_recommand['Tips Right']->it_content . "</div>", $template);
}
2 years ago
// /day-tours/(278008224) 节点不使用推荐信息
if ($information->is_parent_id == '278008224') {
} else {
// 右侧列表广告
$tips_right_a = [];
$tips_right_b = [];
$tips_right_c = [];
1 year ago
2 years ago
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right A_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_a[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right B_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_b[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right C_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_c[] = $recommand_information[$key];
}
}
$tips_right_list_content = $this->load->view(
'mobile_first/ch-tips-right-list',
array(
'tips_right_a' => $tips_right_a,
'tips_right_b' => $tips_right_b,
'tips_right_c' => $tips_right_c
),
true
);
1 year ago
if (($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
$template = str_replace('<!--@TIPS-RIGHT-LIST@-->', $tips_right_list_content, $template);
}
2 years ago
}
2 years ago
//文中的信息推荐
if (strpos($information->ic_content, '<!--@Content-Recommends-Article@-->') !== false) {
$information->ic_content = str_replace('<!--@Content-Recommends-Article@-->', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), true), $information->ic_content);
}
//文中的线路推荐
if (strpos($information->ic_content, '<!--@Content-Recommends-Tour@-->') !== false) {
$information->ic_content = str_replace('<!--@Content-Recommends-Tour@-->', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), true), $information->ic_content);
}
4 years ago
2 years ago
// 未勾选In Article 广告时,加入标签 <meta name="ezoic" content="noads"/>,让 ezoic 识别出该页面不展示广告。
1 year ago
if (empty($meta_google_ad_article) || !$meta_google_ad_article) {
2 years ago
$template = str_replace(
'<!--@Meta-Ezoic-NoAds@-->',
'<meta name="ezoic" content="noads"/>',
$template
);
} else {
$template = str_replace(
'<!--@Meta-Ezoic-NoAds@-->',
'',
$template
);
}
2 years ago
//替换内容中广告
$temp_array = array();
preg_match_all('^<!--@TIPS-[A-Z]+-([0-9]+)@-->^', $information->ic_content, $temp_array);
1 year ago
if (!empty($temp_array[1])) {
2 years ago
foreach ($temp_array[1] as $key => $item) {
$tips_detail = $this->recommends_and_tips_model->tips_detail($item);
if ($tips_detail) {
$information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
}
2 years ago
}
}
2 years ago
//顶部全屏大图
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');
}
2 years ago
//顶部视频
$meta_news_video = get_meta($information->ic_id, 'meta_news_video');
$meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
1 year ago
if (!empty($meta_news_video) && !empty($meta_video_picture)) {
2 years ago
$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);
1 year ago
}
2 years ago
if (is_file('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
$main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css'));
} else {
$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);
// /china-trains/ 节点
if ($information->is_parent_id == "278008234") {
$template = str_replace(
'<!--@CHINA-TRAINS-CSS@-->',
'<link href="https://proxy-data.chinahighlights.com/css/china-trains.css" rel="stylesheet">',
$template
);
}
//额外样式
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
1 year ago
if (!empty($meta_addon_css)) {
2 years ago
if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) {
$meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css'));
} else {
$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');
1 year ago
if (!empty($meta_addon_js)) {
2 years ago
$template = str_replace('<!--@ADDON-JS@-->', '<script src="' . $meta_addon_js . '"></script>', $template);
}
1 year ago
$meta_index_set = get_meta($information->ic_id, 'meta_index_set');
1 year ago
if (!empty($meta_index_set)) {
$template = str_replace('<!--@Meta_Robots@-->', '<meta name="robots" content="' . $meta_index_set . '" />', $template);
}
2 years ago
//设置内容图片缓加载
$lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.chinahighlights.com/grey.gif');
$template = str_replace('<!--@CUSTOM-CONENT@-->', $lazy_content, $template);
//替换内容中各种标签
$tag_why_us = $this->load->view($template_path . '-why-us', false, true);
$template = str_replace('<!--@TAG-WHY-US@-->', $tag_why_us, $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" data-matched-content-rows-num="2,2" data-matched-content-columns-num="1,3" data-matched-content-ui-type="image_stacked,image_stacked"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
//}
//社媒分享图片
$full_ic_photo = '';
1 year ago
if (!empty($information->ic_photo)) {
2 years ago
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
} else {
$full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
}
1 year ago
if (!empty($full_ic_photo)) {
2 years ago
$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);
}
//设置图片尺寸
// 优化过图片目录D:\wwwroot\origin-images.chinahighlights.com\optimize\
$www_local_path = 'D:/wwwroot/origin-www.chinahighlights.com';
$image_local_path = 'D:/wwwroot/origin-images.chinahighlights.com/optimize';
if (is_dir($www_local_path) && is_dir($image_local_path)) {
$template = $this->html_optimize_lib->set_image_size_local($template, $www_local_path, $image_local_path);
2 years ago
} else {
$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);
}
public function test_recommand()
{
$information = $this->Information_model->Detail($this->input->get('is_id'));
$recommand_information = $this->recommand_information($information);
// var_dump($recommand_information);
$tips_right_a = [];
$tips_right_b = [];
$tips_right_c = [];
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right A_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_a[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right B_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_b[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right C_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_c[] = $recommand_information[$key];
}
}
2 years ago
2 years ago
echo 'List Tips Right A: ' . COUNT($tips_right_a);
echo '; List Tips Right B: ' . COUNT($tips_right_b);
echo '; List Tips Right C: ' . COUNT($tips_right_c);
$tips_right_list_content = $this->load->view(
'mobile_first/ah-tips-right-list',
array(
'tips_right_a' => $tips_right_a,
'tips_right_b' => $tips_right_b,
'tips_right_c' => $tips_right_c
),
true
);
echo $tips_right_list_content;
}
public function test_feedback()
{
$feedback_newest = $this->Feedback_model->get_feedback_newest();
2 years ago
var_dump($feedback_newest);
echo '------------------------------------------------------';
$feedback_newest = $this->Feedback_model->get_feedback_newest(10);
var_dump($feedback_newest);
2 years ago
}
public function test_ch_feedback30()
2 years ago
{
$feedback30_array = [];
preg_match_all('^<!--@FEEDBACK-30_(.*)@-->^', '<div><!--@FEEDBACK-30_Bangkok@--></div>', $feedback30_array);
1 year ago
if (!empty($feedback30_array)) {
2 years ago
foreach ($feedback30_array[0] as $index => $tag_name) {
$city_name = $feedback30_array[1][$index];
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 2);
$feedback_content = $this->load->view(
'mobile_first/ch-feedback-30-list',
2 years ago
array('feedback_list' => $feedback_list),
true
2 years ago
);
2 years ago
echo $feedback_content;
}
}
2 years ago
}
2 years ago
public function test_get_feedback_by_city_name()
{
$feedback_list = $this->Feedback_model->get_feedback_by_city_name('Bangkok', 5);
var_dump($feedback_list);
}
2 years ago
public function test_feedback_city_list()
{
$feedback_city_array = [];
preg_match_all('^<!--@FEEDBACK-CITY-LIST_(.*)@-->^', '<div><!--@FEEDBACK-CITY-LIST_Bangkok@--></div>', $feedback_city_array);
1 year ago
if (!empty($feedback_city_array)) {
2 years ago
foreach ($feedback_city_array[0] as $index => $tag_name) {
$city_name_string = $feedback_city_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_city_list = [];
foreach ($city_name_list as $index => $city_name) {
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
$data_name = str_replace(" ", "_", $city_name);
$feedback_city_list[$data_name] = $feedback_list;
}
// header('Content-Type: application/json');
// echo json_encode($feedback_city_list);
$feedback_content = $this->load->view(
'mobile_first/ah-feedback-city-list',
$feedback_city_list,
true
);
echo $feedback_content;
}
}
2 years ago
}
// <div>#ah-mtc-3,st,2#</div>
// CH: 1; AH: 28; GH : 33
2 years ago
public function test_price()
{
$price_rule = base64_decode($this->input->get('price_rule'));
$dept_sn = $this->input->get('dept_sn');
2 years ago
$price_item_array = $this->price_pregmatch($price_rule);
echo 'price_item_array: ';
2 years ago
var_dump($price_item_array);
$price_tag_list = $this->parse_price_tag($price_rule, $dept_sn);
echo '<br/>price_tag_list: ';
var_dump($price_tag_list);
2 years ago
}
/*!
* 页面中有价格标签,查出价格并替换内容
* @author LiaoYijun
* @date 2023-05-12
* @param string $price_content 包含价格标签的内容
* @return array 包含价格与占位符的数组
*/
public function parse_price_tag($price_content, $dept_sn = 28)
2 years ago
{
$price_item_array = $this->price_pregmatch($price_content);
$price_tag_list = [];
1 year ago
if (!empty($price_item_array)) {
2 years ago
foreach ($price_item_array as $price_item) {
1 year ago
$price_date = !empty($price_item->price_date) ? $price_item->price_date : date('Y-m-d', time() + 86400 * 7); //当前时间7天后的价格
2 years ago
$price_number = '';
//优先读取新的价格体系
$price = $this->PrimeLinePrice_model->search($price_item->cli_no, 1, $price_item->cli_grade, $price_item->person_size, $price_date, $dept_sn);
1 year ago
if (!empty($price)) {
2 years ago
switch (strtoupper($price_item->price_people)) {
case 'A':
$price_number = $price->PLP_AdultUnitPrice;
break;
case 'C':
$price_number = $price->PLP_ChildUnitPrice;
break;
case 'B':
$price_number = $price->PLP_BabyUnitPrice;
break;
case 'R':
$price_number = $price->PLP_RoomDiffPrice;
break;
case 'AR':
$price_number = $price->PLP_AdultUnitPrice + $price->PLP_RoomDiffPrice; //成人加单间房差
break;
default:
$price_number = $price->PLP_AdultUnitPrice;
}
} else {
$price = $this->Price_model->search($price_item->cli_no, 1, $price_item->cli_grade, false, $price_date);
1 year ago
if (!empty($price)) {
2 years ago
switch (strtoupper($price_item->price_people)) {
case 'A':
switch ($price_item->person_size) {
case '1':
$price_number = $price->CLP_OneAdultPriceRMB;
2 years ago
break;
2 years ago
case '2': //25
$price_number = $price->CLP_TwoToFiveAdultPriceRMB;
2 years ago
break;
2 years ago
case '6': //69
$price_number = $price->CLP_SixToNineAdultPriceRMB;
2 years ago
break;
2 years ago
case '10':
$price_number = $price->CLP_OverTenAdultPriceRMB;
2 years ago
break;
2 years ago
default:
$price_number = $price->CLP_TwoToFiveAdultPriceRMB;
}
break;
2 years ago
case 'C':
$price_number = 0;
break;
2 years ago
case 'B':
$price_number = 0;
break;
2 years ago
case 'R':
switch ($price_item->person_size) {
case '1':
$price_number = $price->CLP_OneRoomDiffPriceRMB;
break;
case '2': //25
$price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB;
break;
case '6': //69
$price_number = $price->CLP_SixToNineRoomDiffPriceRMB;
break;
case '10':
$price_number = $price->CLP_OverTenRoomDiffPriceRMB;
break;
default:
$price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB;
}
break;
2 years ago
case 'AR': //成人加单间房差
$price_number = 0;
break;
default:
$price_number = 0;
}
}
}
if($dept_sn == 1){
$price_number = $this->currency->convert_moneny_by_char($price_number,"USD");
2 years ago
}
$site_money = $this->currency->calc_show_price($price_number);
//把金额格式化为带有逗号(,)方便阅读,如 12,345
$price_number = is_numeric($price_number) ? number_format($site_money) : $price_number;
1 year ago
if (!empty($price_number)) {
2 years ago
$price_tag = [
'placeholder' => $price_item->placeholder,
'price_number' => $price_number,
];
$price_tag_list[] = $price_tag;
}
}
}
return $price_tag_list;
}
//使用正则匹配出价格标签,返回一个价格数组
private function price_pregmatch($content)
{
$price_array = array();
$temp_array = array();
$result = false;
//#ah-1,lx,2,2016-01-23,A#
//线路代号,等级(st标准、lx豪华、ec经济),人等,时间,人型(A成人、C小孩、B婴儿、R单间房差、AR成人+房差)
preg_match_all('^#[a-zA-Z0-9,-]+#^', $content, $temp_array);
foreach ($temp_array[0] as $item) {
$placeholder = $item;
$item = str_replace('#', '', $item);
$price_array = explode(',', $item);
1 year ago
$cli_no = !empty($price_array[0]) ? $price_array[0] : false; //线路代号
if (empty($cli_no)) {
2 years ago
continue; //没有设置线路代号则进入下一条
}
1 year ago
$cli_grade = !empty($price_array[1]) ? $price_array[1] : false; //标准7001、豪华7002、经济7003
2 years ago
switch (strtoupper($cli_grade)) {
case 'ST':
$cli_grade = '7001';
break;
case 'LX':
$cli_grade = '7002';
break;
case 'EC':
$cli_grade = '7003';
break;
default:
$cli_grade = '7001';
}
1 year ago
$person_size = (!empty($price_array[2]) && is_numeric($price_array[2])) ? $price_array[2] : 2; //人等1,2-5,6-9,10默认2人等
2 years ago
//为了兼容以前的人等方式,把算数人等转换为单数 25=>2
switch ($person_size) {
case '25':
$person_size = '2';
break;
case '69':
$person_size = '6';
break;
}
1 year ago
$price_date = !empty($price_array[3]) ? $price_array[3] : false; //价格时间
$price_people = !empty($price_array[4]) ? $price_array[4] : 'A'; //A成人、C小孩、B婴儿、R单间房差
2 years ago
$result[] = (object) array('placeholder' => $placeholder, 'cli_no' => $cli_no, 'cli_grade' => $cli_grade, 'person_size' => $person_size, 'price_date' => $price_date, 'price_people' => $price_people);
}
return $result;
}
public function make_www_cache_gh($device, $information, $recommand_information)
{
$data = array();
$meta_show_advertise = get_meta($information->ic_id, 'meta_show_advertise');
$data['meta_show_advertise'] = $meta_show_advertise;
2 years ago
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';
2 years ago
} else {
2 years ago
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);
2 years ago
$html_path_ext = '-pc.htm';
} else {
return false;
}
2 years ago
break;
default:
}
2 years ago
// GH Home 下层节点名称和链接映射
$group_map = [
278009289 => [
'ic_url' => '/destinations',
'ic_url_title' => 'Destinations',
],
278009290 => [
'ic_url' => '/about',
'ic_url_title' => 'About Us',
],
];
$breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map);
$breadcrumb_structured_data_content = $this->load->view(
$template_path . '-structured-data-breadcrumb',
array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
true
);
$template = str_replace(
'<!--@STRUCTURED-DATA-BREADCRUMB-BLOCK@-->',
$breadcrumb_structured_data_content,
$template
);
//替换模板中的标签
$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 ($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');
}
2 years ago
2 years ago
$meta_product_code = get_meta($information->ic_id, 'meta_product_code');
1 year ago
$ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
2 years ago
//H1模板替换
$data_H1 = array();
$data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
$data_H1['author'] = ''; //获取作者信息
$data_H1['meta_news_createdate'] = get_meta($information->ic_id, 'meta_news_createdate');
2 years ago
$author = $this->Operator_model->get_author_nikename($information->ic_author);
1 year ago
if (!empty($author)) {
2 years ago
$data_H1['author'] = $author->OPI_FirstName;
} else {
$author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
1 year ago
if (!empty($author_web)) {
2 years ago
$data_H1['author'] = $author_web->a_name;
}
}
$data_H1['ic_title'] = $information->ic_title;
$data_H1['ic_photo'] = $meta_addon_picture; //$information->ic_photo; 用额外设置的图片替代
$data_H1['breadcrumb_data'] = $breadcrumb_data;
$data_H1['ads_by_google'] = $ads_by_google;
$template_H1 = $this->load->view($template_path . '-h1', $data_H1, true);
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
1 year ago
if (empty($meta_product_code)) {
2 years ago
$addthis_widget = $this->load->view($template_path . '-add-this', false, true);
$template = str_replace('<!--@ADDTHIS-WIDGET@-->', $addthis_widget, $template);
}
2 years ago
$article_structured_data_content = $this->load->view(
$template_path . '-structured-data-article',
array('information' => $information, 'author_name' => $data_H1['author']),
true
);
$template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template);
1 year ago
if (!empty($meta_product_code)) {
2 years ago
// <input name="product_code" type="hidden" value="cht-63">
$product_code_input = "<input name='product_code' type='hidden' value='$meta_product_code'>";
$template = str_replace('<!--@INPUT_PRODUCT_CODE@-->', $product_code_input, $template);
}
1 year ago
if (empty($meta_product_code)) {
2 years ago
$template = str_replace('?product_code=', '', $template);
} else {
$template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
}
2 years ago
//信息推荐
$template_recommand = $recommand_information; //$this->recommand_information($information); 从外面传进来pc和移动只需要查一次减少数据库负担
$template = str_replace('<!--@ARTICLENEXT@-->', $this->load->view($template_path . '-next', array('recommands' => $template_recommand), true), $template);
// //广告改叫tips防止被插件屏蔽
1 year ago
if (!empty($template_recommand['Tips Right TOP'])) {
2 years ago
// $template = str_replace('<!--@TIPS-RIGHT-TOP@-->', "<div class='right_brand_info'><aside>" . $template_recommand['Tips Right TOP']->it_content . "</aside></div>", $template);
}
1 year ago
if (!empty($template_recommand['Tips Right']) && ($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
2 years ago
$template = str_replace('<!--@TIPS-RIGHT@-->', "<div class='right_tour'><div class='ah_inforight'>" . $template_recommand['Tips Right']->it_content . "</div></div>", $template);
}
// 右侧列表广告
$tips_right_a = [];
$tips_right_b = [];
$tips_right_c = [];
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right A_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_a[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right B_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_b[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right C_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_c[] = $recommand_information[$key];
}
}
2 years ago
$tips_right_list_content = $this->load->view(
'mobile_first/gh-tips-right-list',
array(
'tips_right_a' => $tips_right_a,
'tips_right_b' => $tips_right_b,
'tips_right_c' => $tips_right_c
),
true
);
1 year ago
if (($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
$template = str_replace('<!--@TIPS-RIGHT-LIST@-->', $tips_right_list_content, $template);
}
2 years ago
//文中的信息推荐
if (strpos($information->ic_content, '<!--@Content-Recommends-Article@-->') !== false) {
// $information->ic_content = str_replace('<!--@Content-Recommends-Article@-->', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), TRUE), $information->ic_content);
}
//文中的线路推荐
if (strpos($information->ic_content, '<!--@Content-Recommends-Tour@-->') !== false) {
// $information->ic_content = str_replace('<!--@Content-Recommends-Tour@-->', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), TRUE), $information->ic_content);
}
2 years ago
//替换内容中广告
$temp_array = array();
preg_match_all('^<!--@TIPS-[A-Z]+-([0-9]+)@-->^', $information->ic_content, $temp_array);
1 year ago
if (!empty($temp_array[1])) {
2 years ago
foreach ($temp_array[1] as $key => $item) {
$tips_detail = $this->recommends_and_tips_model->tips_detail($item);
if ($tips_detail) {
$information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
}
2 years ago
}
}
// 未勾选In Article 广告时,加入标签 <meta name="ezoic" content="noads"/>,让 ezoic 识别出该页面不展示广告。
$meta_google_ad_article = get_meta($information->ic_id, 'meta_google_ad_article');
1 year ago
if (empty($meta_google_ad_article) || !$meta_google_ad_article) {
$template = str_replace(
'<!--@Meta-Ezoic-NoAds@-->',
'<meta name="ezoic" content="noads"/>',
$template
);
} else {
$template = str_replace(
'<!--@Meta-Ezoic-NoAds@-->',
'',
$template
);
}
2 years ago
$why_us_covid_list_pc = $this->load->view(
$template_path . '-why-us-covid-list-pc',
array(),
true
);
$information->ic_content = str_replace('<!--@WHY-US-COVID-LIST-PC@-->', $why_us_covid_list_pc, $information->ic_content);
$why_us_covid_list_mobile = $this->load->view(
$template_path . '-why-us-covid-mobile',
array(),
true
);
$information->ic_content = str_replace('<!--@WHY-US-COVID-MOBILE@-->', $why_us_covid_list_mobile, $information->ic_content);
1 year ago
if (empty($meta_product_code)) {
2 years ago
$info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
$information->ic_content = str_replace('<!--@INFO-PAGE-FORM@-->', $info_page_form_content, $information->ic_content);
} else {
$tour_form_content = $this->load->view(
'mobile_first/gh-tour-form',
array('information' => $information, 'meta_product_code' => $meta_product_code),
true
);
$information->ic_content = str_replace('<!--@TOUR-FORM-TAG@-->', $tour_form_content, $information->ic_content);
}
// CH: 1; AH: 28; GH : 33
$price_tag_list = $this->parse_price_tag($information->ic_content, 33);
foreach ($price_tag_list as $price_tag) {
$information->ic_content = str_replace(
$price_tag['placeholder'],
$price_tag['price_number'],
$information->ic_content
);
}
2 years ago
// 动态加载反馈标签,每个城市三十条反馈。
// HTLM: <div><!--@FEEDBACK-30_Bangkok@--></div>
// 解析结果:<!--@FEEDBACK-30_Bangkok@-->; Bangkok
$feedback30_array = [];
preg_match_all('^<!--@FEEDBACK-30_(.*)@-->^', $information->ic_content, $feedback30_array);
1 year ago
if (!empty($feedback30_array)) {
2 years ago
foreach ($feedback30_array[0] as $index => $tag_name) {
$city_name = $feedback30_array[1][$index];
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
$feedback_30_content = $this->load->view(
'mobile_first/gh-feedback-30-list',
array('feedback_list' => $feedback_list),
true
2 years ago
);
2 years ago
$information->ic_content = str_replace(
$tag_name,
$feedback_30_content,
$information->ic_content
2 years ago
);
2 years ago
}
}
2 years ago
// 集合页面反馈标签
$feedback_city_array = [];
preg_match_all('^<!--@FEEDBACK-CITY-LIST_(.*)@-->^', $information->ic_content, $feedback_city_array);
1 year ago
if (!empty($feedback_city_array)) {
2 years ago
foreach ($feedback_city_array[0] as $index => $tag_name) {
$city_name_string = $feedback_city_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_city_list = [];
foreach ($city_name_list as $index => $city_name) {
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
$data_name = str_replace(" ", "_", $city_name);
$feedback_city_list[$data_name] = $feedback_list;
}
$feedback_city_content = $this->load->view(
'mobile_first/gh-feedback-city-list',
$feedback_city_list,
true
);
$information->ic_content = str_replace(
2 years ago
$tag_name,
$feedback_city_content,
$information->ic_content
);
2 years ago
}
}
// 动态加载反馈标签,第一个城市不足八条,使用第二城市数据。
// HTLM: <div><!--@FEEDBACK_Siem Reap,Bangkok@--></div>
// 解析结果:<!--@FEEDBACK_Siem Reap,Bangkok@-->; Siem Reap,Bangkok
$feedback_array = [];
preg_match_all('^<!--@FEEDBACK_(.*)@-->^', $information->ic_content, $feedback_array);
1 year ago
if (!empty($feedback_array)) {
foreach ($feedback_array[0] as $index => $tag_name) {
$city_name_string = $feedback_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_list = $this->Feedback_model->get_feedback_by_city_list($city_name_list);
// 防止触发 Google 网络垃圾政策只返回前三条
$top3_feedback_list = array_slice($feedback_list, 0, 3);
$feedback_content = $this->load->view(
'mobile_first/gh-feedback-list',
array('feedback_list' => $top3_feedback_list),
true
);
$information->ic_content = str_replace(
$tag_name,
$feedback_content,
$information->ic_content
);
}
}
2 years ago
if (is_file('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
$main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css'));
} else {
$main_css_string = compress_css(GET_HTTP('https://www.globalhighlights.com/css/gh-global.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');
1 year ago
if (!empty($meta_addon_css)) {
2 years ago
// if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) {
//$meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css'));
// } else {
$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');
1 year ago
if (!empty($meta_addon_js)) {
2 years ago
$template = str_replace('<!--@ADDON-JS@-->', '<script src="' . $meta_addon_js . '"></script>', $template);
}
1 year ago
$meta_index_set = get_meta($information->ic_id, 'meta_index_set');
1 year ago
if (!empty($meta_index_set)) {
$template = str_replace('<!--@Meta_Robots@-->', '<meta name="robots" content="' . $meta_index_set . '" />', $template);
}
2 years ago
//设置内容图片缓加载
$lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.chinahighlights.com/grey.gif');
$template = str_replace('<!--@CUSTOM-CONENT@-->', $lazy_content, $template);
//社媒分享图片
$full_ic_photo = '';
1 year ago
if (!empty($information->ic_photo)) {
2 years ago
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
} else {
$full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
}
1 year ago
if (!empty($full_ic_photo)) {
2 years ago
$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);
}
//设置图片尺寸
// 优化过图片目录D:\wwwroot\origin-images.chinahighlights.com\optimize\
$www_local_path = 'D:/wwwroot/origin-www.globalhighlights.com';
$image_local_path = 'D:/wwwroot/origin-images.chinahighlights.com/optimize';
if (is_dir($www_local_path) && is_dir('D:/wwwroot/origin-www.globalhighlights.com')) {
$template = $this->html_optimize_lib->set_image_size_local($template, $www_local_path, $image_local_path);
2 years ago
} else {
$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);
}
public function make_www_cache_ah($device, $information, $recommand_information)
{
$data = array();
$data['information'] = $information;
$recommand_template = '';
$meta_show_advertise = get_meta($information->ic_id, 'meta_show_advertise');
$data['meta_show_advertise'] = $meta_show_advertise;
2 years ago
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);
2 years ago
$html_path_ext = '-mobile.htm';
} else {
2 years ago
return false;
}
$recommand_template = 'mobile_first/ah-next-mobile';
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);
2 years ago
$html_path_ext = '-pc.htm';
} else {
return false;
4 years ago
}
2 years ago
$recommand_template = 'mobile_first/ah-next';
break;
default:
}
4 years ago
2 years ago
//替换模板中的标签
$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);
//顶部视频
$data['meta_news_video'] = get_meta($information->ic_id, 'meta_news_video');
$data['meta_video_picture'] = get_meta($information->ic_id, 'meta_video_picture');
1 year ago
if (empty($data['meta_news_video']) && empty($data['meta_video_picture'])) {
2 years ago
//没有顶部视频时候才读取全屏大图
//顶部全屏大图
if ($device == 'mobile') { //移动端读取移动大图
$data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture_mobile');
} else {
$data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture');
}
$data['meta_addon_picture_url'] = get_meta($information->ic_id, 'meta_addon_picture_url');
}
4 years ago
2 years ago
// AH Home 下层节点名称和链接映射
$group_map = [
278002667 => [
'ic_url' => '/destinations',
'ic_url_title' => 'Destinations',
],
278008885 => [
'ic_url' => '/about-us',
'ic_url_title' => 'About Us',
],
];
$breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map);
1 year ago
$ads_by_google = !empty(get_meta($information->ic_id, 'meta_google_ad_article'));
$data['meta_news_createdate'] = get_meta($information->ic_id, 'meta_news_createdate');
2 years ago
$data['ads_by_google'] = $ads_by_google;
$data['author'] = ''; //获取作者信息
$author = $this->Operator_model->get_author_nikename($information->ic_author);
1 year ago
if (!empty($author)) {
2 years ago
$data['author'] = $author->OPI_FirstName;
} else {
$author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等
1 year ago
if (!empty($author_web)) {
2 years ago
$data['author'] = $author_web->a_name;
}
}
$data['breadcrumb_data'] = $breadcrumb_data;
$template_H1 = $this->load->view($template_path . '-h1', $data, true);
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
// 结构化标签Article
$article_structured_data_content = $this->load->view(
$template_path . '-structured-data-article',
array('information' => $information, 'author' => $data['author']),
2 years ago
true
);
$template = str_replace('<!--@STRUCTURED-DATA-ARTICLE-BLOCK@-->', $article_structured_data_content, $template);
// 结构化标签BreadcrumbList
$breadcrumb_structured_data_content = $this->load->view(
$template_path . '-structured-data-breadcrumb',
array('breadcrumb_data' => $breadcrumb_data, 'information' => $information),
true
);
$template = str_replace(
'<!--@STRUCTURED-DATA-BREADCRUMB-BLOCK@-->',
$breadcrumb_structured_data_content,
$template
);
//推荐信息或者产品
$template_recommand = $recommand_information;
$template = str_replace('<!--@ARTICLENEXT@-->', $this->load->view($recommand_template, array('recommands' => $template_recommand), true), $template);
//广告改叫tips防止被插件屏蔽
1 year ago
if (!empty($template_recommand['Tips Right']) && ($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
2 years ago
$template = str_replace('<!--@TIPS-RIGHT@-->', "<div class='right_tour'><div class='ah_inforight'>" . $template_recommand['Tips Right']->it_content . "</div></div>", $template);
}
// 右侧列表广告
$tips_right_a = [];
$tips_right_b = [];
$tips_right_c = [];
1 year ago
2 years ago
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right A_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_a[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right B_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_b[] = $recommand_information[$key];
}
}
for ($i = 1; $i <= 12; $i++) {
$key = 'List Tips Right C_' . $i;
if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) {
$tips_right_c[] = $recommand_information[$key];
}
}
2 years ago
$tips_right_list_content = $this->load->view(
'mobile_first/ah-tips-right-list',
array(
'tips_right_a' => $tips_right_a,
'tips_right_b' => $tips_right_b,
'tips_right_c' => $tips_right_c,
2 years ago
),
true
);
1 year ago
if (($meta_show_advertise == 'yes' || empty($meta_show_advertise))) {
$template = str_replace('<!--@TIPS-RIGHT-LIST@-->', $tips_right_list_content, $template);
}
1 year ago
2 years ago
//文中的信息推荐
if (strpos($information->ic_content, '<!--@Content-Recommends-Article@-->') !== false) {
$information->ic_content = str_replace('<!--@Content-Recommends-Article@-->', $this->load->view($template_path . '-recommends-article', array('recommands' => $template_recommand), true), $information->ic_content);
}
//文中的线路推荐
if (strpos($information->ic_content, '<!--@Content-Recommends-Tour@-->') !== false) {
$information->ic_content = str_replace('<!--@Content-Recommends-Tour@-->', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), true), $information->ic_content);
}
2 years ago
//替换内容中广告
$temp_array = array();
preg_match_all('^<!--@TIPS-[A-Z]+-([0-9]+)@-->^', $information->ic_content, $temp_array);
1 year ago
if (!empty($temp_array[1])) {
2 years ago
foreach ($temp_array[1] as $key => $item) {
$tips_detail = $this->recommends_and_tips_model->tips_detail($item);
if ($tips_detail) {
$information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content);
}
2 years ago
}
}
2 years ago
$meta_product_code = get_meta($information->ic_id, 'meta_product_code');
// 非产品页面
1 year ago
if (empty($meta_product_code)) {
2 years ago
$addthis_widget = $this->load->view($template_path . '-add-this', false, true);
$template = str_replace('<!--@ADDTHIS-WIDGET@-->', $addthis_widget, $template);
$template = str_replace('?product_code=', '', $template);
} else {
$template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template);
$inquiry_form_template = $this->load->view(
$template_path . '-inquiry-form',
array('meta_product_code' => $meta_product_code, 'information' => $information),
true
);
$information->ic_content = str_replace('<!--@INQUIRY-FORM@-->', $inquiry_form_template, $information->ic_content);
// GP 表单
$gp_form_content = $this->load->view(
$template_path . '-gp-form',
array('meta_product_code' => $meta_product_code, 'information' => $information),
true
);
$information->ic_content = str_replace('<!--@GP-FORM@-->', $gp_form_content, $information->ic_content);
// tour-list 表单
$tour_list_form_content = $this->load->view(
$template_path . '-tour-list-form',
array('meta_product_code' => $meta_product_code, 'information' => $information),
true
);
$information->ic_content = str_replace('<!--@TOUR-LIST-FORM@-->', $tour_list_form_content, $information->ic_content);
// 水灯节 GP 线路表单
$gp_form_content = $this->load->view(
$template_path . '-lantern-festival-gp-form',
array('meta_product_code' => $meta_product_code, 'information' => $information),
true
);
$information->ic_content = str_replace('<!--@LANTERN-GP-FORM@-->', $gp_form_content, $information->ic_content);
}
2 years ago
$price_tag_list = $this->parse_price_tag($information->ic_content);
2 years ago
foreach ($price_tag_list as $price_tag) {
$information->ic_content = str_replace(
$price_tag['placeholder'],
$price_tag['price_number'],
$information->ic_content
);
}
// why-us 相关的标签
$why_us_mobile = $this->load->view($template_path . '-why-us-mobile', false, true);
$information->ic_content = str_replace('<!--@WHY_US_MOBILE@-->', $why_us_mobile, $information->ic_content);
$why_us_tour_detail_pc = $this->load->view($template_path . '-why-us-tour-detail-pc', false, true);
$information->ic_content = str_replace('<!--@WHY_US_TOUR_DETAIL_PC@-->', $why_us_tour_detail_pc, $information->ic_content);
$why_us_tour_list_pc = $this->load->view($template_path . '-why-us-tour-list-pc', false, true);
$information->ic_content = str_replace('<!--@WHY_US_TOUR_LIST_PC@-->', $why_us_tour_list_pc, $information->ic_content);
$info_page_form_content = $this->load->view($template_path . '-info-page-form', false, true);
$information->ic_content = str_replace('<!--@INFO-PAGE-FORM@-->', $info_page_form_content, $information->ic_content);
// 水灯节表单
$lantern_form_content = $this->load->view(
'mobile_first/ah-lantern-form',
2 years ago
array('information' => $information),
true
);
$information->ic_content = str_replace('<!--@LANTERN-FORM@-->', $lantern_form_content, $information->ic_content);
// CAD 跨年表单
$new_year_countdown_form_content = $this->load->view(
'mobile_first/ah-new-year-countdown',
array('information' => $information),
true
);
$information->ic_content = str_replace(
1 year ago
'<!--@NEW_YEAR-COUNTDOWN-FORM@-->',
$new_year_countdown_form_content,
$information->ic_content
);
2 years ago
// 动态加载反馈标签,第一个城市不足八条,使用第二城市数据。
// HTLM: <div><!--@FEEDBACK_Siem Reap,Bangkok@--></div>
// 解析结果:<!--@FEEDBACK_Siem Reap,Bangkok@-->; Siem Reap,Bangkok
$feedback_array = [];
preg_match_all('^<!--@FEEDBACK_(.*)@-->^', $information->ic_content, $feedback_array);
1 year ago
if (!empty($feedback_array)) {
2 years ago
foreach ($feedback_array[0] as $index => $tag_name) {
$city_name_string = $feedback_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_list = $this->Feedback_model->get_feedback_by_city_list($city_name_list);
// 防止触发 Google 网络垃圾政策只返回前三条
$top3_feedback_list = array_slice($feedback_list, 0, 3);
2 years ago
$feedback_content = $this->load->view(
'mobile_first/ah-feedback-list',
array('feedback_list' => $top3_feedback_list),
2 years ago
true
);
$information->ic_content = str_replace(
$tag_name,
$feedback_content,
$information->ic_content
);
}
}
2 years ago
2 years ago
// 动态加载反馈标签,每个城市三十条反馈。
// HTLM: <div><!--@FEEDBACK-30_Bangkok@--></div>
// 解析结果:<!--@FEEDBACK-30_Bangkok@-->; Bangkok
$feedback30_array = [];
preg_match_all('^<!--@FEEDBACK-30_(.*)@-->^', $information->ic_content, $feedback30_array);
1 year ago
if (!empty($feedback30_array)) {
2 years ago
foreach ($feedback30_array[0] as $index => $tag_name) {
$city_name = $feedback30_array[1][$index];
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name);
$feedback_30_content = $this->load->view(
'mobile_first/ah-feedback-30-list',
array('feedback_list' => $feedback_list),
true
);
$information->ic_content = str_replace(
$tag_name,
$feedback_30_content,
$information->ic_content
);
}
}
// 集合页面反馈标签
2 years ago
$feedback_city_array = [];
preg_match_all('^<!--@FEEDBACK-CITY-LIST_(.*)@-->^', $information->ic_content, $feedback_city_array);
1 year ago
if (!empty($feedback_city_array)) {
2 years ago
foreach ($feedback_city_array[0] as $index => $tag_name) {
$city_name_string = $feedback_city_array[1][$index];
$city_name_list = explode(',', $city_name_string);
$feedback_city_list = [];
foreach ($city_name_list as $index => $city_name) {
$feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5);
$data_name = str_replace(" ", "_", $city_name);
$feedback_city_list[$data_name] = $feedback_list;
}
$feedback_city_content = $this->load->view(
'mobile_first/ah-feedback-city-list',
$feedback_city_list,
true
);
$information->ic_content = str_replace(
$tag_name,
$feedback_city_content,
$information->ic_content
);
}
}
2 years ago
//主样式表,内联模式
if (is_file('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
$main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css'));
} else {
$main_css_string = compress_css(GET_HTTP('https://proxy-data.asiahighlights.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');
1 year ago
if (!empty($meta_addon_css)) {
2 years ago
//内联方式
$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');
1 year ago
if (!empty($meta_addon_js)) {
2 years ago
$template = str_replace('<!--@ADDON-JS@-->', '<script src="' . $meta_addon_js . '"></script>', $template);
}
1 year ago
$meta_index_set = get_meta($information->ic_id, 'meta_index_set');
1 year ago
if (!empty($meta_index_set)) {
$template = str_replace('<!--@Meta_Robots@-->', '<meta name="robots" content="' . $meta_index_set . '" />', $template);
}
2 years ago
//设置内容图片缓加载
$lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.asiahighlights.com/grey.gif');
$template = str_replace('<!--@CUSTOM-CONENT@-->', $lazy_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="2509031466" data-matched-content-rows-num="2,2" data-matched-content-columns-num="1,3" data-matched-content-ui-type="image_stacked,image_stacked"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
//}
//社媒分享图片
$full_ic_photo = '';
1 year ago
if (!empty($information->ic_photo)) {
2 years ago
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
} else {
$full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile');
}
1 year ago
if (!empty($full_ic_photo)) {
2 years ago
$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);
}
// 设置图片尺寸
// 优化过图片目录D:\wwwroot\origin-images.chinahighlights.com\optimize\
$www_local_path = 'D:/wwwroot/origin-www.asiahighlights.com';
$image_local_path = 'D:/wwwroot/origin-images.chinahighlights.com/optimize';
if (is_dir($www_local_path) && is_dir($image_local_path)) {
$template = $this->html_optimize_lib->set_image_size_local($template, $www_local_path, $image_local_path);
2 years ago
} else {
$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);
}
/**
* @description: CT用的生成静态文件方法.有些内容的替换CT这边不一样需要单独处理 zp
* @param {type} $device='mobile' or 'pc'
* @return:
* @Date Changed:
*/
public function make_www_cache_ct($information)
{
$data = array();
#region 公用数据
//$apiurl = "http://202.103.68.104:61/info.php"; //本地测试
$apiurl = "https://ct.mycht.cn/info.php"; //网前
//先准备数据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;
$meta_ct_page_type = "";
$meta_ct_page_type = get_meta($information->ic_id, 'meta_ct_page_type'); //页面类型
$meta_product_code = get_meta($information->ic_id, 'meta_product_code'); //绑定的产品编号
$template_path = 'mobile_first/' . $this->config->item('site_code'); //模板位置
//面包屑
$crumb = "";
$crumb_data = $this->Information_model->get_path_exclude_ct($information->is_id, $information->is_path);
if (count($crumb_data) > 0) { //至少有一个父类面包屑才显示
$crumb = "<div class=\"crumb\"><a href=\"/\">Home</a>";
foreach ($crumb_data as $index => $item) {
$crumb .= '<a href="' . $item['ic_url'] . '" data-index="' . $index . '" data-is-id="' . $item['is_id'] . '">' . $item['ic_url_title'] . '</a>';
}
$crumb .= "</div>";
}
$data["crumb"] = $crumb;
//作者字符串,信息页或者城市天气页加载 2022-7-26
$str_author = "";
$author = $this->Operator_model->get_author_nikename($information->ic_author);
$meta_news_createdate = get_meta($information->ic_id, 'meta_news_createdate'); //信息发布时间
1 year ago
if ((empty($meta_product_code) && !($meta_ct_page_type !== false && $meta_ct_page_type != "")) || $meta_ct_page_type == "weatherpage") {
$OPI_FirstName = !empty($author) ? $author->OPI_FirstName : 'author nickname';
$EditTime = strtotime($information->ic_datetime); //如果有录入信息发布时间的属性,就读取这个
if (!empty($meta_news_createdate)){
$EditTime = strtotime($meta_news_createdate);
}
$str_author = '<div class="authorupdate">Written by <strong>' . $OPI_FirstName . '</strong> Updated <span>' . date("M. j, Y", $EditTime) . '</span></div>';
2 years ago
}
2 years ago
//火车票详细页搜索框添加 -- zp
$meta_ct_page_trainform = get_meta($information->ic_id, 'meta_ct_page_trainform'); //是否插入火车票搜索框
$template_TrainDetailSearch = "";
if ($meta_ct_page_trainform == "yes" || $information->is_parent_id == "278014609") {
$meta_train_city = get_meta($information->ic_id, 'meta_train_city'); //默认的出发及目的地城市 beijing|shanghai
$data_TrainCity = array();
$data_TrainCity["from"] = "";
$data_TrainCity["to"] = "";
1 year ago
if (!empty($meta_train_city)) {
if (strpos($meta_train_city, '|') !== false) {
$arrTrainCity = explode('|', $meta_train_city);
$data_TrainCity["from"] = $arrTrainCity[0];
$data_TrainCity["to"] = $arrTrainCity[1];
1 year ago
}
}
$template_TrainDetailSearch = $this->load->view($template_path . '-train-detail', $data_TrainCity, true);
2 years ago
}
2 years ago
/* 详细内容 */
$ic_content = $information->ic_content;
#region old replace
// /**替换详细内容里面的价格
/* 直接使用fetch来动态获取价格这样不用替换标签直接录标签
// * // 一日游价格标签, "<!--@DayTripPrice:XASIC-41@-->" 或者<!--@DayTripPrice:XASIC-41,2@--> 逗号后面是人数
// * //精华线路标签"<!--@TourPrice:ct-1@-->"
// */
// $ic_content = preg_replace_callback('/<!--@DayTripPrice:(.*)@-->/i',function($match){
// //处理一日游每次配备
// $matchItem = $match[1];
// return '<span class="js_getDayTripPrice" data="'.$matchItem.'"></span>';;
// },$ic_content);
// $ic_content = preg_replace_callback('/<!--@TourPrice:(.*)@-->/i',function($match){
// //处理精华线路每次配备
// $matchItem = $match[1];
// return '<span class="js_getTourPrice" data="'.$matchItem.'"></span>';;
// },$ic_content);
#enregion
/** 替换H1加面包屑,加作者. 2024-4-26不在H1放火车搜索框改为替换标签 */
//$ic_content = preg_replace('/<h1>(.*)<\/h1>/i', $crumb . "\r\n" . '<H1>$1</H1>' . "\r\n" . $str_author . $template_TrainDetailSearch . "\r\n", $ic_content, 1);
$ic_content = preg_replace('/<h1>(.*)<\/h1>/i', $crumb . "\r\n" . '<H1>$1</H1>' . "\r\n" . $str_author . "\r\n", $ic_content, 1);
/**替换火车标签 */
if (strpos($ic_content, '<!--@TRAINSEARCH-FORM@-->') !== false) {
1 year ago
$ic_content = str_replace('<!--@TRAINSEARCH-FORM@-->', $template_TrainDetailSearch, $ic_content);
}
2 years ago
/**替换zodiac标签 */
if (strpos($ic_content, '<!--@ZODIAC-CALC@-->') !== false) {
$zodiacCalc = $this->load->view('mobile_first/' . $this->config->item('site_code') . '-zodiac-calc', false, true);
$ic_content = str_replace('<!--@ZODIAC-CALC@-->', $zodiacCalc, $ic_content);
}
2 years ago
//图片加延迟
$ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.chinatravel.com/images/mobile-first/grey.gif');
2 years ago
$ic_content = $this->html_optimize_lib->set_image_size($ic_content);
4 years ago
2 years ago
$data["CUSTOMCONENT"] = $ic_content;
4 years ago
2 years ago
//非产品页面
$data["PRODUCTJS"] = "";
$data["ISPRODUCT"] = "no"; //判断是否是产品页
$data["addthis_widget"] = "";
$data["FloatIcon"] = ""; //浮动图标替代addthis
$arrExitUrl = array("/", "/culture", "/guide", "/tour", "/citytour", "/daytrip", "/asia-tour", "/china-trains");
2 years ago
1 year ago
if (empty(get_meta($information->ic_id, 'meta_product_code')) || in_array($information->ic_url, $arrExitUrl)) {
2 years ago
//$data["addthis_widget"] = $this->load->view($template_path . '-add-this', false, true); //社媒代码addthis
$data["FloatIcon"] = "<div class=\"fixed-tm\"><a href=\"/forms/customize\" >Create My Trip</a></div>";
} else {
// $data["PRODUCTJS"] = '<script src="https://data.chinatravel.com/js/mobile-first/flatpickr.js"></script>';
$data["ISPRODUCT"] = "yes";
}
2 years ago
//顶部视频
$data["TOPVIDEO"] = "";
$meta_news_video = get_meta($information->ic_id, 'meta_news_video');
$meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
1 year ago
if (!empty($meta_news_video) && !empty($meta_video_picture)) {
2 years ago
$data["TOPVIDEO"] = '<div class="banner"><video autoplay="" controls="controls" id="bgvid" poster="' . $meta_video_picture . '" src="' . $meta_news_video . '" style="position: inherit;"> </video></div>';
}
4 years ago
2 years ago
//主样式表,内联模式
//$apiweb="http://202.103.68.104"; //本地测试
$apiweb = "https://data.chinatravel.com";
$cssUrl = $apiweb . "/css/newcss3/base.css?v=" . time();
$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');
1 year ago
if (!empty($meta_addon_css)) {
2 years ago
//引用方式
//$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>';
}
//社媒分享图片
$data["OGIMAGE"] = "";
1 year ago
if (!empty($information->ic_photo)) {
2 years ago
if (strpos($information->ic_photo, "chinatravel.com") != false) {
$full_ic_photo = $information->ic_photo;
} else {
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
}
$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">';
}
2 years ago
//结构化标签
$data["ConstructionCode"] = "";
$meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
1 year ago
if (!empty($meta_construction_code)) {
2 years ago
$data["ConstructionCode"] = $meta_construction_code;
}
4 years ago
2 years ago
//总JS为了方便以后js好维护必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js所以必须在这里进行判断
$addBaseJs = false;
$addonJs = "";
$meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
2 years ago
if ($meta_ct_page_price == "yes") {
$addBaseJs = true;
} else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
$addBaseJs = true;
}
2 years ago
if ($addBaseJs) {
$addonJs = '<script src="' . $apiweb . '/js/mobile-first/base.js" defer></script>';
}
/// ----- 总JS判断完成-----
2 years ago
//额外js
$data["ADDONJS"] = "";
$meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
1 year ago
if (!empty($meta_addon_js)) {
2 years ago
$addonJs .= '<script src="' . $meta_addon_js . '" defer></script>';
}
//价格js
if ($meta_ct_page_price == "yes") {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getprice.js" defer></script>';
}
2 years ago
2 years ago
//列表js
if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getlist.js" defer></script>';
}
2 years ago
//天气
if (in_array($meta_ct_page_type, array('weatherpage'))) {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getweather.js" defer></script>';
}
2 years ago
//页面传递参数
$passParam = "";
if (in_array($meta_ct_page_type, array("daytripindex", "tourindex", "attractionindex", "weatherpage"))) { //一日游和线路列表
//产品首页
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
if (in_array($meta_ct_page_type, array("attractionindex"))) {
//旧信息id,景点等信息类
$passParam .= '<input type="hidden" name="param_old_pid" id="param_old_pid" value="' . $meta_ct_page_value . '"/>';
} else {
//城市名称,产品类用
$passParam .= '<input type="hidden" name="param_city" id="param_city" value="' . $meta_ct_page_value . '"/>';
}
//加信息平台的is_id
$passParam .= '<input type="hidden" name="param_parentId" id="param_parentId" value="' . $information->is_id . '"/>';
}
2 years ago
//产品详细页
$productType = "";
$productCode = "";
if ($meta_ct_page_type == "daytripdetail") {
//一日游
1 year ago
if (!empty($meta_ct_page_type)) {
2 years ago
$productType = $meta_ct_page_type;
}
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
1 year ago
if (!empty($meta_ct_page_value)) {
2 years ago
$productCode = $meta_ct_page_value;
}
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/daytripdetail.js" defer></script>';
//$addonJs .= '<script src="'.$apiweb.'/js/mobile-first/flatpickr.js"></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/newcss3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
if ($meta_ct_page_type == "tourdetail") {
//线路
$productType = $meta_ct_page_type;
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
1 year ago
if (!empty($meta_ct_page_value)) {
2 years ago
$productCode = $meta_ct_page_value;
}
2 years ago
//获取cli_sn
$tourdata = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/api/getCliSn/?param=" . $productCode));
$data["clisn"] = $tourdata->clisn;
2 years ago
//调取模板
$dataform["TourCode"] = $productCode;
$dataform["CLI_SN"] = $tourdata->clisn;
$dataform["TourName"] = $information->ic_title;
2 years ago
}
2 years ago
//游船详细页
if ($meta_ct_page_type == "cruisedetails") {
$productType = $meta_ct_page_type;
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
1 year ago
if (!empty($meta_ct_page_value)) {
2 years ago
$productCode = $meta_ct_page_value;
}
$dataCruise["shipname"] = $productCode;
$template_curisedetails = $this->load->view($template_path . '-cruisedetails-form', $dataCruise, true);
$data["template_curisedetails"] = $template_curisedetails;
}
2 years ago
//表单页
if (in_array($meta_ct_page_type, array("customize", "contactus", "pagewithform", "tourdetail"))) {
$productType = $meta_ct_page_type;
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/form.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/newcss3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
2 years ago
$data["productType"] = $productType;
$data["productCode"] = $productCode;
//页面添加的元素
$data["ADDONJS"] = $addonJs;
$data["passParam"] = $passParam;
#endregion
#region 移动端和PC端差别处理区域
$arrDevice = array("mobile", "pc");
1 year ago
$data["showFormTourQi"]=true; //是否显示线路表单,默认显示
2 years ago
foreach ($arrDevice as $device) {
//顶部全屏大图
$data["TOPBANNER"] = "";
$ImgText = ""; //图文字
$meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
$meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text');
if ($device == 'mobile') { //移动端读取移动大图
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
$bannerImg = '<img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '" width="750" height="500">';
1 year ago
if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title"><a href="' . $meta_addon_picture_url . '">' . $meta_addon_picture_text . '</a></p></div>';
1 year ago
} else if (!empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title">' . $meta_addon_picture_text . '</p></div>';
}
} else {
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
$bannerImg = '<img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '" width="1920" height="600">';
1 year ago
if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title"><a href="' . $meta_addon_picture_url . '">' . $meta_addon_picture_text . '</a></p></div>';
1 year ago
} else if (!empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title">' . $meta_addon_picture_text . '</p></div>';
}
}
// 搜索框
$template_TrainSearch = "";
if ($information->ic_url == "/china-trains/hometest" || $information->ic_url == "/china-trains") {
//火车票首页
$template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
$ImgText = "";
//火车票移动端去掉头部图片保证搜索框CLS
if ($device == 'mobile') {
$meta_addon_picture = "";
$data["TOPBANNER"] = '<div class="banner">' . $template_TrainSearch . '</div>';
}
} else if ($information->ic_url == "/china-flights") {
//机票首页
$template_TrainSearch = $this->load->view($template_path . '-flight-index', null, true);
$ImgText = "";
//飞机票移动端去掉头部图片保证搜索框CLS
if ($device == 'mobile') {
$meta_addon_picture = "";
$data["TOPBANNER"] = '<div class="banner">' . $template_TrainSearch . '</div>';
}
}
1 year ago
if (!empty($meta_addon_picture)) {
if (!empty($meta_addon_picture_url)) {
2 years ago
$data["TOPBANNER"] = '<div class="banner"><a href="' . $meta_addon_picture_url . '">' . $bannerImg . ' </a>' . $ImgText . $template_TrainSearch . '</div>';
} else {
2 years ago
$data["TOPBANNER"] = '<div class="banner">' . $bannerImg . $ImgText . $template_TrainSearch . '</div>';
}
}
2 years ago
if ($meta_ct_page_type == "tourdetail") {
$dataform['device'] = $device;
$template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
$data["template_form_tourqi"] = $template_form_tourqi; //表单模板字符串
/**替换左右结构的线路表单标签 2024-7-4*/
if (strpos($ic_content, '<!--@TOUR-FORM@-->') !== false) {
1 year ago
$template_form_tourqi = $this->load->view($template_path . '-form-tourqi-new', $dataform, true);
$ic_content = str_replace('<!--@TOUR-FORM@-->', $template_form_tourqi, $ic_content);
1 year ago
$data["showFormTourQi"]=false; //如果有标签就不显示外面的表单,因为$ic_content会在第一次就替换掉标签所以第二次pc端这里不执行。
$data["CUSTOMCONENT"] = $ic_content;
}
2 years ago
}
//两种设备分别调用两种模板 ,静态化
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) == '/') {
$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);
}
#endregion
}
/**
* 上海站
*/
public function make_www_cache_sh($information)
{
$data = array();
#region 公用数据
//$apiurl = "http://202.103.68.104:61/info.php"; //本地测试
$apiurl = "https://ct.mycht.cn/info.php"; //网前
//先准备数据,采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
$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;
$meta_ct_page_type = "";
$meta_ct_page_type = get_meta($information->ic_id, 'meta_ct_page_type'); //页面类型
$meta_product_code = get_meta($information->ic_id, 'meta_product_code'); //绑定的产品编号
$template_path = 'mobile_first/' . $this->config->item('site_code'); //模板位置
//面包屑
$crumb = "";
$crumb_data = $this->Information_model->get_path_exclude_ct($information->is_id, $information->is_path);
if (count($crumb_data) > 0) { //至少有一个父类面包屑才显示
$crumb = "<div class=\"crumb\"><a href=\"/\">Home</a>";
foreach ($crumb_data as $index => $item) {
$crumb .= '<a href="' . $item['ic_url'] . '" data-index="' . $index . '" data-is-id="' . $item['is_id'] . '">' . $item['ic_url_title'] . '</a>';
}
$crumb .= "</div>";
}
$data["crumb"] = $crumb;
//作者字符串,信息页或者城市天气页加载 2022-7-26
$str_author = "";
$author = $this->Operator_model->get_author_nikename($information->ic_author);
1 year ago
if ((empty($meta_product_code) && !($meta_ct_page_type !== false && $meta_ct_page_type != "")) || $meta_ct_page_type == "weatherpage") {
$OPI_FirstName = !empty($author) ? $author->OPI_FirstName : 'author nickname';
2 years ago
$str_author = '<div class="authorupdate">Written by <strong>' . $OPI_FirstName . '</strong> Updated <span>' . date("M. j, Y", strtotime($information->ic_datetime)) . '</span></div>';
}
2 years ago
/* 详细内容 */
$ic_content = $information->ic_content;
2 years ago
/** 替换H1加面包屑,加作者 */
$ic_content = preg_replace('/<h1>(.*)<\/h1>/i', $crumb . "\r\n" . '<H1>$1</H1>' . "\r\n" . $str_author . "\r\n", $ic_content, 1);
2 years ago
//图片加延迟
$ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.shanghaihighlights.com/image/grey.gif');
2 years ago
$ic_content = $this->html_optimize_lib->set_image_size($ic_content);
2 years ago
//非产品页面
$data["PRODUCTJS"] = "";
$data["ISPRODUCT"] = "no"; //判断是否是产品页
$data["addthis_widget"] = "";
$data["FloatIcon"] = ""; //浮动图标替代addthis
$arrExitUrl = array("/", "/culture", "/guide", "/tour", "/citytour", "/daytrip", "/asia-tour", "/china-trains");
1 year ago
if (empty(get_meta($information->ic_id, 'meta_product_code')) || in_array($information->ic_url, $arrExitUrl)) {
2 years ago
$data["FloatIcon"] = "<div class=\"fixed-tm\"><a href=\"/forms/customize\" >Create My Trip</a></div>";
} else {
$data["ISPRODUCT"] = "yes";
}
2 years ago
//顶部视频
$data["TOPVIDEO"] = "";
$meta_news_video = get_meta($information->ic_id, 'meta_news_video');
$meta_video_picture = get_meta($information->ic_id, 'meta_video_picture');
1 year ago
if (!empty($meta_news_video) && !empty($meta_video_picture)) {
2 years ago
$data["TOPVIDEO"] = '<div class="banner"><video autoplay="" controls="controls" id="bgvid" poster="' . $meta_video_picture . '" src="' . $meta_news_video . '" style="position: inherit;"> </video></div>';
}
2 years ago
//主样式表,内联模式
//$apiweb="http://202.103.68.104:81"; //本地测试
$apiweb = "https://data.shanghaihighlights.com";
$cssUrl = $apiweb . "/css/css3/base.css?v=" . time();
$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');
1 year ago
if (!empty($meta_addon_css)) {
2 years ago
//引用方式
//$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>';
}
//社媒分享图片
$data["OGIMAGE"] = "";
1 year ago
if (!empty($information->ic_photo)) {
2 years ago
if (strpos($information->ic_photo, "shanghaihighlights.com") != false) {
$full_ic_photo = $information->ic_photo;
} else {
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
}
$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">';
}
2 years ago
//结构化标签
$data["ConstructionCode"] = "";
$meta_construction_code = get_meta($information->ic_id, 'meta_construction_code');
1 year ago
if (!empty($meta_construction_code)) {
2 years ago
$data["ConstructionCode"] = $meta_construction_code;
}
2 years ago
//总JS为了方便以后js好维护必须的把一些公用的JS统计到一个文件。但是又不是所有页面都需要调用这个基础js所以必须在这里进行判断
$addBaseJs = false;
$addonJs = "";
$meta_ct_page_price = get_meta($information->ic_id, 'meta_ct_page_price'); //是否包含价格
2 years ago
if ($meta_ct_page_price == "yes") {
$addBaseJs = true;
} else if ($meta_ct_page_type !== false && $meta_ct_page_type != "") {
$addBaseJs = true;
}
2 years ago
if ($addBaseJs) {
$addonJs = '<script src="' . $apiweb . '/js/mobile-first/base.js" defer></script>';
}
/// ----- 总JS判断完成-----
2 years ago
//额外js
$data["ADDONJS"] = "";
$meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
1 year ago
if (!empty($meta_addon_js)) {
2 years ago
$addonJs .= '<script src="' . $meta_addon_js . '" defer></script>';
}
//价格js
if ($meta_ct_page_price == "yes") {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getprice.js" defer></script>';
}
2 years ago
//列表js
if (in_array($meta_ct_page_type, array('daytripindex', 'tourindex', 'attractionindex'))) {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getlist.js" defer></script>';
}
2 years ago
//天气
if (in_array($meta_ct_page_type, array('weatherpage'))) {
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/getweather.js" defer></script>';
}
2 years ago
//页面传递参数
$passParam = "";
if (in_array($meta_ct_page_type, array("daytripindex", "tourindex", "attractionindex", "weatherpage"))) { //一日游和线路列表
//产品首页
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
if (in_array($meta_ct_page_type, array("attractionindex"))) {
//旧信息id,景点等信息类
$passParam .= '<input type="hidden" name="param_old_pid" id="param_old_pid" value="' . $meta_ct_page_value . '"/>';
} else {
//城市名称,产品类用
$passParam .= '<input type="hidden" name="param_city" id="param_city" value="' . $meta_ct_page_value . '"/>';
}
//加信息平台的is_id
$passParam .= '<input type="hidden" name="param_parentId" id="param_parentId" value="' . $information->is_id . '"/>';
}
2 years ago
//产品详细页
$productType = "";
$productCode = "";
if ($meta_ct_page_type == "daytripdetail") {
//一日游
1 year ago
if (!empty($meta_ct_page_type)) {
2 years ago
$productType = $meta_ct_page_type;
}
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
1 year ago
if (!empty($meta_ct_page_value)) {
2 years ago
$productCode = $meta_ct_page_value;
}
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/daytripdetail.js" defer></script>';
//$addonJs .= '<script src="'.$apiweb.'/js/mobile-first/flatpickr.js"></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
//一日游表单的替换
$DayTripData["productCode"] = $productCode;
$template_form_daydetail = $this->load->view($template_path . '-daydetail-form', $DayTripData, true); //模板内容
//使用simple_html_dom_lib库来进行表单添加
$ic_content = $this->html_optimize_lib->add_htmlcode($ic_content, "#maincontent", $template_form_daydetail);
}
if ($meta_ct_page_type == "tourdetail") {
//线路
$productType = $meta_ct_page_type;
$meta_ct_page_value = get_meta($information->ic_id, 'meta_ct_page_value');
1 year ago
if (!empty($meta_ct_page_value)) {
2 years ago
$productCode = $meta_ct_page_value;
}
//获取cli_sn
$tourdata = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/apish/getCliSn/?param=" . $productCode));
2 years ago
$data["clisn"] = $tourdata->clisn;
//获取price
$tourprice = json_decode(GET_HTTP($apiurl . "/thirdparty/ctmobilefirst/apish/getTourPrice/?param=" . $productCode));
$dataform["tourprice"] = $tourprice->price;
2 years ago
//调取模板
$dataform["TourCode"] = $productCode;
$dataform["CLI_SN"] = $tourdata->clisn;
$dataform["TourName"] = $information->ic_title;
$dataform["ic_photo"] = $information->ic_photo;
$template_form_tourqi = $this->load->view($template_path . '-form-tourqi', $dataform, true);
//使用simple_html_dom_lib库来进行表单添加
$ic_content = $this->html_optimize_lib->add_htmlcode($ic_content, "#maincontent", $template_form_tourqi);
2 years ago
}
2 years ago
//表单页
if (in_array($meta_ct_page_type, array("customize", "contactus", "pagewithform", "tourdetail"))) {
$productType = $meta_ct_page_type;
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/form.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/flatpickr.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
2 years ago
if ($meta_ct_page_type == "daytripform") {
$productType = $meta_ct_page_type;
$addonJs .= '<script src="' . $apiweb . '/js/mobile-first/daytrip-form.js" defer></script>';
$data["ADDONCSS"] .= '<link href="' . $apiweb . '/css/css3/form.css" rel="preload" as="style" onload="this.rel=\'stylesheet\'" />';
}
2 years ago
$data["productType"] = $productType;
$data["productCode"] = $productCode;
//页面添加的元素
$data["ADDONJS"] = $addonJs;
$data["passParam"] = $passParam;
//页面详细内容放最后,这样上面都可以进行内容的替换,比如一日游表单
$data["CUSTOMCONENT"] = $ic_content;
#endregion
#region 移动端和PC端差别处理区域
$arrDevice = array("mobile", "pc");
foreach ($arrDevice as $device) {
//顶部全屏大图
$data["TOPBANNER"] = "";
$ImgText = ""; //图文字
$meta_addon_picture_url = get_meta($information->ic_id, 'meta_addon_picture_url');
$meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text');
if ($device == 'mobile') { //移动端读取移动大图
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile');
$bannerImg = '<img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '" width="750" height="500">';
1 year ago
if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title"><a href="' . $meta_addon_picture_url . '">' . $meta_addon_picture_text . '</a></p></div>';
1 year ago
} else if (!empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title">' . $meta_addon_picture_text . '</p></div>';
}
} else {
$meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture');
$bannerImg = '<img class="img-responsive" alt="' . $information->ic_title . '" src="' . $meta_addon_picture . '" width="1920" height="600">';
1 year ago
if (!empty($meta_addon_picture_url) && !empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title"><a href="' . $meta_addon_picture_url . '">' . $meta_addon_picture_text . '</a></p></div>';
1 year ago
} else if (!empty($meta_addon_picture_text)) {
2 years ago
$ImgText = '<div class="carousel-caption"><p class="ads-title">' . $meta_addon_picture_text . '</p></div>';
}
}
// 搜索框
$template_TrainSearch = "";
if ($information->ic_url == "/china-trains/hometest" || $information->ic_url == "/china-trains") {
//火车票首页
$template_TrainSearch = $this->load->view($template_path . '-train-index', null, true);
$ImgText = "";
//火车票移动端去掉头部图片保证搜索框CLS
if ($device == 'mobile') {
$meta_addon_picture = "";
$data["TOPBANNER"] = '<div class="banner">' . $template_TrainSearch . '</div>';
}
} else if ($information->ic_url == "/china-flights") {
//机票首页
$template_TrainSearch = $this->load->view($template_path . '-flight-index', null, true);
$ImgText = "";
//飞机票移动端去掉头部图片保证搜索框CLS
if ($device == 'mobile') {
$meta_addon_picture = "";
$data["TOPBANNER"] = '<div class="banner">' . $template_TrainSearch . '</div>';
}
}
1 year ago
if (!empty($meta_addon_picture)) {
if (!empty($meta_addon_picture_url)) {
2 years ago
$data["TOPBANNER"] = '<div class="banner"><a href="' . $meta_addon_picture_url . '">' . $bannerImg . ' </a>' . $ImgText . $template_TrainSearch . '</div>';
} else {
2 years ago
$data["TOPBANNER"] = '<div class="banner">' . $bannerImg . $ImgText . $template_TrainSearch . '</div>';
}
}
//两种设备分别调用两种模板 ,静态化
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) == '/') {
$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);
}
2 years ago
#endregion
}
//通过内容找到第一张图片
public function set_photo_content($ic_photo, $ic_content)
{
1 year ago
if (empty($ic_photo)) {
2 years ago
$images = get_image_url_by_source($ic_content);
1 year ago
if (!empty($images) and !empty($images[1])) {
2 years ago
return $images[1][0];
}
} else {
return $this->config->item('site_image_url') . $ic_photo;
}
return '';
}
//根据推荐规则进行查询
public function recommand_information_rule($information, $root_information, $recommand, &$exclude_ids)
{
$data = array();
switch ($recommand->ir_rule) {
case 'rule_same_node_keyword': //同节点关键词
$keywords = explode(',', $recommand->ir_keyword);
$data = $this->Information_model->search_by_words_2($root_information->is_path, $keywords, $exclude_ids);
break;
case 'rule_same_url_keyword': //同URL关键词
$keywords = explode(',', $recommand->ir_keyword);
$url = trim($information->ic_url);
$url = substr($url, 0, strpos($url, '/', 1) + 1);
$data = $this->Information_model->search_by_words($url, $keywords, $exclude_ids);
break;
case 'rule_same_node_random': //同节点随机
$data = $this->Information_model->random(1, $root_information->is_path, $exclude_ids);
break;
case 'rule_this_node_random': //指定节点下随机
$ir_pointer = $this->Information_model->Detail($recommand->ir_pointer_is_id, 'is_path');
1 year ago
if (!empty($ir_pointer)) {
2 years ago
$data = $this->Information_model->random(1, $ir_pointer->is_path, $exclude_ids);
}
break;
case 'rule_range_random': //范围内随机,同读取备用节点
break;
case 'rule_show_tips': //显示广告
$data = $this->recommends_and_tips_model->tips_detail($recommand->ir_pointer_it_id);
return array($recommand->ir_name => $data);
2 years ago
//break;
case 'rule_no_show': //不显示
return array($recommand->ir_name => false);
//break;
default: //'rule_parent'://继承上级规则则留空,程序会循环一遍分组的规则
return false;
}
2 years ago
//读取备用节点
1 year ago
if (empty($data) && !empty($recommand->ir_urls)) { //查不到信息并且备选urls不为空则随机选一条
2 years ago
// $url_array = explode("\n", $recommand->ir_urls);
// $data = $this->Information_model->Detail(trim($url_array[rand(0, count($url_array) - 1)]));
$url_array = explode("\n", $recommand->ir_urls);
$data = $this->Information_model->random_range(1, $url_array, $exclude_ids);
}
1 year ago
if (!empty($data)) {
2 years ago
$exclude_ids[] = $data->is_id;
$data->desktop_photo = get_meta($data->ic_id, 'meta_addon_picture');
$data->mobile_photo = get_meta($data->ic_id, 'meta_addon_picture_mobile');
1 year ago
if (empty($data->mobile_photo)) {
if (!empty($data->ic_photo)) {
2 years ago
$data->mobile_photo = $this->config->item('site_image_url') . $data->ic_photo;
} else {
$data->mobile_photo = 'https://data.chinahighlights.com/image/travelguide/article/recommended-info-bottom-cover.jpg';
}
2 years ago
}
}
return array($recommand->ir_name => $data);
}
//获取当前信息所有的推荐信息和广告内容
public function recommand_information($information)
{
$data = array();
$group_detail = $this->Information_model->get_detail_by_path($information->is_path, 0); //信息所属分组,根据分组进行不同推荐
$group_recommands = $this->recommends_and_tips_model->recommends_list($group_detail->is_id); //节点下所有的推荐规则
$root_detail = $this->Information_model->get_detail_by_path($information->is_path, 1); //信息所属分类,获取信息顶级节点内容
$root_recommands = $this->recommends_and_tips_model->recommends_list($root_detail->is_id); //节点下所有的推荐规则
$exclude_ids = array($information->is_id); //需要排除的is_id防止通过页面显示相同内容默认排除本身每个推荐内容都需要排除已经推荐过的
foreach ($root_recommands as $item) {
if ($this->config->item('site_code') == 'ah' or $this->config->item('site_code') == 'ch' or $this->config->item('site_code') == 'gh') { //如果是AH CH GH的页面取消重复检测
2 years ago
$exclude_ids = array(0);
}
$result = $this->recommand_information_rule($information, $root_detail, $item, $exclude_ids);
1 year ago
if (!empty($result)) {
2 years ago
$data += $result;
}
}
2 years ago
foreach ($group_recommands as $item) {
if ($this->config->item('site_code') == 'ah' or $this->config->item('site_code') == 'ch' or $this->config->item('site_code') == 'gh') { //如果是AH CH GH的页面取消重复检测
$exclude_ids = array(0);
}
1 year ago
if (empty($data[$item->ir_name])) {
2 years ago
$result = $this->recommand_information_rule($information, $root_detail, $item, $exclude_ids);
1 year ago
if (!empty($result)) {
2 years ago
$data += $result;
}
2 years ago
}
}
//print_r($data);
//log_message('error', 'exclude_ids: '.$information->ic_url.' '.implode(',',$exclude_ids));
return $data;
}
public function call_mobile_template_NEXT($template_path, $is_id)
{
$data['detail'] = $this->Information_model->Detail($is_id);
$data['type_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 0); //信息所属分组,根据分组进行不同推荐
$data['root_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 1); //信息所属分类,获取信息顶级节点内容
switch (strtolower($data['type_detail']->is_id)) {
case 278008010: //Inspiration
//随机获取两个同级节点内容
$random_array = $this->Information_model->random(2, $data['root_detail']->is_path, array($data['detail']->is_id));
1 year ago
if (!empty($random_array[0])) {
2 years ago
$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);
}
1 year ago
if (!empty($random_array[1])) {
2 years ago
$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);
}
//漏斗作用的页面,随机挑选一篇
$random_array = array(
'/travelguide/china-facts.htm',
'/travelguide/article-top-china-tourist-destination.htm',
'/travelguide/most-beautiful-places.htm',
'/weather/china-best-times.htm',
'/travelguide/article-10-movies-to-watch.htm',
'/travelguide/article-culture-shock-in-china.htm',
'/travelguide/article-what-chinese-eat-for-breakfast.htm',
'/travelguide/china-top-10-attractions.htm',
'/travelguide/chinese-food/eight-chinese-dishes.htm',
'/travelguide/china-travel-reopen-restrictions.htm',
);
$data['info_topthings'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
1 year ago
if (!empty($data['info_topthings'])) {
2 years ago
$data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1);
$data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
}
//文化板块的页面,随机挑选一篇
$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)]);
1 year ago
if (!empty($data['info_hotel'])) {
2 years ago
$data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);
$data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
}
break;
case 278008012: //'planing-1(guide)':
case 278008013: //'planning-2 (decision tips)':
case 278008011: //'destination': //url的第一段表示地区根据第一段来搜索相关数据如/beijing/ 而不是根据is_parent_id因为可能信息和线路是在不同的分类下
$destination_url = trim($data['detail']->ic_url);
$destination_url = substr($destination_url, 0, strpos($destination_url, '/', 1) + 1);
//how to plan
$data['info_howtoplan'] = $this->Information_model->search_by_words($destination_url, array('how', 'plan'), array($data['detail']->is_id));
1 year ago
if (empty($data['info_howtoplan'])) { //找不到对应信息则显示备用
2 years ago
$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); //信息所属分类,获取信息顶级节点内容
1 year ago
if (!empty($data['info_howtoplan'])) {
2 years ago
$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($destination_url, array('best', 'time'), array($data['detail']->is_id));
1 year ago
if (empty($data['info_besttime'])) {
2 years ago
$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); //信息所属分类,获取信息顶级节点内容
1 year ago
if (!empty($data['info_besttime'])) {
2 years ago
$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($destination_url, array('top', 'things'), array($data['detail']->is_id));
1 year ago
if (empty($data['info_topthings'])) {
2 years ago
$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); //信息所属分类,获取信息顶级节点内容
1 year ago
if (!empty($data['info_topthings'])) {
2 years ago
$data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
}
//第四篇随机推荐下方url
$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',
);
$data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
1 year ago
if (!empty($data['info_hotel'])) {
2 years ago
$data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);
$data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
}
2 years ago
break;
default:
return '';
}
2 years ago
return $this->load->view($template_path . '-next', $data, true);
}
//更新静态文件
//不用参数提交的原因是可能url带有特殊字符CI会报错
public function update_cache($static_html_url = false, $delete_only = false)
{
1 year ago
$url = !empty($static_html_url) ? $static_html_url : $this->input->post('cache_url');
2 years ago
$url = str_replace($this->config->item('site_url'), '', $url);
$original_url = $url; //原始链接
1 year ago
$delete_only = !empty($delete_only) ? $delete_only : $this->input->get_post('delete_only');
2 years ago
switch ($this->config->item('site_code')) {
case 'cht':
$search_list = $this->Information_model->search_url($url);
$amp_request = false;
foreach ($search_list as $key => $req_url) {
$meta_amp_status = get_meta($req_url->ic_id, 'AMP_STATUS');
if ($meta_amp_status) {
$amp_request = true;
}
}
if ($amp_request) {
$url = 'http://169.54.167.189:22224/ampreq' . $url;
} else {
2 years ago
$url = 'http://169.54.167.189:22224' . $url;
}
break;
case 'ah':
if ($delete_only === true) {
$url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url;
} else { // static_html_optimize=comeon 启用静态化压缩和js、css延迟加载
$url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon';
}
break;
case 'gm':
//GET_HTTP("http://148.251.35.42:3300/create-cache/?url=" . urlencode($url)); //请求nodejs静态化更新页面删除缓存因为部分页面没有进入信息平台
//if ($delete_only) {
// $url = "https://www.chinarundreisen.com/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url);
2 years ago
//} else {
//先删除再生成,部分页面没有在信息平台中
GET_HTTP("https://www.chinarundreisen.com/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url));
$url = "https://www.chinarundreisen.com/gm.php/information/detail/?static_html_url=" . $url;
2 years ago
//}
break;
//国际站
case 'vac':
case 'vc':
case 'it':
case 'ru':
case 'jp':
$information = $this->Information_model->Detail($url);
$meta_pc_amp = @get_meta($information->ic_id, 'AMP_BODY_PC_STATUS');
if ($delete_only) {
//只删除操作在url修改和不发布信息的时候使用
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
} else {
$tmp = $url;
//判断是否是更新信息
// 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
1 year ago
if (!empty($information->ic_content) || !empty($information->ic_summary) || $meta_pc_amp == 'yes') {
2 years ago
$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
} else {
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url;
//$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
}
1 year ago
if (isset($information->ic_type) && $information->ic_type == 'product') {
2 years ago
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
}
//int return direct
$cache_url = $this->input->post('cache_url');
if ($url && !$cache_url) {
/*
ignore_user_abort(true);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
*/
$data['async_update'] = $url;
$data[] = array('name' => 'ok', 'value' => '信息保存成功请在8秒后检查更新页面。', 'url' => $url);
//如果是外部调用就返回结果,内部就不返回了
if ($cache_url) {
echo json_encode($data);
}
return $data;
}
}
break;
1 year ago
//国际站 - GH - add gm
2 years ago
case 'gh_vac':
case 'gh_vc':
case 'gh_it':
case 'gh_ru':
case 'gh_jp':
1 year ago
case 'gh_gm':
2 years ago
$information = $this->Information_model->Detail($url);
$meta_pc_amp = @get_meta($information->ic_id, 'AMP_BODY_PC_STATUS');
if ($delete_only) {
//只删除操作在url修改和不发布信息的时候使用
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
} else {
$tmp = $url;
//判断是否是更新信息
// 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
1 year ago
if (!empty($information->ic_content) || !empty($information->ic_summary) || $meta_pc_amp == 'yes') {
2 years ago
$url = $this->config->item('site_url') . '/index.php/gh/info/detail/?static_html_url=' . $url;
} else {
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url;
//$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
}
1 year ago
if (isset($information->ic_type) && $information->ic_type == 'product') {
2 years ago
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
}
// GH国际 不发布的时候删除缓存
1 year ago
if (isset($information) && !empty($information) && !$information->ic_status) {
2 years ago
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $tmp;
}
//int return direct
$cache_url = $this->input->post('cache_url');
if ($url && !$cache_url) {
/*
ignore_user_abort(true);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
*/
$data['async_update'] = $url;
$data[] = array('name' => 'ok', 'value' => '信息保存成功请在8秒后检查更新页面。', 'url' => $url);
//如果是外部调用就返回结果,内部就不返回了
if ($cache_url) {
echo json_encode($data);
}
return $data;
}
}
break;
case 'ct': //子站点使用
$url = 'http://50.97.246.187:22223' . $url;
break;
case 'sht':
case 'gl':
case 'mbj':
case 'yz':
$url = $this->config->item('site_url') . $url . '@cache@refresh';
break;
default:
return false;
//break;
}
2 years ago
2 years ago
$content = GET_HTTP($url);
if ($content === false) {
$data[] = array('name' => 'no', 'value' => sprintf($this->lang->line('update_cache_failed'), $url));
} else {
//手动更新的话接着更新CDN缓存
$msg = $this->lang->line('update_cache_success');
if ($this->input->post('updatecdn') == 1) {
$notice = $this->update_cdn();
if ($notice == 200) {
$msg .= $this->lang->line('update_cdn_success');
} else {
$msg .= $this->lang->line('update_cdn_failed') . '<br>' . $notice;
}
2 years ago
}
$data[] = array('name' => 'ok', 'value' => $msg, 'url' => $url);
}
//如果是外部调用就返回结果,内部就不返回了
if ($this->input->post('cache_url')) {
echo json_encode($data);
}
return $data;
}
//更新CDN缓存
public function update_cdn($static_html_url = false)
{
$flag = false; //false不更新true更新
$update_site = array('jp', 'ru'); //需要更新CDN的站点
//需要更新的url
$url = $static_html_url;
1 year ago
if (empty($url)) {
2 years ago
$url = $this->input->post('cache_url');
}
2 years ago
//如果传递进来的url是带有域名则对域名进行判断
$tempu = parse_url($url);
1 year ago
if (isset($tempu['host'])) {
$url = isset($tempu['path']) ? $tempu['path'] : '/';
2 years ago
$pad = $tempu['host'];
$flag = true;
} //如果传递进来的url没有域名则使用当前站点的信息进行判断
else {
$url = str_replace($this->config->item('site_url'), '', $url);
$pad = str_replace('http://', '', $this->config->item('site_url'));
if (in_array($this->config->item('site_code'), $update_site)) {
$flag = true;
}
2 years ago
}
2 years ago
//默认更新成功,如果不成功,则返回错误提示信息
$notice = 200;
if ($flag) {
$result = GET_HTTP('https://openapi.us.cdnetworks.com/purge/rest/doPurge?user=ycc@chinahighlights.com&pass=cXi2UbsTrw9Urv@&pad=' . $pad . '&type=item&path=' . $url . '&output=json');
$result = json_decode($result, true);
if ($result['resultCode'] != 200) {
$notice = $result['notice'] . $result['details'];
}
}
2 years ago
return $notice;
}
//获取产品信息,提供给用户选择进行绑定
public function get_products()
{
$HT_productType = $this->input->post('product_type');
$HT_productName = $this->input->post('product_name');
//产品类型
switch ($HT_productType) {
case 't':
$data['productList'] = $this->Landscape_model->search_list($HT_productName);
break;
default:
$data['productList'] = array();
break;
}
$data['product_type'] = $HT_productType;
$product_list_page = $this->load->view('bootstrap/information_select_product', $data, true);
$data = array();
$data[] = array('name' => 'ok', 'value' => $product_list_page);
echo json_encode($data);
return true;
}
//显示备份的内容
public function backup_content($log_id)
{
$data['log_info'] = $this->Logs_model->read($log_id);
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);
} else {
$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/information_backup_content');
$this->load->view('bootstrap/footer');
}
//保存自定义配置
public function save_meta()
{
$im_ic_id = $this->input->post('im_ic_id');
$im_key = $this->input->post('im_key');
$im_value = $this->input->post('im_value');
if ($im_ic_id && $im_key && $im_value !== false) {
$meta = $this->InfoMetas_model->get($im_ic_id, $im_key);
if ($meta === false) {
$this->InfoMetas_model->add($im_ic_id, $im_key, $im_value);
} else {
$this->InfoMetas_model->update($im_ic_id, $im_key, $im_value);
}
$data[] = array('name' => 'ok', 'value' => $this->lang->line('media_save_success'));
} else {
$data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
}
echo json_encode($data);
return true;
}
//保存自定义配置
public function delete_meta()
{
$im_ic_id = $this->input->post('im_ic_id');
$im_key = $this->input->post('im_key');
if ($im_ic_id && $im_key) {
$this->InfoMetas_model->delete($im_ic_id, $im_key);
$data[] = array('name' => 'ok', 'value' => $this->lang->line('media_delete_success'));
} else {
$data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
}
echo json_encode($data);
return true;
}
}