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.
54 lines
1.9 KiB
PHP
54 lines
1.9 KiB
PHP
<?php
|
|
|
|
if (!defined('BASEPATH'))
|
|
exit('No direct script access allowed');
|
|
|
|
class City extends CI_Controller
|
|
{
|
|
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->permission->is_admin();
|
|
$this->load->model('Area_model');
|
|
$this->load->model('Information_model');
|
|
$this->load->model('InfoContents_model');
|
|
$this->load->model('InfoStructures_model');
|
|
}
|
|
|
|
public function index($city_id)
|
|
{
|
|
//查询不到城市信息则显示错误
|
|
$data['city'] = $this->Area_model->get_city($city_id);
|
|
if ($data['city'] == FALSE)
|
|
{
|
|
show_404();
|
|
}
|
|
//查询结构根节点,当为空则建立
|
|
$rootStructure = $this->Information_model->GetRoot('c', $city_id);
|
|
if ($rootStructure == FALSE)
|
|
{
|
|
$this->InfoContents_model->Add('', $data['city']->CII2_Name, 'root', '', '', '', '', '', '', 0, 0, '', '',0,0, '', '', $city_id, 'c', 0, '','');
|
|
$this->InfoStructures_model->Add(0, $this->InfoContents_model->insert_id);
|
|
$is_id = $this->InfoStructures_model->insert_id;
|
|
}
|
|
else
|
|
{
|
|
$is_id = $rootStructure->is_id;
|
|
}
|
|
redirect(site_url('information/edit/' . $is_id));
|
|
}
|
|
|
|
//$is_sort=-99 代表根节点
|
|
public function addnode($is_parent_id,$is_sort=-99){
|
|
$Structure = $this->InfoStructures_model->Detail($is_parent_id);
|
|
if ($is_parent_id!=='-99' && $Structure == FALSE ) {
|
|
show_404();
|
|
}
|
|
|
|
$ic_id=$this->InfoContents_model->add_use_ORM('infoContents',array('ic_url_title'=>'new information','ic_title'=>'new information','ic_sitecode'=>$this->config->item('site_code')));
|
|
$this->InfoStructures_model->Add($is_parent_id,$ic_id,$is_sort);
|
|
redirect(site_url('information/edit/' . $this->InfoStructures_model->insert_id));
|
|
}
|
|
|
|
} |