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.
101 lines
3.8 KiB
PHTML
101 lines
3.8 KiB
PHTML
8 years ago
|
<?php
|
||
|
|
||
|
if (!defined('BASEPATH'))
|
||
|
exit('No direct script access allowed');
|
||
|
|
||
|
class Seo extends CI_Controller {
|
||
|
|
||
|
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('InfoSEOs_model');
|
||
|
}
|
||
|
|
||
|
public function index() {
|
||
|
$data = array();
|
||
|
$data['seo_list'] = $this->InfoSEOs_model->all();
|
||
|
$this->load->view('bootstrap3/header', $data);
|
||
|
$this->load->view('bootstrap3/seo');
|
||
|
$this->load->view('bootstrap3/footer');
|
||
|
}
|
||
|
|
||
|
public function search() {
|
||
|
$seo_url = $this->input->post('url_keyword');
|
||
|
$data['url_list'] = $this->InfoSEOs_model->search($seo_url);
|
||
|
$url_list_view = $this->load->view('seo_select_url', $data, true);
|
||
|
$data = array();
|
||
|
$data[] = array('name' => 'ok', 'value' => $url_list_view);
|
||
|
echo json_encode($data);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public function detail($seo_id = FALSE) {
|
||
|
$data = array();
|
||
|
if (!empty($seo_id)) {
|
||
|
$data['seo_detail'] = $this->InfoSEOs_model->get_detail($seo_id);
|
||
|
}
|
||
|
$data['seo_list'] = $this->InfoSEOs_model->all();
|
||
|
|
||
|
$this->load->view('bootstrap3/header', $data);
|
||
|
$this->load->view('bootstrap3/seo');
|
||
|
$this->load->view('bootstrap3/footer');
|
||
|
}
|
||
|
|
||
|
public function add() {
|
||
|
$this->InfoSEOs_model->add('新的SEO信息', '//新的SEO信息', '', '', '', '');
|
||
|
redirect(site_url('seo/detail/' . $this->InfoSEOs_model->insert_id));
|
||
|
}
|
||
|
|
||
|
public function edit_save() {
|
||
|
$this->form_validation->set_rules('seo_url', 'lang:seo_url', 'callback_seo_url_check|required');
|
||
|
$this->form_validation->set_rules('seo_title', 'lang:ic_seo_title', 'required');
|
||
|
$this->form_validation->set_rules('seo_h1', 'lang:seo_h1', 'required|max_length[50]');
|
||
|
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 {
|
||
|
$seo_detail = $this->InfoSEOs_model->get_detail($this->input->post('seo_id'));
|
||
|
|
||
|
if ($seo_detail) {
|
||
|
$this->InfoSEOs_model->update($this->input->post('seo_id'), $this->input->post('seo_h1'), $this->input->post('seo_url'), $this->input->post('seo_title'), $this->input->post('seo_keywords'), $this->input->post('seo_description'), $this->input->post('seo_summary'));
|
||
|
} else {
|
||
|
$this->InfoSEOs_model->add($this->input->post('seo_h1'), $this->input->post('seo_url'), $this->input->post('seo_title'), $this->input->post('seo_keywords'), $this->input->post('seo_description'), $this->input->post('seo_summary'));
|
||
|
}
|
||
|
$data[] = array('name' => 'ok', 'value' => $this->lang->line('seo_save_success'));
|
||
|
echo json_encode($data);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//URL重复检测
|
||
|
public function seo_url_check($url) {
|
||
|
$seo_id = $this->input->post('seo_id');
|
||
|
if ($this->InfoSEOs_model->url_check($seo_id, $url)) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function delete($seo_id) {
|
||
|
if (!empty($seo_id)) {
|
||
|
$detail_seo = $this->InfoSEOs_model->get_detail($seo_id);
|
||
|
if ($detail_seo) {
|
||
|
$this->InfoSEOs_model->delete($seo_id);
|
||
|
}
|
||
|
}
|
||
|
redirect(site_url('seo'));
|
||
|
//想办法做提示
|
||
|
// $data[] = array('name' => 'ok_go', 'value' => site_url('seo'));
|
||
|
// echo json_encode($data);
|
||
|
}
|
||
|
|
||
|
}
|