From c719f3c1e06c00fa4723f2f1298b3c94a1bec7e7 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Fri, 20 Jun 2008 06:40:01 -0400 Subject: [PATCH] Store compose parameters in session and redirect to a unique URL --- program/include/rcube_json_output.php | 37 +++++++++++++++++++++++++++---------- 1 files changed, 27 insertions(+), 10 deletions(-) diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php index 6bf4f8a..2f65c19 100644 --- a/program/include/rcube_json_output.php +++ b/program/include/rcube_json_output.php @@ -34,17 +34,15 @@ private $texts = array(); private $commands = array(); - public $task = ''; public $ajax_call = true; /** * Constructor */ - public function __construct(&$config, $task) + public function __construct($task) { - $this->task = $task; - $this->config = $config; + $this->config = rcmail::get_instance()->config; } @@ -60,11 +58,14 @@ } /** - * @ignore + * Issue command to set page title + * + * @param string New page title */ public function set_pagetitle($title) { - // ignore + $name = $this->config->get('product_name'); + $this->command('set_pagetitle', JQ(empty($name) ? $title : $name.' :: '.$title)); } /** @@ -130,7 +131,7 @@ { $arg_list = func_get_args(); foreach ($arg_list as $i => $name) { - $this->texts[$name] = rcube::gettext($name); + $this->texts[$name] = rcube_label($name); } } @@ -147,7 +148,7 @@ { $this->command( 'display_message', - rcube::gettext(array('name' => $message, 'vars' => $vars)), + rcube_label(array('name' => $message, 'vars' => $vars)), $type ); } @@ -160,6 +161,19 @@ $this->env = array(); $this->texts = array(); $this->commands = array(); + } + + /** + * Redirect to a certain url + * + * @param mixed Either a string with the action or url parameters as key-value pairs + * @see rcmail::url() + */ + public function redirect($p = array(), $delay = 0) + { + $location = rcmail::get_instance()->url($p); + $this->remote_response("window.setTimeout(\"location.href='{$location}'\", $delay);"); + exit; } @@ -211,7 +225,10 @@ */ private function get_js_commands() { - $out = 'this.set_env('.json_serialize($this->env).");\n"; + $out = ''; + + if (sizeof($this->env)) + $out .= 'this.set_env('.json_serialize($this->env).");\n"; foreach($this->texts as $name => $text) { $out .= sprintf("this.add_label('%s', '%s');\n", $name, JQ($text)); @@ -229,7 +246,7 @@ implode(',', $args) ); } - + return $out; } } -- Gitblit v1.9.1