From e019f2d0f2dc2fbfa345ab5d7ae85e67bfdd76b8 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 25 Sep 2010 09:03:53 -0400
Subject: [PATCH] - s/RoundCube/Roundcube/

---
 program/include/rcube_json_output.php |   67 ++++++++++++++++++++-------------
 1 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php
index 2fbf9c0..9700472 100644
--- a/program/include/rcube_json_output.php
+++ b/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$
 
 */
 
@@ -29,25 +29,28 @@
 class rcube_json_output
 {
     private $config;
-    private $charset = 'UTF-8';
+    private $charset = RCMAIL_CHARSET;
     private $env = array();
     private $texts = array();
     private $commands = array();
+    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
      *
@@ -58,7 +61,8 @@
     {
         $this->env[$name] = $value;
     }
-    
+
+
     /**
      * Issue command to set page title
      *
@@ -67,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
@@ -102,6 +107,7 @@
         // ignore
     }
 
+
     /**
      * Register a list of template object handlers
      *
@@ -112,8 +118,8 @@
     {
         // ignore
     }
-    
-    
+
+
     /**
      * Call a client method
      *
@@ -122,7 +128,12 @@
      */
     public function command()
     {
-        $this->commands[] = func_get_args();
+        $cmd = func_get_args();
+        
+        if (strpos($cmd[0], 'plugin.') === 0)
+          $this->callbacks[] = $cmd;
+        else
+          $this->commands[] = $cmd;
     }
     
     
@@ -139,7 +150,7 @@
             $this->texts[$name] = rcube_label($name);
         }
     }
-    
+
 
     /**
      * Invoke display_message command
@@ -161,7 +172,8 @@
             );
         }
     }
-    
+
+
     /**
      * Delete all stored env variables and commands
      */
@@ -171,7 +183,8 @@
         $this->texts = array();
         $this->commands = array();
     }
-    
+
+
     /**
      * Redirect to a certain url
      *
@@ -212,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
@@ -222,18 +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 response code
+        // send function calls
         $response['exec'] = $this->get_js_commands() . $add;
+        
+        if (!empty($this->callbacks))
+            $response['callbacks'] = $this->callbacks;
 
         echo json_serialize($response);
     }
-    
-    
+
+
     /**
      * Return executable javascript code for all registered commands
      *
@@ -242,7 +257,7 @@
     private function get_js_commands()
     {
         $out = '';
-        
+
         foreach ($this->commands as $i => $args) {
             $method = array_shift($args);
             foreach ($args as $i => $arg) {
@@ -259,5 +274,3 @@
         return $out;
     }
 }
-
-

--
Gitblit v1.9.1