172 lines
6.4 KiB
PHP
172 lines
6.4 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Comment class
|
|
*/
|
|
|
|
class Comment extends MY_Controller
|
|
{
|
|
|
|
/**
|
|
* 관리자 페이지 상의 현재 디렉토리입니다
|
|
* 페이지 이동시 필요한 정보입니다
|
|
*/
|
|
public $pagedir = 'contents/comment';
|
|
|
|
/**
|
|
* 모델을 로딩합니다
|
|
*/
|
|
protected $models = array('Contents', 'Contents_comment', 'Upload_file', 'Apps', 'Contents_category');
|
|
|
|
/**
|
|
* 이 컨트롤러의 메인 모델 이름입니다
|
|
*/
|
|
protected $modelname = 'Contents_comment_model';
|
|
|
|
/**
|
|
* 헬퍼를 로딩합니다
|
|
*/
|
|
protected $helpers = array('form', 'array', 'dhtml_editor');
|
|
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
|
|
/**
|
|
* 라이브러리를 로딩합니다
|
|
*/
|
|
$this->load->library(array('pagination', 'querystring'));
|
|
}
|
|
|
|
/**
|
|
* 목록을 가져오는 메소드입니다
|
|
*/
|
|
public function index()
|
|
{
|
|
|
|
$this->accesslevel->check_admin('read');
|
|
|
|
$view = array();
|
|
$view['view'] = array();
|
|
|
|
/**
|
|
* 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다.
|
|
*/
|
|
$param =& $this->querystring;
|
|
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
|
|
$findex = $this->input->get('findex') ? $this->input->get('findex') : 'con_sort';
|
|
$forder = $this->input->get('forder', null, 'desc');
|
|
$sfield = $this->input->get('sfield', null, '');
|
|
$skeyword = $this->input->get('skeyword', null, '');
|
|
|
|
$per_page = admin_listnum();
|
|
$offset = ($page - 1) * $per_page;
|
|
|
|
/**
|
|
* 게시판 목록에 필요한 정보를 가져옵니다.
|
|
*/
|
|
$this->{$this->modelname}->allow_search_field = array('app_id','com_id', 'contents_comment.con_id', 'com_content', 'contents_comment.user_id', 'contents.user_id', 'com_created_at'); // 검색이 가능한 필드
|
|
$this->{$this->modelname}->search_field_equal = array('app_id','com_id'); // 검색중 like 가 아닌 = 검색을 하는 필드
|
|
$this->{$this->modelname}->allow_order_field = array('con_id', 'com_id'); // 정렬이 가능한 필드
|
|
$where = array('contents.is_del' => '0');
|
|
if ($this->input->get('app_id')) {
|
|
$where['contents.app_id'] = $this->input->get('app_id');
|
|
}
|
|
if ($this->input->get('cat_id')) {
|
|
$where['contents.cat_id'] = $this->input->get('cat_id');
|
|
}
|
|
$result = $this->{$this->modelname}
|
|
->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword);
|
|
|
|
$list_num = $result['total_rows'] - ($page - 1) * $per_page;
|
|
if (element('list', $result)) {
|
|
foreach (element('list', $result) as $key => $val) {
|
|
$result['list'][$key]['num'] = $list_num--;
|
|
if (element('cat1_id', $val)) {
|
|
$result['list'][$key]['category1'] = $this->Contents_category_model->get_one(element('cat1_id', $val));
|
|
}
|
|
if (element('cat2_id', $val)) {
|
|
$result['list'][$key]['category2'] = $this->Contents_category_model->get_one(element('cat2_id', $val));
|
|
}
|
|
/*
|
|
if (element('cat3_id', $val)) {
|
|
$result['list'][$key]['category3'] = $this->Contents_category_model->get_one(element('cat3_id', $val));
|
|
}
|
|
if (element('cat4_id', $val)) {
|
|
$result['list'][$key]['category4'] = $this->Contents_category_model->get_one(element('cat4_id', $val));
|
|
}
|
|
*/
|
|
$result['list'][$key]['display_name'] = display_username(
|
|
element('user_username', $val)
|
|
);
|
|
}
|
|
}
|
|
|
|
$view['view']['data'] = $result;
|
|
$view['view']['applist'] = $this->Apps_model->app_list();
|
|
|
|
/**
|
|
* primary key 정보를 저장합니다
|
|
*/
|
|
$view['view']['primary_key'] = $this->{$this->modelname}->primary_key;
|
|
|
|
/**
|
|
* 페이지네이션을 생성합니다
|
|
*/
|
|
$config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page');
|
|
$config['total_rows'] = $result['total_rows'];
|
|
$config['per_page'] = $per_page;
|
|
$this->pagination->initialize($config);
|
|
$view['view']['paging'] = $this->pagination->create_links();
|
|
$view['view']['page'] = $page;
|
|
|
|
/**
|
|
* 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다
|
|
*/
|
|
$search_option = array('com_content' => '댓글내용');
|
|
$view['view']['skeyword'] = ($sfield && array_key_exists($sfield, $search_option)) ? $skeyword : '';
|
|
$view['view']['search_option'] = search_option($search_option, $sfield);
|
|
$view['view']['listall_url'] = admin_url($this->pagedir);
|
|
$view['view']['write_url'] = admin_url($this->pagedir . '/write');
|
|
$view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output());
|
|
|
|
/**
|
|
* 어드민 레이아웃을 정의합니다
|
|
*/
|
|
$layoutconfig = array('layout' => 'layout', 'skin' => 'index');
|
|
$view['layout'] = $this->layoutlib->admin($layoutconfig, $this->configlib->get_device_view_type());
|
|
$this->data = $view;
|
|
$this->layout = element('layout_skin_file', element('layout', $view));
|
|
$this->view = element('view_skin_file', element('layout', $view));
|
|
}
|
|
|
|
/**
|
|
* 목록 페이지에서 선택삭제를 하는 경우 실행되는 메소드입니다
|
|
*/
|
|
public function listdelete()
|
|
{
|
|
|
|
$this->accesslevel->check_admin('delete');
|
|
|
|
/**
|
|
* 체크한 게시물의 삭제를 실행합니다
|
|
*/
|
|
if ($this->input->post('chk') && is_array($this->input->post('chk'))) {
|
|
foreach ($this->input->post('chk') as $val) {
|
|
if ($val) {
|
|
$this->{$this->modelname}->delete($val);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 삭제가 끝난 후 목록페이지로 이동합니다
|
|
*/
|
|
$this->session->set_flashdata('message','정상적으로 삭제되었습니다');
|
|
$param =& $this->querystring;
|
|
$redirecturl = admin_url($this->pagedir . '?' . $param->output());
|
|
|
|
redirect($redirecturl);
|
|
}
|
|
} |