thomascube
2010-10-06 2fe8d6bdebbaa160ee062b18e78fe7e77b430e00
program/include/rcube_json_output.php
@@ -4,8 +4,8 @@
 +-----------------------------------------------------------------------+
 | program/include/rcube_json_output.php                                 |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2008-2009, RoundCube Dev. - Switzerland                 |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2008-2010, Roundcube Dev. - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -16,7 +16,7 @@
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 +-----------------------------------------------------------------------+
 $Id:  $
 $Id$
*/
@@ -36,19 +36,21 @@
    private $callbacks = array();
    private $message = null;
    public $browser;
    public $type = 'js';
    public $ajax_call = true;
    /**
     * Constructor
     */
    public function __construct($task)
    public function __construct($task=null)
    {
        $this->config = rcmail::get_instance()->config;
        $this->config  = rcmail::get_instance()->config;
        $this->browser = new rcube_browser();
    }
    /**
     * Set environment variable
     *
@@ -59,7 +61,8 @@
    {
        $this->env[$name] = $value;
    }
    /**
     * Issue command to set page title
     *
@@ -68,8 +71,9 @@
    public function set_pagetitle($title)
    {
        $name = $this->config->get('product_name');
        $this->command('set_pagetitle', JQ(empty($name) ? $title : $name.' :: '.$title));
        $this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title);
    }
    /**
     * @ignore
@@ -103,6 +107,7 @@
        // ignore
    }
    /**
     * Register a list of template object handlers
     *
@@ -113,8 +118,8 @@
    {
        // ignore
    }
    /**
     * Call a client method
     *
@@ -145,7 +150,7 @@
            $this->texts[$name] = rcube_label($name);
        }
    }
    /**
     * Invoke display_message command
@@ -167,7 +172,8 @@
            );
        }
    }
    /**
     * Delete all stored env variables and commands
     */
@@ -177,7 +183,8 @@
        $this->texts = array();
        $this->commands = array();
    }
    /**
     * Redirect to a certain url
     *
@@ -218,7 +225,6 @@
            $s_header_sent = true;
            send_nocacheing_headers();
            header('Content-Type: text/plain; charset=' . $this->get_charset());
            print '/** ajax response ['.date('d/M/Y h:i:s O')."] **/\n";
        }
        // unset default env vars
@@ -228,21 +234,21 @@
        $response = array('action' => $rcmail->action, 'unlock' => (bool)$_REQUEST['_unlock']);
        
        if (!empty($this->env))
          $response['env'] = $this->env;
            $response['env'] = $this->env;
          
        if (!empty($this->texts))
          $response['texts'] = $this->texts;
            $response['texts'] = $this->texts;
        // send function calls
        $response['exec'] = $this->get_js_commands() . $add;
        
        if (!empty($this->callbacks))
          $response['callbacks'] = $this->callbacks;
            $response['callbacks'] = $this->callbacks;
        echo json_serialize($response);
    }
    /**
     * Return executable javascript code for all registered commands
     *
@@ -251,7 +257,7 @@
    private function get_js_commands()
    {
        $out = '';
        foreach ($this->commands as $i => $args) {
            $method = array_shift($args);
            foreach ($args as $i => $arg) {
@@ -268,5 +274,3 @@
        return $out;
    }
}