From 10da75f3645ff2121bbaf9d603f2e1465eddab78 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Tue, 27 Nov 2012 05:17:37 -0500
Subject: [PATCH] Move shortcut functions to framework class

---
 program/lib/Roundcube/rcube.php                 |   24 ++++++++++++
 program/include/bc.php                          |    8 ++--
 program/lib/Roundcube/rcube_output_html.php     |    2 
 program/include/rcmail.php                      |   24 ------------
 program/lib/Roundcube/rcube_string_replacer.php |    4 +-
 5 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/program/include/bc.php b/program/include/bc.php
index 4c8f8a4..b589135 100644
--- a/program/include/bc.php
+++ b/program/include/bc.php
@@ -84,19 +84,19 @@
     return rcube_output::json_serialize($input);
 }
 
-function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
+function rep_specialchars_output($str, $enctype='', $mode='', $newlines=true)
 {
     return rcube_utils::rep_specialchars_output($str, $enctype, $mode, $newlines);
 }
 
-function Q($str, $mode='strict', $newlines=TRUE)
+function Q($str, $mode='strict', $newlines=true)
 {
-    return rcmail::Q($str, $mode, $newlines);
+    return rcube_utils::rep_specialchars_output($str, 'html', $mode, $newlines);
 }
 
 function JQ($str)
 {
-    return rcmail::JQ($str);
+    return rcube_utils::rep_specialchars_output($str, 'js');
 }
 
 function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL)
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index cdafc5e..3a8c62c 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -2029,30 +2029,6 @@
 
 
     /**
-     * Quote a given string.
-     * Shortcut function for rcube_utils::rep_specialchars_output()
-     *
-     * @return string HTML-quoted string
-     */
-    public static function Q($str, $mode = 'strict', $newlines = true)
-    {
-        return rcube_utils::rep_specialchars_output($str, 'html', $mode, $newlines);
-    }
-
-
-    /**
-     * Quote a given string for javascript output.
-     * Shortcut function for rcube_utils::rep_specialchars_output()
-     *
-     * @return string JS-quoted string
-     */
-    public static function JQ($str)
-    {
-        return rcube_utils::rep_specialchars_output($str, 'js');
-    }
-
-
-    /**
      * Returns real size (calculated) of the message part
      *
      * @param rcube_message_part  Message part
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index 1ce6241..c3aa8ff 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -894,6 +894,30 @@
 
 
     /**
+     * Quote a given string.
+     * Shortcut function for rcube_utils::rep_specialchars_output()
+     *
+     * @return string HTML-quoted string
+     */
+    public static function Q($str, $mode = 'strict', $newlines = true)
+    {
+        return rcube_utils::rep_specialchars_output($str, 'html', $mode, $newlines);
+    }
+
+
+    /**
+     * Quote a given string for javascript output.
+     * Shortcut function for rcube_utils::rep_specialchars_output()
+     *
+     * @return string JS-quoted string
+     */
+    public static function JQ($str)
+    {
+        return rcube_utils::rep_specialchars_output($str, 'js');
+    }
+
+
+    /**
      * Construct shell command, execute it and return output as string.
      * Keywords {keyword} are replaced with arguments
      *
diff --git a/program/lib/Roundcube/rcube_output_html.php b/program/lib/Roundcube/rcube_output_html.php
index 6c9dfdd..f861ff9 100644
--- a/program/lib/Roundcube/rcube_output_html.php
+++ b/program/lib/Roundcube/rcube_output_html.php
@@ -843,7 +843,7 @@
                             break;
                         case 'javascript':
                         case 'js':
-                            $label = rcmail::JQ($label);
+                            $label = rcube::JQ($label);
                             break;
                         default:
                             $label = html::quote($label);
diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php
index 9af6b33..0467b86 100644
--- a/program/lib/Roundcube/rcube_string_replacer.php
+++ b/program/lib/Roundcube/rcube_string_replacer.php
@@ -96,7 +96,7 @@
       $i = $this->add($prefix . html::a(array(
           'href' => $url_prefix . $url,
           'target' => '_blank'
-        ), rcmail::Q($url)) . $suffix);
+        ), rcube::Q($url)) . $suffix);
     }
 
     // Return valid link for recognized schemes, otherwise, return the unmodified string for unrecognized schemes.
@@ -116,7 +116,7 @@
 
     $i = $this->add(html::a(array(
         'href' => 'mailto:' . $href,
-        'onclick' => "return ".rcmail::JS_OBJECT_NAME.".command('compose','".rcmail::JQ($href)."',this)",
+        'onclick' => "return ".rcmail::JS_OBJECT_NAME.".command('compose','".rcube::JQ($href)."',this)",
       ), rcmail::Q($href)) . $suffix);
 
     return $i >= 0 ? $this->get_replacement($i) : '';

--
Gitblit v1.9.1