| | |
| | | <?php |
| | | |
| | | /* |
| | | /** |
| | | +-----------------------------------------------------------------------+ |
| | | | program/include/rc,aiƶ_output_json.php | |
| | | | program/include/rcmail_output_json.php | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2008-2012, The Roundcube Dev Team | |
| | |
| | | +-----------------------------------------------------------------------+ |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * View class to produce JSON responses |
| | | * |
| | | * @package Core |
| | | * @package Webmail |
| | | * @subpackage View |
| | | */ |
| | | class rcmail_output_json extends rcmail_output |
| | | { |
| | | protected $texts = array(); |
| | | protected $commands = array(); |
| | | protected $texts = array(); |
| | | protected $commands = array(); |
| | | protected $callbacks = array(); |
| | | protected $message = null; |
| | | protected $message = null; |
| | | |
| | | public $type = 'js'; |
| | | public $type = 'js'; |
| | | public $ajax_call = true; |
| | | |
| | | |
| | |
| | | else |
| | | $name = $this->config->get('product_name'); |
| | | |
| | | $this->command('set_pagetitle', empty($name) ? $title : $name.' :: '.$title); |
| | | $this->command('set_pagetitle', empty($name) ? $title : $name . ' :: ' . $title); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Register a template object handler |
| | |
| | | // ignore |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Register a list of template object handlers |
| | | * |
| | |
| | | { |
| | | // ignore |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Call a client method |
| | |
| | | $this->commands[] = $cmd; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Add a localized label to the client environment |
| | | */ |
| | |
| | | $this->texts[$name] = $this->app->gettext($name); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Invoke display_message command |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Delete all stored env variables and commands |
| | | */ |
| | | public function reset() |
| | | { |
| | | parent::reset(); |
| | | $this->texts = array(); |
| | | $this->texts = array(); |
| | | $this->commands = array(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Redirect to a certain url |
| | |
| | | exit; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Send an AJAX response to the client. |
| | | */ |
| | |
| | | exit; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Show error page and terminate script execution |
| | | * |
| | |
| | | */ |
| | | public function raise_error($code, $message) |
| | | { |
| | | if ($code == 403) { |
| | | header('HTTP/1.1 403 Forbidden'); |
| | | die("Invalid Request"); |
| | | } |
| | | |
| | | $this->show_message("Application Error ($code): $message", 'error'); |
| | | $this->remote_response(); |
| | | exit; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Send an AJAX response with executable JS code |
| | |
| | | if (!empty($this->callbacks)) |
| | | $response['callbacks'] = $this->callbacks; |
| | | |
| | | // trigger generic hook where plugins can put additional content to the response |
| | | $hook = $this->app->plugins->exec_hook("render_response", array('response' => $response)); |
| | | |
| | | // save some memory |
| | | $response = $hook['response']; |
| | | unset($hook['response']); |
| | | |
| | | echo self::json_serialize($response); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return executable javascript code for all registered commands |