<?php

class crud_callback_chunk_options
{
    
}

class crud_callback_chunk_run
{

    protected $field = '';
    protected $run = '';
    protected $post = array();

    public function __construct($field = '', $run = '', $post_data = array())
    {
        $this->set_field($field);
        $this->run = $run;
        $this->set_post($post_data);
    }

    public function set_field($field = '')
    {
        $this->field = $field;
    }

    public function set_post($post_data = array())
    {
        $this->post = $post_data;
    }

    public function get_callback_string()
    {

        return '$this->crud->callback(\'' . $this->field . '\', ' . $this->run . ');';
    }

}

class crud_callback_chunk_schema
{

    protected $table = '';
    protected $field = '';
    protected $type = '';
    protected $notNULL = FALSE;
    protected $extra_fields = '';

    public function set_table($table)
    {
        $this->table = $table;
    }

    public function set_field($field)
    {
        $this->field = $field;
    }

    public function set_type($type)
    {
        $this->type = $type;
    }

    public function set_not_null($notNULL = FALSE)
    {
        $this->notNULL = $notNULL;
    }

    public function get_table()
    {
        return $this->table;
    }
    
    public function get_extra_fields()
    {
        return $this->extra_fields;
    }

    public function generate()
    {
        $str = '`'
                . $this->field
                . '` '
                . $this->type
                . ($this->notNULL ? ' NOT NULL' : '');

        return $str;
    }

}

interface chunk_interface
{

    public function get_admin_html();

    public function run();
}

interface crud_callback_chunk
{

    /**
     * @return string
     */
    public function get_name();

    /**
     * @return mixed boolen|crud_callback_chunk_options
     */
    public function get_options();

    /**
     * @return string|crud_callback_chunk_schema
     */
    public function get_schema();

    /**
     * @return mixed string|crud_callback_chunk_run
     */
    public function run();
}
