A complete platform for building web applications.

Controllers

Controllers is a layer between model and view, file name must be in {app-name}/{controller-name}.php format.

Command:

php creator make controller category Todo
php creator make controller task Todo

application/controllers/Todo/routes.php
application/language/arabic/todo_lang.php
application/language/english/todo_lang.php
application/controllers/Todo/Category.php

application/controllers/Todo/Task.php

The routes.php file:

<?php
$route['Todo'] = 'Todo/Category';

The language/arabic/todo_lang.php file:

<?php
/**
 * Todo language file
 */
defined('BASEPATH') OR exit('No direct script access allowed');

$lang['Todo'] = "Todo";

Start translate you application.

The controllers/Todo/Category.php file:

<?php
/**
 * Category Controller
 *
 * Provide Category functions.
 *
 */

class Category extends ER_Controller {
    /**
     * Class constructor
     *
     * @return  void
     */
    function __construct()
    {
        parent::__construct();
        $this->load->model('Todo/Category_model', 'category');
    }

    /**
     *
     * Index Page for this controller.
     *
     */
    public function index()
    {
        redirect('/Todo/Category/list');
    }

/**
 *
 * List Page for this controller.
 *
 */
public function getList()
{
    $this->create_button = true;
    $this->search_button = true;
    $limit  = 10;
    $offset = $this->input->get('page', TRUE);
    $count  = $this->category->count();
    $this->data['paging'] = make_paging($count, $limit);
    $this->data['rows_list'] = $this->category->rows();
}

/**
 *
 * List Page for this controller.
 *
 */
public function postList()
{
    $this->create_button = true;
    $this->search_button = true;

    $input = $this->input->post(array_keys($this->category->forms('search')), TRUE);
    $this->form_validation->set_rules($this->category->rules('search'));

    if (empty($this->category->rules('search')) || $this->form_validation->run() === TRUE)
    {
        $limit  = 10;
        $offset = $this->input->get('page', TRUE);
        $count  = $this->category->count_search($input);
        $this->data['paging'] = make_paging($count, $limit);
        $this->data['rows_list'] = $this->category->search($input, $limit, $offset);
    }
    else
    {
        set_message($this->form_validation->error_array(), 'error');
        redirect('/Todo/Category/list');
    }
}

/**
 *
 * Show Page for this controller.
 *
 */
public function getShow($id)
{
    $this->data['row'] = $this->category->find($id);
    if(!is_object($this->data['row']))
    {
        set_message('row_is_not_found', 'error');
        redirect('/Todo/Category/list');
    }
}

/**
 *
 * getCreate Page for this controller.
 *
 */
public function getCreate()
{
}

/**
 *
 * getCreate Page for this controller.
 *
 */
public function postCreate()
{
    $input = $this->input->post(array_keys($this->category->forms('create')), TRUE);
    $this->form_validation->set_rules($this->category->rules('create'));

    if ($this->form_validation->run() === TRUE)
    {
        $category = new $this->category;
        foreach ($input as $key => $value) {
            $category->$key = $value;
        }
        $category = $category->insert();
        set_message('row_has_been_created', 'success');
        redirect('/Todo/Category/list');
    }
    else
    {
        set_message($this->form_validation->error_array(), 'error');
        redirect('/Todo/Category/create');
    }
}

/**
 *
 * getEdit Page for this controller.
 *
 */
public function getEdit($id)
{
    $this->data['row'] = $this->category->find($id);
    if(!is_object($this->data['row']))
    {
        set_message('row_is_not_found', 'error');
        redirect('/Todo/Category/list');
    }
}

/**
 *
 * postEdit Page for this controller.
 *
 */
public function postEdit($id)
{
    $input = $this->input->post(array_keys($this->category->forms('edit')), TRUE);
    $this->form_validation->set_rules($this->category->rules('edit'));

    if ($this->form_validation->run() === TRUE)
    {
        $category = $this->category->find($id);
        if(is_object($category))
        {
            foreach ($input as $key => $value) {
                $category->$key = $value;
            }
            $category->update();
            set_message('row_has_been_updated', 'success');
        }
        else
        {
            set_message('row_is_not_found', 'error');
            redirect('/Todo/Category/list');
        }
    }
    else
    {
        set_message($this->form_validation->error_array(), 'error');
    }
    redirect('/Todo/Category/edit/'.$id);
}

/**
 *
 * postDelete Page for this controller.
 *
 */
public function postDelete()
{
    $input = $this->input->post(array_keys($this->category->forms('delete')), TRUE);
    $category = $this->category->find($input[$this->category->primaryKey]);
    if(is_object($category))
    {
        $category->delete();
        set_message('row_has_been_deleted', 'success');
    }
    else
    {
        set_message('row_is_not_found', 'error');
    }
    redirect('/Todo/Category/list');
}

}

/* End of file Category.php */
/* Location: ./application/controllers/Todo/Category.php */

And do the same with controllers/Todo/Task.php

Next is the Views.