Threaded View

  1. #1
    Ext User
    Join Date
    Apr 2009
    Posts
    9
    Vote Rating
    0
    goachka is on a distinguished road

      0  

    Default Ext.Direct for CodeIgniter

    Ext.Direct for CodeIgniter


    Usage
    Just copy archive contents to your application folder.
    It will create cache folder in your application folder (make this folder writable!).
    It will place extdapi.php, extdcacheprovider.php, extdrouter.php to the libraries folder.
    It will place example classes Echo.php, Exception.php, File.php, Time.php to the same folder.
    And it will place direct.php to the controllers folder.

    Now you can test it:
    1. Add a script tag in your main application page for the API:
    Code:
    <script type="text/javascript" src="<?=base_path()?>direct/api"></script>
    2. Add provider:
    Code:
    Ext.Direct.addProvider(Ext.app.REMOTING_API);
    3. Now you can call some method, for example Time.get():
    Code:
    Ext.mits.Time.get(function(provider, response) {
        Ext.Msg.alert('response', response.result);
    });
    Now you can use your own classes:
    Place them to the libraries folder. Don't forget to make comments before each method of your class. First of all it should have @remotable attribute:
    Code:
    class Time {
        /**
         * @remotable
         */
        public function get(){
            return date('m-d-Y H:i:s');
        }
    }
    If you use method to submit form, add @formHandler attribute:
    Code:
    /**
     * @remotable
     * @formHandler
     */
    Just see example classes, included in this implementation.

    To include your own classes replace $api definition in file direct.php with your own:
    Code:
    $api->add(
        array(
            'MyClass1',
            'MyClass2',
            ...
        )
    );
    Classes files should be named accordingly MyClass1.php, MyClass2.php, ...

    If you want to use CodeIgniter object in your classes, just get instance:
    PHP Code:
    $CI =& get_instance(); 
    P.S. This code doesn't work on Windows platform, because of backslashes in win paths.. something should be updated...
    Attached Files