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.
430 lines
16 KiB
PHP
430 lines
16 KiB
PHP
<?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;
|
|
var $ic_ht_area_type = false;
|
|
var $ic_ht_area_id = false;
|
|
var $ic_type = false;
|
|
var $ic_id = false;
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->HT = $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;
|
|
$this->ic_ht_area_type = false;
|
|
$this->ic_ht_area_id = false;
|
|
$this->ic_id = false;
|
|
}
|
|
|
|
function get_last_edit_list($topNum = 24) {
|
|
$this->init();
|
|
$this->topNum = $topNum;
|
|
return $this->GetList();
|
|
}
|
|
|
|
function search($keyword) {
|
|
$this->init();
|
|
$this->topNum = 24;
|
|
if (is_numeric($keyword)) {
|
|
$this->search_title = "AND ic_id=" . $this->HT->escape($keyword);
|
|
} else {
|
|
$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) {
|
|
$this->init();
|
|
$this->topNum = $topnum;
|
|
$sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%';
|
|
$this->search = " AND ic_content like N'$sql_keyword' ";
|
|
return $this->GetList();
|
|
}
|
|
|
|
//根据url搜索信息
|
|
function search_url($url) {
|
|
$this->init();
|
|
$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) {
|
|
$this->init();
|
|
if ($level !== false) {
|
|
$this->level = " AND is1.is_level= '$level' ";
|
|
}
|
|
$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('', $site_code);
|
|
}
|
|
|
|
//根据路径获取某一级别节点详细页
|
|
function get_detail_by_path($path, $level) {
|
|
$this->init();
|
|
$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 ';
|
|
return $this->GetList();
|
|
}
|
|
//根据节点ID列表获取信息
|
|
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 ';
|
|
return $this->GetList();
|
|
}
|
|
|
|
//根据根节点ID获取子节点列表
|
|
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 ';
|
|
return $this->GetList();
|
|
}
|
|
|
|
|
|
function Detail($ic_url_is_id) {
|
|
if (empty($ic_url_is_id)) {
|
|
return false;
|
|
}
|
|
$this->init();
|
|
$this->topNum = 1;
|
|
if (is_numeric($ic_url_is_id)) {
|
|
$this->ic_url_is_id = " AND is1.is_id= " . $this->HT->escape($ic_url_is_id);
|
|
} else {
|
|
$this->ic_url_is_id = " AND ic.ic_url = " . $this->HT->escape($ic_url_is_id);
|
|
}
|
|
return $this->GetList();
|
|
}
|
|
|
|
function detail_by_ic_id($ic_id) {
|
|
if (empty($ic_id)) {
|
|
return false;
|
|
}
|
|
$this->init();
|
|
$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 = "") {
|
|
$this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT ";
|
|
if (empty($filed)) {
|
|
$sql .= " is1.is_id, \n"
|
|
. " is1.is_parent_id, \n"
|
|
. " is1.is_path, \n"
|
|
. " is1.is_level, \n"
|
|
. " is1.is_sort, \n"
|
|
. " is1.is_sitecode, \n"
|
|
. " is1.is_datetime, \n"
|
|
. " is1.is_ic_id, \n"
|
|
. " ic.ic_id, \n"
|
|
. " ic.ic_url, \n"
|
|
. " ic.ic_url_title, \n"
|
|
. " ic.ic_type, \n"
|
|
. " ic.ic_title, \n"
|
|
. " ic.ic_content, \n"
|
|
. " ic.ic_summary, \n"
|
|
. " ic.ic_seo_title, \n"
|
|
. " ic.ic_seo_description, \n"
|
|
. " ic.ic_seo_keywords, \n"
|
|
. " ic.ic_show_bread_crumbs, \n"
|
|
. " ic.ic_status, \n"
|
|
. " ic.ic_template, \n"
|
|
. " ic.ic_photo, \n"
|
|
. " ic.ic_photo_width, \n"
|
|
. " ic.ic_photo_height, \n"
|
|
. " ic.ic_sitecode, \n"
|
|
. " ic.ic_recommend_tours, \n"
|
|
. " ic.ic_recommend_packages, \n"
|
|
. " ic.ic_datetime, \n"
|
|
. " ic.ic_ht_area_id, \n"
|
|
. " ic.ic_ht_area_type, \n"
|
|
. " ic.ic_ht_product_id, \n"
|
|
. " ic.ic_ht_product_type, \n"
|
|
. " ic.SRMS_SIC_Code, \n"
|
|
. " ic.SRMS_SIIT_Code, \n"
|
|
. " ic.ic_author \n";
|
|
} else {
|
|
$sql.=" $filed ";
|
|
}
|
|
//添加查询AMP发布状态
|
|
$sql.=",isnull((select top 1 CONVERT(varchar, im_value) from infoMetas where im_ic_id=ic_id and im_key='AMP_STATUS'),0) as amp_status ";
|
|
$sql.="FROM infoStructures is1 \n"
|
|
. " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
|
|
. " AND ic.ic_sitecode = is1.is_sitecode \n"
|
|
. "WHERE is1.is_sitecode = ? ";
|
|
$this->search_title ? $sql.=$this->search_title : false;
|
|
$this->search_url ? $sql.=$this->search_url : false;
|
|
$this->search ? $sql.=$this->search : false;
|
|
$this->path ? $sql.=$this->path : false;
|
|
$this->level ? $sql.=$this->level : false;
|
|
$this->is_parent_id ? $sql.=$this->is_parent_id : false;
|
|
$this->is_id_array ? $sql.=$this->is_id_array : false;
|
|
$this->ic_url_is_id ? $sql.=$this->ic_url_is_id : false;
|
|
$this->ic_id ? $sql.=$this->ic_id : false;
|
|
$this->ic_type ? $sql.=$this->ic_type : false;
|
|
$this->ic_ht_area_type ? $sql.=$this->ic_ht_area_type : false;
|
|
$this->ic_ht_area_id ? $sql.=$this->ic_ht_area_id : false;
|
|
|
|
$this->orderBy ? $sql.=$this->orderBy : false;
|
|
|
|
$query = $this->HT->query($sql, array($site_code ? $site_code : $this->config->item('site_code')));
|
|
//print_r($this->HT->queries);
|
|
if ($this->topNum === 1) {
|
|
if ($query->num_rows() > 0) {
|
|
$row = $query->row();
|
|
return $row;
|
|
} else {
|
|
return FALSE;
|
|
}
|
|
} else {
|
|
return $query->result();
|
|
}
|
|
}
|
|
|
|
//根据区域信息获取根节点
|
|
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"
|
|
. " is1.is_level, \n"
|
|
. " ic.ic_url_title \n"
|
|
. "FROM infoStructures is1 \n"
|
|
. " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
|
|
. " AND ic.ic_sitecode = is1.is_sitecode \n"
|
|
. "WHERE is1.is_sitecode = ? \n"
|
|
. " AND ic.ic_ht_area_type = ? \n"
|
|
. " AND ic.ic_ht_area_id = ? \n"
|
|
. "ORDER BY \n"
|
|
. " 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));
|
|
if ($query->result()) {
|
|
$row = $query->row();
|
|
return $row;
|
|
} else {
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
//根据信息树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));
|
|
$result = $query->result();
|
|
if (!empty($result)) {
|
|
return $result[0]->CII_PRI_SN;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//获取结构列表
|
|
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"
|
|
. " ISNULL(ic.ic_status,0) AS status, \n"
|
|
. " is1.is_path, \n"
|
|
. " 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"
|
|
. " OR ',' + is1.is_path LIKE '%,$is_id,%' \n"
|
|
. "ORDER BY \n"
|
|
. " is1.is_level ASC, \n"
|
|
. " is1.is_sort ASC, \n"
|
|
. " is1.is_path ASC \n";
|
|
$query = $this->HT->query($sql, array($is_id));
|
|
//print_r($this->HT->queries);
|
|
return $query->result();
|
|
}
|
|
|
|
//检测链接是否重复
|
|
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')));
|
|
//print_r($this->HT->queries);
|
|
if ($query->num_rows() > 0) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//获取没有绑定的景点列表
|
|
function get_unlink_landscape_list($city_id) {
|
|
$sql = "SELECT TOP 8 lsi.LSI_SN, \n"
|
|
. " lsi.LSI_City, \n"
|
|
. " lsi2.LSI2_Name, \n"
|
|
. " ci2.CII2_Name \n"
|
|
. "FROM LandScapeInfo lsi \n"
|
|
. " INNER JOIN LandScapeInfo2 lsi2 ON lsi2.LSI2_LSI_SN = lsi.LSI_SN \n"
|
|
. " AND lsi2.LSI2_LGC = ? \n"
|
|
. " INNER JOIN CItyInfo2 ci2 ON ci2.CII2_CII_SN = lsi.LSI_City \n"
|
|
. " AND ci2.CII2_LGC = ? \n"
|
|
. "WHERE lsi.LSI_Publish = 1 \n"
|
|
. " AND (lsi.LSI_ParentSN IS NULL OR lsi.LSI_ParentSN = 0) \n"
|
|
. " AND lsi.LSI_City = ? \n"
|
|
. " AND NOT EXISTS( \n"
|
|
. " SELECT TOP 1 1 \n"
|
|
. " FROM infoContents ic \n"
|
|
. " WHERE ic.ic_ht_product_type = 't' \n"
|
|
. " AND ic.ic_ht_product_id = lsi.LSI_SN \n"
|
|
. " ) \n"
|
|
. "ORDER BY \n"
|
|
. " lsi2.LSI2_SN DESC";
|
|
$query = $this->HT->query($sql, array($this->config->item('site_lgc'), $this->config->item('site_lgc'), $city_id));
|
|
return $query->result();
|
|
}
|
|
|
|
//获取根节点列表
|
|
function root_type_list() {
|
|
$this->init();
|
|
$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' ";
|
|
return $this->GetList();
|
|
}
|
|
|
|
//获取某个信息类型详情
|
|
function get_type_detail($type_name, $area_type, $area_id) {
|
|
$this->init();
|
|
$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);
|
|
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";
|
|
$empty_info ? $sql_empty_info = '' : $sql_empty_info = "AND datalength(ic_content) > 0";
|
|
//sql
|
|
$sql = "SELECT
|
|
ic_id,
|
|
ic_url,
|
|
ic_sitecode,
|
|
ic_title,
|
|
ic_url_title,
|
|
ic_datetime,
|
|
ic_type,
|
|
ic_author,
|
|
ic_status,
|
|
ic_view,
|
|
is_id
|
|
FROM infoContents
|
|
LEFT JOIN infoStructures ON ic_id = is_ic_id
|
|
WHERE YEAR(GETDATE()) - YEAR(ic_datetime) >= ?
|
|
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')));
|
|
return $query->result();
|
|
}
|
|
|
|
|
|
//ct
|
|
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"
|
|
. " is1.is_parent_id, \n"
|
|
. " is1.is_path, \n"
|
|
. " is1.is_level, \n"
|
|
. " is1.is_sort, \n"
|
|
. " is1.is_sitecode, \n"
|
|
. " is1.is_datetime, \n"
|
|
. " is1.is_ic_id, \n"
|
|
. " ic.ic_id, \n"
|
|
. " ic.ic_url, \n"
|
|
. " ic.ic_url_title, \n"
|
|
. " ic.ic_type, \n"
|
|
. " ic.ic_title, \n"
|
|
. " ic.ic_content, \n"
|
|
. " ic.ic_summary, \n"
|
|
. " ic.ic_seo_title, \n"
|
|
. " ic.ic_seo_description, \n"
|
|
. " ic.ic_seo_keywords, \n"
|
|
. " ic.ic_show_bread_crumbs, \n"
|
|
. " ic.ic_status, \n"
|
|
. " ic.ic_template, \n"
|
|
. " ic.ic_photo, \n"
|
|
. " ic.ic_photo_width, \n"
|
|
. " ic.ic_photo_height, \n"
|
|
. " ic.ic_sitecode, \n"
|
|
. " ic.ic_recommend_tours, \n"
|
|
. " ic.ic_recommend_packages, \n"
|
|
. " ic.ic_datetime, \n"
|
|
. " ic.ic_ht_area_id, \n"
|
|
. " ic.ic_ht_area_type, \n"
|
|
. " ic.ic_ht_product_id, \n"
|
|
. " ic.ic_ht_product_type, \n"
|
|
. " ic.ic_author \n"
|
|
. " FROM infoStructures is1 \n"
|
|
. " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
|
|
. " AND ic.ic_sitecode = is1.is_sitecode \n"
|
|
. " WHERE is1.is_sitecode = ? ";
|
|
$sql .= $this->ic_url_is_id;
|
|
$query = $this->HT->query($sql, $webcode);
|
|
// print_r($this->HT->queries);
|
|
|
|
return $query->row();
|
|
}
|
|
|
|
//获取分组列表
|
|
function group_list(){
|
|
$this->init();
|
|
$this->search =' AND is_level<=1 ';
|
|
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
|
|
return $this->GetList();
|
|
}
|
|
|
|
|
|
}
|