Files
cm-web/application/controllers/admin/Comments.php
2020-06-10 06:21:34 +09:00

54 lines
2.0 KiB
PHP
Executable File

<?php
class Comments extends MY_Controller {
public function __construct()
{
define("HOOSK_ADMIN", 1);
parent::__construct();
$this->load->model('comment_model');
$this->load->helper(array('admincontrol', 'url', 'hoosk_admin', 'file', 'form'));
$this->load->library('session');
define('LANG', $this->data['settings']->siteLang);
$this->lang->load('admin', LANG);
//Define what page we are on for nav
$this->data['current'] = $this->uri->segment(2);
//check session exists
Admincontrol_helper::is_logged_in($this->session->userdata('userName'));
$this->load->helper('general');
}
public function index()
{
$this->load->library('pagination');
$result_per_page = 15; // the number of result per page
$config['base_url'] = BASE_URL . '/admin/comments/';
$config['total_rows'] = $this->comment_model->getCountPaging();
$config['per_page'] = $result_per_page;
$config['last_link'] = false;
$config['first_link'] = false;
$config['suffix'] = '?term=' . getSearchTerm();
$this->pagination->initialize($config);
//Get posts from database
$this->data['comments'] = $this->comment_model->getPaging($result_per_page, $this->uri->segment(3))
->get()->result();
$this->data['header'] = $this->load->view('admin/header', $this->data, true);
$this->data['footer'] = $this->load->view('admin/footer', '', true);
$this->load->view('admin/comments', $this->data);
}
public function delete()
{
if ($this->input->post('deleteid')) :
$this->comment_model->delete($this->input->post('deleteid'));
redirect(BASE_URL . '/admin/comments');
else :
$this->data['form'] = [(array)$this->comment_model->getOne($this->uri->segment(4))];
$this->load->view('admin/comment_delete.php', $this->data);
endif;
}
}