summaryrefslogtreecommitdiff
path: root/roundcubemail/program/include/main.inc
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-04-29 06:44:57 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-04-29 06:44:57 +0000
commit1b71e625981a1b32ab097b228306308ae7d02efe (patch)
treea3e7b187f6e8ee35babb93321027a6db43146118 /roundcubemail/program/include/main.inc
parented545a3f60de5139e2b1bdad1fd31af3d67b09cd (diff)
- improved messages list performance - patch from Justin Heesemann
git-svn-id: https://svn.roundcube.net/trunk@1341 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/main.inc')
-rw-r--r--roundcubemail/program/include/main.inc17
1 files changed, 12 insertions, 5 deletions
diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc
index d61159565..853ca686c 100644
--- a/roundcubemail/program/include/main.inc
+++ b/roundcubemail/program/include/main.inc
@@ -1060,8 +1060,15 @@ function rcube_charset_convert($str, $from, $to=NULL)
function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
{
global $OUTPUT_TYPE, $OUTPUT;
- static $html_encode_arr, $js_rep_table, $xml_rep_table;
+ static $html_encode_arr = false;
+ static $js_rep_table = false;
+ static $xml_rep_table = false;
+ $charset = $OUTPUT->get_charset();
+ $is_iso_8859_1 = false;
+ if ($charset == 'ISO-8859-1') {
+ $is_iso_8859_1 = true;
+ }
if (!$enctype)
$enctype = $GLOBALS['OUTPUT_TYPE'];
@@ -1102,7 +1109,7 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
return rawurlencode($str);
// if the replace tables for XML and JS are not yet defined
- if (!$js_rep_table)
+ if ($js_rep_table===false)
{
$js_rep_table = $xml_rep_table = array();
$xml_rep_table['&'] = '&amp;';
@@ -1111,7 +1118,7 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
{
$xml_rep_table[Chr($c)] = "&#$c;";
- if ($OUTPUT->get_charset()=='ISO-8859-1')
+ if ($is_iso_8859_1)
$js_rep_table[Chr($c)] = sprintf("\\u%04x", $c);
}
@@ -1125,8 +1132,8 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
// encode for javascript use
if ($enctype=='js')
{
- if ($OUTPUT->get_charset()!='UTF-8')
- $str = rcube_charset_convert($str, RCMAIL_CHARSET, $OUTPUT->get_charset());
+ if ($charset!='UTF-8')
+ $str = rcube_charset_convert($str, RCMAIL_CHARSET,$charset);
return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), addslashes(strtr($str, $js_rep_table)));
}