master
LMR 2 years ago
parent eb244f7cab
commit 776b0b6d86

@ -139,10 +139,9 @@ class Information extends CI_Controller
if ($item->is_parent_id == $src->is_id) {
// info_content
echo $item->is_ic_id . ' @ ';
$item_info_content = $this->InfoContents_model->Detail($item->is_ic_id);
print_r($item_info_content);
/*
$this->InfoContents_model->add(
$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,
@ -164,7 +163,8 @@ class Information extends CI_Controller
$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
$item_info_content->ic_author,
$dest->is_sitecode
);
// info_meta
$item_meta_amp = $this->InfoMetas_model->Detail($item->is_ic_id, 'AMP');
@ -181,9 +181,9 @@ class Information extends CI_Controller
$this->InfoMetas_model->Add($this->InfoContents_model->insert_id, 'AMP_SCHEMA', $item_meta_pcschema);
// 添加节点
$this->InfoStructures_model->Add($dest->is_id, $this->InfoContents_model->insert_id);
$this->InfoStructures_model->Add_with_sitecode($dest->is_id, $this->InfoContents_model->insert_id, 999, $dest->is_sitecode);
$node_map[$item->is_id] = $this->InfoStructures_model->insert_id;
*/
} else {
}

@ -85,6 +85,70 @@ class InfoContents_model extends CI_Model
return $query;
}
function Add_with_sitecode(
$ic_url,
$ic_url_title,
$ic_type,
$ic_title,
$ic_content,
$ic_summary,
$ic_seo_title,
$ic_seo_description,
$ic_seo_keywords,
$ic_show_bread_crumbs,
$ic_status,
$ic_template,
$ic_photo,
$ic_photo_width,
$ic_photo_height,
$ic_recommend_tours,
$ic_recommend_packages,
$ic_ht_area_id,
$ic_ht_area_type,
$ic_ht_product_id,
$ic_ht_product_type,
$ic_author,
$site_code = ''
) {
if (empty($site_code)) {
$site_code = $this->config->item('site_code');
}
$ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content);
$ic_content = str_replace('#textarea#', 'textarea', $ic_content);
$ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content);
$sql = "INSERT INTO infoContents \n"
. " ( \n"
. " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n"
. " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n"
. " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n"
. " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n"
. " ) \n"
. "VALUES \n"
. " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )";
$query = $this->HT->query(
$sql,
array(
$ic_url, $ic_url_title, $ic_type, $ic_title, str_replace(
$this->config->item('media_image_url'),
$this->config->item('site_image_url'),
$ic_content
),
$ic_summary, $ic_seo_title, $ic_seo_description, $ic_seo_keywords, $ic_show_bread_crumbs, $ic_status,
$ic_template, $ic_photo, $ic_photo_width, $ic_photo_height, $site_code, $ic_recommend_tours, $ic_recommend_packages,
$ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type, $ic_author
)
);
$this->insert_id = $this->HT->last_id('infoContents');
return $query;
}
function Update(
$ic_id,
$ic_url,
@ -204,7 +268,7 @@ class InfoContents_model extends CI_Model
public function get_ic_contents2($ic_id)
{
$sql = "SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo, ic_sitecode, ic_seo_description from infoContents where ic_id=?";
$sql = "SELECT top 1 * from infoContents where ic_id=?";
$query = $this->HT->query($sql, array($ic_id));
if ($query->result()) {
$row = $query->row();

@ -16,100 +16,127 @@ class InfoStructures_model extends CI_Model
function Detail($is_id)
{
$sql = "SELECT TOP 1 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"
. "FROM infoStructures is1 \n"
. "WHERE is1.is_id = ?";
. " 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"
. "FROM infoStructures is1 \n"
. "WHERE is1.is_id = ?";
$query = $this->HT->query($sql, array($is_id));
//print_r($this->HT->queries);
if ($query->result())
{
if ($query->result()) {
$row = $query->row();
return $row;
}
else
{
} else {
return FALSE;
}
}
function Add($is_parent_id, $is_ic_id=-1,$is_sort=999)
function Add($is_parent_id, $is_ic_id = -1, $is_sort = 999)
{
if ($is_parent_id == 0 )
{
if ($is_parent_id == 0) {
$is_path = '';
$is_level = 1;
}else if($is_parent_id == -99){
$is_path = '';
} else if ($is_parent_id == -99) {
$is_path = '';
$is_level = 0;
$is_sort=0;
}
else
{
$is_sort = 0;
} else {
$infoStructure = $this->Detail($is_parent_id);
if ($infoStructure)
{
if ($infoStructure) {
$is_path = $infoStructure->is_path;
$is_level = $infoStructure->is_level + 1;
}
else
{
} else {
return false;
}
}
$sql = "INSERT INTO infoStructures \n"
. " ( \n"
. " is_parent_id, is_path, is_level, is_sort, is_sitecode, is_datetime, is_ic_id \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, getdate(), ? \n"
. " )";
. " ( \n"
. " is_parent_id, is_path, is_level, is_sort, is_sitecode, is_datetime, is_ic_id \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, getdate(), ? \n"
. " )";
$query = $this->HT->query($sql, array($is_parent_id, $is_path, $is_level, $is_sort, $this->config->item('site_code'), $is_ic_id));
$this->insert_id = $this->HT->last_id('infoStructures');
//把自己的ID加到path上
$set_sql = "UPDATE infoStructures \n"
. "SET is_path = is_path + CONVERT(VARCHAR(200), is_id) + ',' \n"
. "WHERE is_id = ?";
. "SET is_path = is_path + CONVERT(VARCHAR(200), is_id) + ',' \n"
. "WHERE is_id = ?";
$query = $this->HT->query($set_sql, array($this->insert_id));
return $this->insert_id;
}
function GetParent($is_path, $level=1)
function Add_with_sitecode($is_parent_id, $is_ic_id = -1, $is_sort = 999, $site_code = '')
{
if ($is_path == '')
{
if (empty($site_code)) {
$site_code = $this->config->item('site_code');
}
if ($is_parent_id == 0) {
$is_path = '';
$is_level = 1;
} else if ($is_parent_id == -99) {
$is_path = '';
$is_level = 0;
$is_sort = 0;
} else {
$infoStructure = $this->Detail($is_parent_id);
if ($infoStructure) {
$is_path = $infoStructure->is_path;
$is_level = $infoStructure->is_level + 1;
} else {
return false;
}
}
$sql = "INSERT INTO infoStructures \n"
. " ( \n"
. " is_parent_id, is_path, is_level, is_sort, is_sitecode, is_datetime, is_ic_id \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, getdate(), ? \n"
. " )";
$query = $this->HT->query($sql, array($is_parent_id, $is_path, $is_level, $is_sort, $site_code, $is_ic_id));
$this->insert_id = $this->HT->last_id('infoStructures');
//把自己的ID加到path上
$set_sql = "UPDATE infoStructures \n"
. "SET is_path = is_path + CONVERT(VARCHAR(200), is_id) + ',' \n"
. "WHERE is_id = ?";
$query = $this->HT->query($set_sql, array($this->insert_id));
return $this->insert_id;
}
function GetParent($is_path, $level = 1)
{
if ($is_path == '') {
return false;
}
$sql = "SELECT TOP 1 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"
. "FROM infoStructures is1 \n"
. "WHERE is1.is_level = ? \n"
. " AND is1.is_id IN ($is_path 0) \n"
. "ORDER BY \n"
. " is1.is_id ASC";
. " 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"
. "FROM infoStructures is1 \n"
. "WHERE is1.is_level = ? \n"
. " AND is1.is_id IN ($is_path 0) \n"
. "ORDER BY \n"
. " is1.is_id ASC";
$query = $this->HT->query($sql, array($level));
// print_r($this->HT->queries);
if ($query->result())
{
if ($query->result()) {
$row = $query->row();
return $row;
}
else
{
} else {
return FALSE;
}
}
@ -119,12 +146,9 @@ class InfoStructures_model extends CI_Model
{
$detail = $this->Detail($is_id);
$root = $this->GetParent($detail->is_path, 1);
if ($root)
{
if ($root) {
return $root;
}
else
{ //没有根节点则返回本节点
} else { //没有根节点则返回本节点
return $detail;
}
}
@ -133,15 +157,12 @@ class InfoStructures_model extends CI_Model
function HasChild($is_id)
{
$sql = "SELECT TOP 1 is1.is_id \n"
. "FROM infoStructures is1 \n"
. "WHERE is1.is_parent_id = ?";
. "FROM infoStructures is1 \n"
. "WHERE is1.is_parent_id = ?";
$query = $this->HT->query($sql, array($is_id));
if ($query->result())
{
if ($query->result()) {
return true;
}
else
{
} else {
return FALSE;
}
}
@ -150,8 +171,8 @@ class InfoStructures_model extends CI_Model
function Delete($is_id)
{
$sql = "DELETE \n"
. "FROM infoStructures \n"
. "WHERE is_id = ?";
. "FROM infoStructures \n"
. "WHERE is_id = ?";
$query = $this->HT->query($sql, array($is_id));
return $query;
}
@ -160,9 +181,9 @@ class InfoStructures_model extends CI_Model
function set_sort($is_id, $sort)
{
$sql = "UPDATE infoStructures \n"
. "SET is_datetime = GETDATE(), \n"
. " is_sort = ? \n"
. "WHERE is_id = ?";
. "SET is_datetime = GETDATE(), \n"
. " is_sort = ? \n"
. "WHERE is_id = ?";
$query = $this->HT->query($sql, array($sort, $is_id));
//print_r($this->HT->queries);
return $query;
@ -173,8 +194,7 @@ class InfoStructures_model extends CI_Model
{
$structure = $this->Detail($is_id);
//如果父级相同则不需要重新设置path
if ($parent_id == $structure->is_parent_id)
{
if ($parent_id == $structure->is_parent_id) {
return true;
}
$parent = $this->Detail($parent_id);
@ -184,39 +204,37 @@ class InfoStructures_model extends CI_Model
$set_path = $parent->is_path . $is_id . ',';
$set_sql = "UPDATE infoStructures \n"
. "SET is_parent_id = ?, \n"
. " is_level = ?, \n"
. " is_path = ? \n"
. "WHERE is_id = ?";
. "SET is_parent_id = ?, \n"
. " is_level = ?, \n"
. " is_path = ? \n"
. "WHERE is_id = ?";
$this->HT->query($set_sql, array($set_parent_id, $set_level, $set_path, $is_id));
$structure = $this->Detail($is_id);
//查询当前节点的所有子节点
$sql = "SELECT is1.is_id, \n"
. " is1.is_parent_id, \n"
. " is1.is_path, \n"
. " is1.is_level, \n"
. " is1.is_sort \n"
. "FROM infoStructures is1 \n"
. "WHERE ',' + is1.is_path LIKE '%,$structure->is_id,%' \n"
. "ORDER BY \n"
. " is1.is_level ASC ";
. " is1.is_parent_id, \n"
. " is1.is_path, \n"
. " is1.is_level, \n"
. " is1.is_sort \n"
. "FROM infoStructures is1 \n"
. "WHERE ',' + is1.is_path LIKE '%,$structure->is_id,%' \n"
. "ORDER BY \n"
. " is1.is_level ASC ";
$query = $this->HT->query($sql);
foreach ($query->result() as $item)
{
if ($item->is_parent_id != $structure->is_id)
{
foreach ($query->result() as $item) {
if ($item->is_parent_id != $structure->is_id) {
$structure = $this->Detail($item->is_parent_id);
}
$set_parent_id = $structure->is_id;
$set_level = $structure->is_level + 1;
$set_path = $structure->is_path . $item->is_id . ',';
$set_sql = "UPDATE infoStructures \n"
. "SET is_parent_id = ?, \n"
. " is_level = ?, \n"
. " is_path = ? \n"
. "WHERE is_id = ?";
. "SET is_parent_id = ?, \n"
. " is_level = ?, \n"
. " is_path = ? \n"
. "WHERE is_id = ?";
$this->HT->query($set_sql, array($set_parent_id, $set_level, $set_path, $item->is_id));
}
}
@ -227,21 +245,22 @@ class InfoStructures_model extends CI_Model
* @return:
* @Date Changed:
*/
public function AddRootNote($is_ic_id){
public function AddRootNote($is_ic_id)
{
$sql = "INSERT INTO infoStructures \n"
. " ( \n"
. " is_parent_id, is_path, is_level, is_sort, is_sitecode, is_datetime, is_ic_id \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, getdate(), ? \n"
. " )";
. " ( \n"
. " is_parent_id, is_path, is_level, is_sort, is_sitecode, is_datetime, is_ic_id \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, getdate(), ? \n"
. " )";
$query = $this->HT->query($sql, array(-99, '', 0, 0, $this->config->item('site_code'), $is_ic_id));
$this->insert_id = $this->HT->last_id('infoStructures');
//把自己的ID加到path上
$set_sql = "UPDATE infoStructures \n"
. "SET is_path = is_path + CONVERT(VARCHAR(200), is_id) + ',' \n"
. "WHERE is_id = ?";
. "SET is_path = is_path + CONVERT(VARCHAR(200), is_id) + ',' \n"
. "WHERE is_id = ?";
$query = $this->HT->query($set_sql, array($this->insert_id));
return $this->insert_id;

Loading…
Cancel
Save