PHP File Manager
Editing File: Entries.php
<?php class Entries extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('news'); } function index($page = null) { $news_entries = $this->news->get(null, array( 'paginate' => true, 'page' => $page, )); $total_news = $this->common->countPreviousQuery(); $this->load->view('header', array('page_title' => 'News')); $this->load->view('news/index', array( 'total_news' => $total_news, 'news_entries' => $news_entries )); $this->load->view('footer'); } function edit($news_id = null) { if ($this->input->post()) { if ($this->input->post('submit_type') == 'delete') { $this->news->delete($this->input->post('news_id')); redirect(site_url(array('news'))); } else { $news_id = $this->news->save($this->input->post()); if ($news_id) { if ($this->input->post('submit_type') == 'save_and_edit') { redirect(site_url(array('news', 'edit', $news_id))); } } redirect(site_url(array('news'))); } } $locations_selection = $this->locations->getDropdownData($this->locations->get()); $teams_selection = $this->teams->getDropdownData($this->teams->get()); if ($news_id) { $news = $this->news->get($news_id); } $header_data = array('page_title' => 'Create news entry'); $page_data = array( 'locations_selection' => $locations_selection, 'teams_selection' => $teams_selection, ); if (isset($news)) { $header_data['page_title'] = "Edit - {$news->title}"; $page_data['news'] = $news; } $this->load->view('header', $header_data); $this->load->view('news/edit', $page_data); $this->load->view('footer'); } function categories() { if ($this->input->post()) { $this->news->saveCategories($this->input->post()); redirect(array('news', 'categories')); } $categories = $this->news->getCategories(); $this->load->view('header', array('page_title' => 'News categories')); $this->load->view('news/categories', array('categories' => $categories)); $this->load->view('footer'); } }
Cancel