master
LMR 11 months ago
parent 70863b5191
commit e426e417de

@ -1,5 +1,5 @@
<?php
if (!defined('BASEPATH')) {
if (! defined('BASEPATH')) {
exit('No direct script access allowed');
}
@ -24,8 +24,8 @@ class infofix extends CI_Controller {
set_time_limit(0);
// json参数
$site = $this->input->get_post('site');
$keys = $this->input->get_post('keys');
$site = $this->input->get_post('site');
$keys = $this->input->get_post('keys');
$key_arr = explode(',', $keys);
// 容错
@ -34,7 +34,7 @@ class infofix extends CI_Controller {
empty($keys) ||
mb_stripos($keys, '/') === false
) {
echo json_encode(array());
echo json_encode([]);
return false;
}
@ -43,7 +43,7 @@ class infofix extends CI_Controller {
// 调整数据
foreach ($rs as $info) {
$key_with_content = array();
$key_with_content = [];
foreach ($key_arr as $key) {
// 链接
@ -53,11 +53,18 @@ class infofix extends CI_Controller {
$sub_url = explode('@@@', $sub_url);
}
// 图片
$sub_ic_photo = mb_stripos($info->ic_photo, $key) !== false ? $info->ic_photo : '';
if ($sub_ic_photo) {
$sub_ic_photo = str_replace($key, '@@@' . $key . '@@@', $sub_ic_photo);
$sub_ic_photo = explode('@@@', $sub_ic_photo);
}
$limitStr = 100;
// 信息内容
$pos_content = 0;
$pos_content = mb_stripos($info->ic_content, $key);
$sub_content = array();
$sub_content = [];
while ($pos_content) {
$_str = '[...' . mb_substr($info->ic_content, $pos_content - $limitStr, mb_strlen($key) + $limitStr * 2) . '...]';
$_str = str_replace($key, '@@@' . $key . '@@@', $_str);
@ -67,43 +74,44 @@ class infofix extends CI_Controller {
}
// amp_json
$sub_content2 = array();
if ($info->amp_json) {
$pos_content2 = 0;
$pos_content2 = mb_stripos($info->amp_json, $key);
while ($pos_content2) {
$_str = '[...' . mb_substr($info->amp_json, $pos_content2 - $limitStr, mb_strlen($key) + $limitStr * 2) . '...]';
$_str = str_replace($key, '@@@' . $key . '@@@', $_str);
$_str = explode('@@@', $_str);
array_push($sub_content2, $_str);
$pos_content2 = mb_stripos($info->amp_json, $key, $pos_content2 + mb_strlen($key));
}
}
$sub_content2 = [];
// if ($info->amp_json) {
// $pos_content2 = 0;
// $pos_content2 = mb_stripos($info->amp_json, $key);
// while ($pos_content2) {
// $_str = '[...' . mb_substr($info->amp_json, $pos_content2 - $limitStr, mb_strlen($key) + $limitStr * 2) . '...]';
// $_str = str_replace($key, '@@@' . $key . '@@@', $_str);
// $_str = explode('@@@', $_str);
// array_push($sub_content2, $_str);
// $pos_content2 = mb_stripos($info->amp_json, $key, $pos_content2 + mb_strlen($key));
// }
// }
// amp_body
$sub_content3 = array();
if ($info->amp_body) {
$pos_content3 = 0;
$pos_content3 = mb_stripos($info->amp_body, $key);
while ($pos_content3) {
$_str = '[...' . mb_substr($info->amp_body, $pos_content3 - $limitStr, mb_strlen($key) + $limitStr * 2) . '...]';
$_str = str_replace($key, '@@@' . $key . '@@@', $_str);
$_str = explode('@@@', $_str);
array_push($sub_content3, $_str);
$pos_content3 = mb_stripos($info->amp_body, $key, $pos_content3 + mb_strlen($key));
}
}
$sub_content3 = [];
// if ($info->amp_body) {
// $pos_content3 = 0;
// $pos_content3 = mb_stripos($info->amp_body, $key);
// while ($pos_content3) {
// $_str = '[...' . mb_substr($info->amp_body, $pos_content3 - $limitStr, mb_strlen($key) + $limitStr * 2) . '...]';
// $_str = str_replace($key, '@@@' . $key . '@@@', $_str);
// $_str = explode('@@@', $_str);
// array_push($sub_content3, $_str);
// $pos_content3 = mb_stripos($info->amp_body, $key, $pos_content3 + mb_strlen($key));
// }
// }
if ($sub_url != '' || count($sub_content) != 0 || count($sub_content2) != 0 || count($sub_content3) != 0) {
array_push(
$key_with_content,
array(
'key' => $key,
'sub_url' => $sub_url,
'sub_content' => $sub_content,
'sub_json' => $sub_content2,
'sub_body' => $sub_content3,
)
[
'key' => $key,
'sub_url' => $sub_url,
'sub_ic_photo' => $sub_ic_photo,
'sub_content' => $sub_content,
'sub_json' => $sub_content2,
'sub_body' => $sub_content3,
]
);
}
}
@ -120,8 +128,8 @@ class infofix extends CI_Controller {
*/
public function update_info_by_keys() {
// json参数
$site = $this->input->get_post('site');
$keys = $this->input->get_post('keys');
$site = $this->input->get_post('site');
$keys = $this->input->get_post('keys');
$keyArr = explode('@', $keys); // ic_id@oldurl@newurl@is_id
//sleep(2);
@ -138,15 +146,15 @@ class infofix extends CI_Controller {
mb_stripos($keys, '@@') !== false ||
mb_stripos($keys, '@ @') !== false
) {
echo json_encode(array('err' => '容错1'));
echo json_encode(['err' => '容错1']);
return false;
}
// 参数解析
$ic_id = $keyArr[0];
$ic_id = $keyArr[0];
$oldStr = $keyArr[1];
$newStr = $keyArr[2];
$is_id = $keyArr[3];
$is_id = $keyArr[3];
// 容错2
if (
@ -157,13 +165,13 @@ class infofix extends CI_Controller {
mb_stripos($newStr, '/') === false ||
mb_stripos($oldStr, '/') === false
) {
echo json_encode(array('err' => '容错2'));
echo json_encode(['err' => '容错2']);
return false;
}
// ic_content
$ic = $this->infoContents_model->get_ic_contents2($ic_id);
if (!empty($ic)) {
if (! empty($ic)) {
$ic->ic_content = str_ireplace($oldStr, $newStr, $ic->ic_content);
$this->infoContents_model->force_update($ic_id, $ic->ic_content);
$ic->ic_url = str_ireplace($oldStr, $newStr, $ic->ic_url);
@ -172,14 +180,14 @@ class infofix extends CI_Controller {
// amp_json
$meta = $this->infoMetas_model->get($ic_id, 'AMP_JSON');
if (!empty($meta)) {
if (! empty($meta)) {
$meta = str_ireplace($oldStr, $newStr, $meta);
$this->infoMetas_model->update($ic_id, 'AMP_JSON', $meta);
}
// amp_body_pc
$meta = $this->infoMetas_model->get($ic_id, 'AMP_BODY_PC');
if (!empty($meta)) {
if (! empty($meta)) {
$meta = str_ireplace($oldStr, $newStr, $meta);
$this->infoMetas_model->update($ic_id, 'AMP_BODY_PC', $meta);
}
@ -193,26 +201,26 @@ class infofix extends CI_Controller {
* @param mixed $ic_id
*/
public function get_by_icid($ic_id) {
$ic = $this->infoContents_model->get_ic_contents2($ic_id);
$ic = $this->infoContents_model->get_ic_contents2($ic_id);
$json = json_decode($this->infoMetas_model->get($ic_id, 'AMP_JSON'));
$use = $this->infoMetas_model->get($ic_id, 'AMP_BODY_PC_STATUS');
$use = $this->infoMetas_model->get($ic_id, 'AMP_BODY_PC_STATUS');
if ($ic) {
echo json_encode(
array(
'state' => 0,
'ic_url' => $ic->ic_url,
[
'state' => 0,
'ic_url' => $ic->ic_url,
'ic_sitecode' => $ic->ic_sitecode,
'ic_content' => $ic->ic_content,
'pc_use' => $use,
'json' => array(), //$json,
)
'ic_content' => $ic->ic_content,
'pc_use' => $use,
'json' => [], //$json,
]
);
} else {
echo json_encode(
array(
[
'state' => -1,
'msg' => 'not content by ' . $ic_id,
)
'msg' => 'not content by ' . $ic_id,
]
);
}
}
@ -221,9 +229,9 @@ class infofix extends CI_Controller {
* 无条件更新信息内容(上线前内容)
*/
public function update_by_icid() {
$ic_id = $this->input->get_post('ic_id');
$ic_id = $this->input->get_post('ic_id');
$ic_content = $this->input->get_post('ic_content');
$backup = $this->input->get_post('backup');
$backup = $this->input->get_post('backup');
// 先备份 - 测试时不备份
if ($backup == 'backup') {
@ -233,7 +241,7 @@ class infofix extends CI_Controller {
}
$rs = $this->infoContents_model->force_update($ic_id, $ic_content);
echo json_encode(array('status' => 1));
echo json_encode(['status' => 1]);
}
/**
@ -241,12 +249,12 @@ class infofix extends CI_Controller {
*/
public function isid_by_icid2() {
$ic_id = $this->input->get_post('ic_id');
$is = $this->infoContents_model->get_isid_by_icid($ic_id);
$is = $this->infoContents_model->get_isid_by_icid($ic_id);
if (isset($is->is_id)) {
echo json_encode(array('status' => 1, 'isid' => $is->is_id));
echo json_encode(['status' => 1, 'isid' => $is->is_id]);
} else {
echo json_encode(array('status' => 0, 'isid' => $is->$ic_id));
echo json_encode(['status' => 0, 'isid' => $is->$ic_id]);
}
}
@ -256,16 +264,16 @@ class infofix extends CI_Controller {
*/
public function list_use_hb() {
$site = $this->input->get('site');
$api = $this->input->get('api');
$rs = $this->infoContents_model->list_use_hb($site);
$api = $this->input->get('api');
$rs = $this->infoContents_model->list_use_hb($site);
if ($api) {
$_rs = array();
$_rs = [];
foreach ($rs as $value) {
array_push($_rs, array(
'id' => $value->ic_id,
'data' => $value->ic_url,
array_push($_rs, [
'id' => $value->ic_id,
'data' => $value->ic_url,
'status' => 0,
));
]);
}
$rs = $_rs;
}
@ -287,10 +295,10 @@ class infofix extends CI_Controller {
// 请求api
$json = $this->infoMetas_model->get($ic_id, 'AMP_JSON');
if (!empty($json)) {
if (! empty($json)) {
// 请求转化服务器
$post_data = 'json=' . urlencode($json);
$ch = curl_init();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
@ -298,7 +306,7 @@ class infofix extends CI_Controller {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$curl_rs = curl_exec($ch);
$curl_rs = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($curl_rs && ($httpCode == 200 || $httpCode == 201)) {
// 先备份 - 测试时不备份
@ -308,7 +316,7 @@ class infofix extends CI_Controller {
$this->logs_model->backup($is->is_id, $ic->ic_content);
}
// 移除外部包裹标签
$curl_rs = str_replace(array('<my_lmr_tpl>', '</my_lmr_tpl>'), '', $curl_rs);
$curl_rs = str_replace(['<my_lmr_tpl>', '</my_lmr_tpl>'], '', $curl_rs);
//cdn域名替换res
$curl_rs = str_replace('//cdn.chinahighlights.ru', '//res.chinahighlights.ru', $curl_rs);
$curl_rs = str_replace('//cdn.arachina.com', '//res.arachina.com', $curl_rs);
@ -319,12 +327,12 @@ class infofix extends CI_Controller {
// 强制更新信息内容
$this->infoContents_model->force_update($ic_id, $curl_rs);
echo json_encode(array('status' => 1));
echo json_encode(['status' => 1]);
} else {
echo json_encode(array('status' => -1, 'msg' => 'err1'));
echo json_encode(['status' => -1, 'msg' => 'err1']);
}
} else {
echo json_encode(array('status' => -1, 'msg' => 'err2'));
echo json_encode(['status' => -1, 'msg' => 'err2']);
}
}

@ -1,73 +1,67 @@
<?php
class Information_model extends CI_Model
{
var $topNum = false;
var $orderBy = false;
var $search_title = false;
var $search_url = false;
var $search = false;
var $path = false;
var $level = false;
var $is_parent_id = false;
var $is_id_array = false;
var $ic_url_is_id = false;
class Information_model extends CI_Model {
var $topNum = false;
var $orderBy = false;
var $search_title = false;
var $search_url = false;
var $search = false;
var $path = false;
var $level = false;
var $is_parent_id = false;
var $is_id_array = false;
var $ic_url_is_id = false;
var $ic_ht_area_type = false;
var $ic_ht_area_id = false;
var $ic_type = false;
var $ic_id = false;
var $ic_ht_area_id = false;
var $ic_type = false;
var $ic_id = false;
function __construct()
{
function __construct() {
parent::__construct();
$this->HT = $this->load->database('INFORMATION', TRUE);
$this->HT = $this->load->database('INFORMATION', TRUE);
$this->HT229 = $this->load->database('HT', TRUE);
}
function init()
{
$this->topNum = false;
$this->orderBy = " ORDER BY ic_datetime DESC ";
$this->search_title = false;
$this->search_url = false;
$this->search = false;
$this->path = false;
$this->level = false;
$this->is_parent_id = false;
$this->is_id_array = false;
$this->ic_url_is_id = false;
function init() {
$this->topNum = false;
$this->orderBy = " ORDER BY ic_datetime DESC ";
$this->search_title = false;
$this->search_url = false;
$this->search = false;
$this->path = false;
$this->level = false;
$this->is_parent_id = false;
$this->is_id_array = false;
$this->ic_url_is_id = false;
$this->ic_ht_area_type = false;
$this->ic_ht_area_id = false;
$this->ic_id = false;
$this->ic_ht_area_id = false;
$this->ic_id = false;
}
function get_last_edit_list($topNum = 24)
{
function get_last_edit_list($topNum = 24) {
$this->init();
$this->topNum = $topNum;
return $this->GetList();
}
function search($keyword)
{
function search($keyword) {
$this->init();
$this->topNum = 48;
if (is_numeric($keyword)) {
$this->search_title = "AND ic_id=" . $this->HT->escape($keyword);
} else {
$sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%';
$sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%';
$this->search_title = "AND (ic_url_title like N'$sql_keyword' OR ic_title like N'$sql_keyword' )";
}
return $this->GetList();
}
function search_all_text($keyword, $topnum = 24)
{
function search_all_text($keyword, $topnum = 24) {
$this->init();
$this->topNum = $topnum;
$sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%';
$this->search = " AND (ic_content like N'$sql_keyword'
$sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%';
$this->search = " AND (ic_content like N'$sql_keyword'
or ic.ic_photo like N'$sql_keyword'
or map.im_value like N'$sql_keyword'
or mapm.im_value like N'$sql_keyword')";
@ -75,39 +69,36 @@ class Information_model extends CI_Model
}
//根据关键词来搜索内容
function search_by_words($url, array $words, $exclude_ids)
{
function search_by_words($url, array $words, $exclude_ids) {
$this->init();
$this->topNum = 1;
$sql_keyword = ' AND ( 1=1 ';
$sql_keyword = ' AND ( 1=1 ';
foreach ($words as $item) {
$sql_keyword .= " AND ic_title like '%" . $this->HT->escape_like_str(trim($item)) . "%' ";
}
$sql_keyword .= ' ) ';
$this->search = " AND ic_status=1 AND ic_url LIKE '$url%' " . $sql_keyword . ' AND is_id NOT IN(' . implode(',', $exclude_ids) . ',0)';
$this->search = " AND ic_status=1 AND ic_url LIKE '$url%' " . $sql_keyword . ' AND is_id NOT IN(' . implode(',', $exclude_ids) . ',0)';
$this->orderBy = " ORDER BY is1.is_level ASC, is1.is_sort ASC,ic_datetime DESC ";
return $this->GetList('ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status,ic.ic_photo');
}
//在当前节点下搜索关键词
function search_by_words_2($path, array $words, $exclude_ids)
{
function search_by_words_2($path, array $words, $exclude_ids) {
$this->init();
$this->topNum = 1;
$sql_keyword = ' AND ( 1=1 ';
$sql_keyword = ' AND ( 1=1 ';
foreach ($words as $item) {
$sql_keyword .= " AND ic_title like '%" . $this->HT->escape_like_str(trim($item)) . "%' ";
}
$sql_keyword .= ' ) ';
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->search = ' AND ic_status=1 AND is_id NOT IN(' . implode(',', $exclude_ids) . ',0) ' . $sql_keyword;
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->search = ' AND ic_status=1 AND is_id NOT IN(' . implode(',', $exclude_ids) . ',0) ' . $sql_keyword;
$this->orderBy = " ORDER BY is1.is_level ASC, is1.is_sort ASC,ic_datetime DESC ";
return $this->GetList('ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status,ic.ic_photo');
}
//在同级别下随机获取N条数据并且排除某些id
function random($topnum, $is_path, array $exclude_ids)
{
function random($topnum, $is_path, array $exclude_ids) {
$this->init();
$this->topNum = $topnum;
$this->search = " AND is1.is_path LIKE '$is_path%' ";
@ -119,8 +110,7 @@ class Information_model extends CI_Model
}
//在urls列表里面随机获取N条数据并且排除某些id
function random_range($topnum, array $url_array, array $exclude_ids)
{
function random_range($topnum, array $url_array, array $exclude_ids) {
$this->init();
$this->topNum = $topnum;
$this->search = ' AND ( 1=2 ';
@ -135,34 +125,31 @@ class Information_model extends CI_Model
}
//根据url搜索信息
function search_url($url)
{
function search_url($url) {
$this->init();
$this->topNum = 24;
$this->topNum = 24;
$this->search_url = ' AND ic_url= ' . $this->HT->escape($url);
return $this->GetList();
}
//根据根节点路径获取子节点列表
function get_list_by_path($path, $level = false, $site_code = false, $filed = false)
{
function get_list_by_path($path, $level = false, $site_code = false, $filed = false) {
$this->init();
if ($level !== false) {
$this->level = " AND is1.is_level= '$level' ";
}
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
return $this->GetList($filed, $site_code);
}
//根据根节点路径获取子节点列表
function get_list_by_path_gm($path, $level = false, $site_code = false, $filed = false)
{
function get_list_by_path_gm($path, $level = false, $site_code = false, $filed = false) {
$this->init();
if ($level !== false) {
$this->level = " AND is1.is_level= '$level' ";
}
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
return $this->GetList_gm($filed, $site_code);
}
@ -170,64 +157,63 @@ class Information_model extends CI_Model
/**
* 获取当前页面的面包屑,不包括当前节点
*/
function get_path_exclude_self($is_id, $path)
{
$site_code = $this->config->item('site_code');
$path_query = $this->HT->query("select
function get_path_exclude_self($is_id, $path) {
$site_code = $this->config->item('site_code');
$path_query = $this->HT->query("select
ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status
from infoStructures a inner join infoContents b on a.is_ic_id=b.ic_id
where is_id in ($path 0) and is_id <> ? and is_siteCode = ? order by is_level asc", array($is_id, $site_code));
from infoStructures a inner join infoContents b on a.is_ic_id=b.ic_id
where is_id in ($path 0) and is_id <> ? and is_siteCode = ? order by is_level asc", [$is_id, $site_code]);
$path_result = $path_query->result();
$path_list = [];
$path_list = [];
$group_map = [
278008010 => [
'ic_url' => '/travelguide/culture/',
'ic_url_title' => 'Chinese Culture'
'ic_url' => '/travelguide/culture/',
'ic_url_title' => 'Chinese Culture',
],
278008011 => [
'ic_url' => '/travelguide/',
'ic_url_title' => 'Travel Guide'
'ic_url' => '/travelguide/',
'ic_url_title' => 'Travel Guide',
],
278008012 => [
'ic_url' => '/aboutus/',
'ic_url_title' => 'About Us'
'ic_url' => '/aboutus/',
'ic_url_title' => 'About Us',
],
278008013 => [
'ic_url' => '/citytour/',
'ic_url_title' => 'City Tours'
'ic_url' => '/citytour/',
'ic_url_title' => 'City Tours',
],
278008014 => [
'ic_url' => '/tour/',
'ic_url_title' => 'China Tours'
]
'ic_url' => '/tour/',
'ic_url_title' => 'China Tours',
],
];
foreach ($path_result as $path_row) {
$ic_url = $path_row->ic_url;
$ic_url = $path_row->ic_url;
$ic_url_title = $path_row->ic_url_title;
if ($path_row->is_level === 0) {
if (array_key_exists($path_row->is_id, $group_map)) {
$top_group = $group_map[$path_row->is_id];
$top_group = $group_map[$path_row->is_id];
$path_array = [
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $top_group['ic_url'],
'ic_url_title' => $top_group['ic_url_title']
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $top_group['ic_url'],
'ic_url_title' => $top_group['ic_url_title'],
];
$path_list[] = $path_array;
}
} else if ($path_row->ic_status === 1) {
$path_array = [
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $path_row->ic_url,
'ic_url_title' => $path_row->ic_url_title
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $path_row->ic_url,
'ic_url_title' => $path_row->ic_url_title,
];
$path_list[] = $path_array;
}
@ -239,40 +225,39 @@ class Information_model extends CI_Model
/**
* 获取当前页面的面包屑,不包括当前节点
*/
function get_breadcrumb_data($is_id, $path, $group_map)
{
$path_query = $this->HT->query("select
function get_breadcrumb_data($is_id, $path, $group_map) {
$path_query = $this->HT->query("select
ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status
from infoStructures a inner join infoContents b on a.is_ic_id=b.ic_id
where is_id in ($path 0) and is_id <> ? order by is_level asc", array($is_id));
from infoStructures a inner join infoContents b on a.is_ic_id=b.ic_id
where is_id in ($path 0) and is_id <> ? order by is_level asc", [$is_id]);
$path_result = $path_query->result();
$path_list = [];
$path_list = [];
foreach ($path_result as $path_row) {
$ic_url = $path_row->ic_url;
$ic_url = $path_row->ic_url;
$ic_url_title = $path_row->ic_url_title;
if ($path_row->is_level === 0) {
if (array_key_exists($path_row->is_id, $group_map)) {
$top_group = $group_map[$path_row->is_id];
$top_group = $group_map[$path_row->is_id];
$path_array = [
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $top_group['ic_url'],
'ic_url_title' => $top_group['ic_url_title']
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $top_group['ic_url'],
'ic_url_title' => $top_group['ic_url_title'],
];
$path_list[] = $path_array;
}
} else if ($path_row->ic_status === 1) {
$path_array = [
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $path_row->ic_url,
'ic_url_title' => $path_row->ic_url_title
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $path_row->ic_url,
'ic_url_title' => $path_row->ic_url_title,
];
$path_list[] = $path_array;
}
@ -282,39 +267,34 @@ class Information_model extends CI_Model
}
//根据路径获取某一级别节点详细页
function get_detail_by_path($path, $level)
{
function get_detail_by_path($path, $level) {
$this->init();
$this->topNum = 1;
$this->level = " AND is1.is_level= '$level' ";
$this->topNum = 1;
$this->level = " AND is1.is_level= '$level' ";
$this->is_id_array = " AND is1.is_id IN ($path 0) ";
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
return $this->GetList();
}
//根据节点ID列表获取信息
function get_detail_by_ids($is_ids)
{
function get_detail_by_ids($is_ids) {
$this->init();
$this->is_id_array = " AND is1.is_id IN ($is_ids) ";
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
return $this->GetList();
}
//根据根节点ID获取子节点列表
function get_list_by_id($is_parent_id, $level = false)
{
function get_list_by_id($is_parent_id, $level = false) {
$this->init();
if ($level !== false) {
$this->level = " AND is1.is_level= '$level' ";
}
$this->is_parent_id = " AND is1.is_parent_id = '$is_parent_id' ";
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
return $this->GetList('is1.is_id, ic.ic_id, ic.ic_url, ic.ic_url_title, ic.ic_title, ic.ic_datetime, ic.ic_author');
}
function Detail($ic_url_is_id, $filed = '', $site_code = '')
{
function Detail($ic_url_is_id, $filed = '', $site_code = '') {
if (empty($ic_url_is_id)) {
return false;
}
@ -328,19 +308,17 @@ class Information_model extends CI_Model
return $this->GetList($filed, $site_code);
}
function detail_by_ic_id($ic_id)
{
function detail_by_ic_id($ic_id) {
if (empty($ic_id)) {
return false;
}
$this->init();
$this->topNum = 1;
$this->topNum = 1;
$this->ic_url_is_id = " AND ic.ic_id = " . $this->HT->escape($ic_id);
return $this->GetList();
}
function GetList($filed = "", $site_code = "")
{
function GetList($filed = "", $site_code = "") {
$this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT ";
if (empty($filed)) {
$sql .= " is1.is_id, \n"
@ -405,7 +383,7 @@ class Information_model extends CI_Model
$this->orderBy ? $sql .= $this->orderBy : false;
$query = $this->HT->query($sql, array($site_code ? $site_code : $this->config->item('site_code')));
$query = $this->HT->query($sql, [$site_code ? $site_code : $this->config->item('site_code')]);
//print_r($this->HT->queries);
if ($this->topNum === 1) {
if ($query->num_rows() > 0) {
@ -419,8 +397,7 @@ class Information_model extends CI_Model
}
}
function GetList_gm($filed = "", $site_code = "")
{
function GetList_gm($filed = "", $site_code = "") {
$this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT ";
if (empty($filed)) {
$sql .= " is1.is_id, \n"
@ -485,7 +462,7 @@ class Information_model extends CI_Model
$this->orderBy ? $sql .= $this->orderBy : false;
$query = $this->HT->query($sql, array($site_code ? $site_code : $this->config->item('site_code')));
$query = $this->HT->query($sql, [$site_code ? $site_code : $this->config->item('site_code')]);
//print_r($this->HT->queries);
if ($this->topNum === 1) {
if ($query->num_rows() > 0) {
@ -500,8 +477,7 @@ class Information_model extends CI_Model
}
//根据区域信息获取根节点
function GetRoot($ic_ht_area_type, $ic_ht_area_id)
{
function GetRoot($ic_ht_area_type, $ic_ht_area_id) {
$sql = "SELECT TOP 1 is1.is_id, \n"
. " is1.is_parent_id, \n"
. " is1.is_path, \n"
@ -517,7 +493,7 @@ class Information_model extends CI_Model
. " is1.is_level ASC, \n"
. " is1.is_sort ASC, \n"
. " is1.is_path ASC \n";
$query = $this->HT->query($sql, array($this->config->item('site_code'), $ic_ht_area_type, $ic_ht_area_id));
$query = $this->HT->query($sql, [$this->config->item('site_code'), $ic_ht_area_type, $ic_ht_area_id]);
if ($query->result()) {
$row = $query->row();
return $row;
@ -527,16 +503,15 @@ class Information_model extends CI_Model
}
//根据信息树id获取省份代号
public function get_province_by_isid($is_id)
{
$sql = " SELECT top 1 CII_PRI_SN
FROM infoStructures is1
INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id
public function get_province_by_isid($is_id) {
$sql = " SELECT top 1 CII_PRI_SN
FROM infoStructures is1
INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id
INNER JOIN CItyInfo ON ic.ic_ht_area_id=CII_SN
WHERE is1.is_id=?";
$query = $this->HT->query($sql, array($is_id));
$query = $this->HT->query($sql, [$is_id]);
$result = $query->result();
if (!empty($result)) {
if (! empty($result)) {
return $result[0]->CII_PRI_SN;
} else {
return false;
@ -544,8 +519,7 @@ class Information_model extends CI_Model
}
//获取结构列表
function StructureList($is_id)
{
function StructureList($is_id) {
$sql = "SELECT is1.is_id AS id, \n"
. " is1.is_parent_id AS pId, \n"
. " ISNULL(ic.ic_url_title,'New Information') AS name , \n"
@ -560,21 +534,20 @@ class Information_model extends CI_Model
. " is1.is_level ASC, \n"
. " is1.is_sort ASC, \n"
. " is1.is_path ASC \n";
$query = $this->HT->query($sql, array($is_id));
$query = $this->HT->query($sql, [$is_id]);
//print_r($this->HT->queries);
return $query->result();
}
//检测链接是否重复
function URLcheck($is_id, $ic_url)
{
function URLcheck($is_id, $ic_url) {
$sql = "SELECT TOP 1 is1.is_id \n"
. "FROM infoStructures is1 \n"
. " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
. "WHERE is1.is_id <> ? \n "
. " AND ic.ic_url = ? \n"
. " AND ic.ic_sitecode=? ";
$query = $this->HT->query($sql, array($is_id, $ic_url, $this->config->item('site_code')));
$query = $this->HT->query($sql, [$is_id, $ic_url, $this->config->item('site_code')]);
//print_r($this->HT->queries);
if ($query->num_rows() > 0) {
return false;
@ -584,8 +557,7 @@ class Information_model extends CI_Model
}
//获取没有绑定的景点列表
function get_unlink_landscape_list($city_id)
{
function get_unlink_landscape_list($city_id) {
$sql = "SELECT TOP 8 lsi.LSI_SN, \n"
. " lsi.LSI_City, \n"
. " lsi2.LSI2_Name, \n"
@ -606,44 +578,41 @@ class Information_model extends CI_Model
. " ) \n"
. "ORDER BY \n"
. " lsi2.LSI2_SN DESC";
$query = $this->HT229->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'), $city_id));
$query = $this->HT229->query($sql, [$this->config->item('site_lgc'), $this->config->item('site_lgc'), $city_id]);
return $query->result();
}
//获取根节点列表
function root_type_list()
{
function root_type_list() {
$this->init();
$this->orderBy = " ORDER BY ic.ic_url_title ASC ";
$this->level = " AND is1.is_level=1 ";
$this->orderBy = " ORDER BY ic.ic_url_title ASC ";
$this->level = " AND is1.is_level=1 ";
$this->is_parent_id = " AND is1.is_parent_id=0 ";
$this->ic_type = " AND ic.ic_type='root' ";
$this->ic_type = " AND ic.ic_type='root' ";
return $this->GetList();
}
//获取某个信息类型详情
function get_type_detail($type_name, $area_type, $area_id)
{
function get_type_detail($type_name, $area_type, $area_id) {
$this->init();
$this->topNum = 1;
$this->orderBy = " ORDER BY is1.is_level ASC ";
$this->topNum = 1;
$this->orderBy = " ORDER BY is1.is_level ASC ";
$this->ic_ht_area_type = " AND ic.ic_ht_area_type= " . $this->HT->escape($area_type);
$this->ic_ht_area_id = " AND ic.ic_ht_area_id=" . $this->HT->escape($area_id);
$this->ic_type = " AND ic.ic_type= " . $this->HT->escape($type_name);
$this->ic_ht_area_id = " AND ic.ic_ht_area_id=" . $this->HT->escape($area_id);
$this->ic_type = " AND ic.ic_type= " . $this->HT->escape($type_name);
return $this->GetList();
}
//获取3年未更新的信息
function get_oldest_info($yeardiff = 3, $has_no_pub = true, $empty_info = true)
{
$has_no_pub ? $sql_no_pub = '' : $sql_no_pub = "AND ic_status = 1";
function get_oldest_info($yeardiff = 3, $has_no_pub = true, $empty_info = true) {
$has_no_pub ? $sql_no_pub = '' : $sql_no_pub = "AND ic_status = 1";
$empty_info ? $sql_empty_info = '' : $sql_empty_info = "AND datalength(ic_content) > 0";
//sql
$sql = "SELECT
$sql = "SELECT
ic_id,
ic_url,
ic_sitecode,
ic_title,
ic_title,
ic_url_title,
ic_datetime,
ic_type,
@ -654,21 +623,19 @@ class Information_model extends CI_Model
FROM infoContents
LEFT JOIN infoStructures ON ic_id = is_ic_id
WHERE YEAR(GETDATE()) - YEAR(ic_datetime) >= ?
AND ic_sitecode = ?
AND ic_sitecode = ?
" . $sql_no_pub . "
" . $sql_empty_info . "
AND ic_url <> ''
ORDER BY ic_datetime desc";
$query = $this->HT->query($sql, array($yeardiff, $this->config->item('site_code')));
$query = $this->HT->query($sql, [$yeardiff, $this->config->item('site_code')]);
return $query->result();
}
//ct
function ct_get_by_url($ic_url, $webcode)
{
function ct_get_by_url($ic_url, $webcode) {
$this->ic_url_is_id = " AND ic.ic_url = N" . $this->HT->escape($ic_url);
$sql = "SELECT is1.is_id, \n"
$sql = "SELECT is1.is_id, \n"
. " is1.is_parent_id, \n"
. " is1.is_path, \n"
. " is1.is_level, \n"
@ -713,10 +680,9 @@ class Information_model extends CI_Model
}
//获取分组列表
function group_list()
{
function group_list() {
$this->init();
$this->search = ' AND is_level<=1 ';
$this->search = ' AND is_level<=1 ';
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,ic.ic_title ASC,is1.is_path ASC ';
return $this->GetList();
}
@ -724,58 +690,57 @@ class Information_model extends CI_Model
/**
* CT 获取当前页面的面包屑,不包括当前节点,去除链接为空及不发布的节点
*/
function get_path_exclude_ct($is_id, $path)
{
$site_code = $this->config->item('site_code');
$path_query = $this->HT->query("select
function get_path_exclude_ct($is_id, $path) {
$site_code = $this->config->item('site_code');
$path_query = $this->HT->query("select
ic_id, is_id, ic_url,ic_url_title,ic_title,is_path,is_level,ic_status
from infoStructures a inner join infoContents b on a.is_ic_id=b.ic_id
where is_id in ($path 0) and is_id <> ? and is_siteCode = ? order by is_level asc", array($is_id, $site_code));
from infoStructures a inner join infoContents b on a.is_ic_id=b.ic_id
where is_id in ($path 0) and is_id <> ? and is_siteCode = ? order by is_level asc", [$is_id, $site_code]);
$path_result = $path_query->result();
$path_list = [];
$path_list = [];
$group_map = [
278013869 => [
'ic_url' => '/tour',
'ic_url_title' => 'China Tours'
'ic_url' => '/tour',
'ic_url_title' => 'China Tours',
],
278014282 => [
'ic_url' => '/citytour',
'ic_url_title' => 'China City Tours'
'ic_url' => '/citytour',
'ic_url_title' => 'China City Tours',
],
278013862 => [
'ic_url' => '/daytrip',
'ic_url_title' => 'China Day Trip'
'ic_url' => '/daytrip',
'ic_url_title' => 'China Day Trip',
],
278014609 => [
'ic_url' => '/china-trains',
'ic_url_title' => 'China Trains'
'ic_url' => '/china-trains',
'ic_url_title' => 'China Trains',
],
278014608 => [
'ic_url' => '/china-flights',
'ic_url_title' => 'China Flights'
]
'ic_url' => '/china-flights',
'ic_url_title' => 'China Flights',
],
];
foreach ($path_result as $path_row) {
if (array_key_exists($path_row->is_id, $group_map)) {
$top_group = $group_map[$path_row->is_id];
$top_group = $group_map[$path_row->is_id];
$path_array = [
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $top_group['ic_url'],
'ic_url_title' => $top_group['ic_url_title']
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $top_group['ic_url'],
'ic_url_title' => $top_group['ic_url_title'],
];
$path_list[] = $path_array;
} else if ($path_row->ic_status === 1) {
$path_array = [
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $path_row->ic_url,
'ic_url_title' => $path_row->ic_url_title
'ic_id' => $path_row->ic_id,
'is_id' => $path_row->is_id,
'ic_title' => $path_row->ic_title,
'ic_url' => $path_row->ic_url,
'ic_url_title' => $path_row->ic_url_title,
];
$path_list[] = $path_array;
}
@ -787,8 +752,7 @@ class Information_model extends CI_Model
/**
* intl 根据keywords获取信息。
*/
function list_by_keywords($site, $keywords)
{
function list_by_keywords($site, $keywords) {
$this->init();
$keysql = '';
foreach ($keywords as $key) {
@ -798,8 +762,8 @@ class Information_model extends CI_Model
$keysql .= ' OR m2.im_value like \'%' . $key . '%\'';
}
$search = ' AND (1=0 ' . $keysql . ')';
$sql = "
SELECT is_id, ic_id, ic_url, ic_content, m1.im_value AS amp_json, m2.im_value AS amp_body
$sql = "
SELECT is_id, ic_id, ic_url, ic_content, ic_photo, m1.im_value AS amp_json, m2.im_value AS amp_body
FROM infoStructures is1
INNER JOIN infoContents ic
ON ic.ic_id = is1.is_ic_id
@ -816,7 +780,7 @@ class Information_model extends CI_Model
" . $search . "
ORDER BY ic_datetime DESC
";
$query = $this->HT->query($sql, array($site));
$query = $this->HT->query($sql, [$site]);
// print_r($this->HT->queries);
return $query->result();
}

Loading…
Cancel
Save