Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- class Content extends Admin_Controller {
- public function __construct()
- {
- parent::__construct();
- Template::set('toolbar_title', 'ToDo List');
- $this->load->model('Todo_model', 'todo_model', true);
- }
- public function index()
- {
- if ($this->input->post('submit'))
- {
- $this->form_validation->set_rules('description', 'Description', 'required|callback_description_check|trim|strip_tags|max_length[10]|xss_clean');
- if ($this->form_validation->run() !== FALSE)
- {
- $this->todo_model->insert($this->input->post());
- Template::set_message('New ToDo item successfully created', 'success');
- }
- else
- {
- Template::set_message('Error creating new ToDo item.', 'error');
- }
- }
- Template::set('items', $this->todo_model->order_by('todo_id', 'desc')->find_all_by('deleted', 0));
- Template::render();
- }
- public function delete()
- {
- $id = $this->uri->segment(5);
- $this->todo_model->delete($id);
- echo 'true';
- die();
- }
- /**
- * validation callback
- */
- function description_check($str) {
- if ($str == 'test')
- {
- $this->form_validation->set_message('description_check', 'The %s field can not be the word "test"');
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- }
Add Comment
Please, Sign In to add comment