<?php

class ccc_multilang_run extends crud_callback_chunk_run
{

    public function get_callback_string()
    {
        $ci = & get_instance();

        return '$this->crud->multilang(new multilang(\'translate_' . $this->field . '\', \'' . $ci->input->post('table_name') . '_translate\', \'' . $this->field . '\'));';
    }

}

class ccc_multilang_schema extends crud_callback_chunk_schema
{

    protected $type = 'varchar(255) CHARACTER SET utf8';

    public function get_table()
    {
        return parent::get_table() . '_translate';
    }
    
    public function get_extra_fields()
    {
        return '`id_lan` int(11), ' . PHP_EOL . '`id_' . $this->table . '` int(11)';
    }

}

class ccc_multilang implements crud_callback_chunk
{

    public function get_name()
    {
        return 'Multilanguage field';
    }

    public function get_options()
    {
        return new crud_callback_chunk_options();
    }

    public function get_schema()
    {
        return new ccc_multilang_schema();
    }

    public function run()
    {
        return new ccc_multilang_run();
    }

}
