From 5c52d06844779efbf4034663f5e68db10619b367 Mon Sep 17 00:00:00 2001 From: svncommit <devs@roundcube.net> Date: Sun, 22 Oct 2006 02:45:54 -0400 Subject: [PATCH] Updated Russian localization --- program/include/rcube_shared.inc | 141 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 119 insertions(+), 22 deletions(-) diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc index 77753f5..11af482 100644 --- a/program/include/rcube_shared.inc +++ b/program/include/rcube_shared.inc @@ -28,12 +28,15 @@ var $scripts_path = ''; var $script_files = array(); + var $external_scripts = array(); var $scripts = array(); var $charset = 'ISO-8859-1'; var $script_tag_file = "<script type=\"text/javascript\" src=\"%s%s\"></script>\n"; var $script_tag = "<script type=\"text/javascript\">\n<!--\n%s\n\n//-->\n</script>\n"; - + var $default_template = "<html>\n<head><title></title></head>\n<body></body>\n</html>"; + var $tag_format_external_script = "<script type=\"text/javascript\" src=\"%s\"></script>\n"; + var $title = ''; var $header = ''; var $footer = ''; @@ -68,20 +71,30 @@ $this->script_files[$position][] = $file; } - + function include_external_script($script_location, $position='head') + { + if (!is_array($this->external_scripts[$position])) + { + $this->external_scripts[$position] = array(); + } + + $this->external_scripts[$position][] = $script_location; + } + function add_script($script, $position='head') { if (!isset($this->scripts[$position])) - $this->scripts[$position] = ''; - - $this->scripts[$position] .= "\n$script"; + $this->scripts[$position] = "\n$script"; + else + $this->scripts[$position] .= "\n$script"; } - function set_title() + function set_title($t) { - + $this->title = $t; } + function set_charset($charset) { @@ -95,17 +108,26 @@ $MBSTRING = FALSE; } } - + function get_charset() { return $this->charset; } + function reset() + { + $this->css = new rcube_css(); + $this->script_files = array(); + $this->scripts = array(); + $this->title = ''; + } + + function write($templ='', $base_path='') { - $output = trim($templ); - + $output = empty($templ) ? $this->default_template : trim($templ); + // set default page title if (!strlen($this->title)) $this->title = 'RoundCube Mail'; @@ -128,19 +150,27 @@ foreach ($this->script_files['head'] as $file) $__page_header .= sprintf($this->script_tag_file, $this->scripts_path, $file); + if (is_array($this->external_scripts['head'])) + { + foreach ($this->external_scripts['head'] as $xscript) + { + $__page_header .= sprintf($this->tag_format_external_script, $xscript); + } + } + if (strlen($this->scripts['head'])) $__page_header .= sprintf($this->script_tag, $this->scripts['head']); if (is_array($this->script_files['foot'])) + { foreach ($this->script_files['foot'] as $file) $__page_footer .= sprintf($this->script_tag_file, $this->scripts_path, $file); + } if (strlen($this->scripts['foot'])) $__page_footer .= sprintf($this->script_tag, $this->scripts['foot']); - $__page_header .= $this->css->show(); - // find page header if($hpos = strpos(strtolower($output), '</head>')) @@ -181,8 +211,12 @@ // find and add page footer - if(($fpos = strpos(strtolower($output), '</body>')) || ($fpos = strpos(strtolower($output), '</html>'))) + $output_lc = strtolower($output); + if(($fpos = strrpos($output_lc, '</body>')) || + ($fpos = strrpos($output_lc, '</html>'))) + { $output = substr($output,0,$fpos) . "$__page_footer\n" . substr($output,$fpos,strlen($output)); + } else $output .= "\n$__page_footer"; @@ -191,8 +225,9 @@ $__page_header = $__page_footer = ''; - // correct absolute pathes in images and other tags + // correct absolute paths in images and other tags $output = preg_replace('/(src|href|background)=(["\']?)(\/[a-z0-9_\-]+)/Ui', "\\1=\\2$base_path\\3", $output); + $output = str_replace('$__skin_path', $base_path, $output); print rcube_charset_convert($output, 'UTF-8', $this->charset); } @@ -842,9 +877,9 @@ if (isset($this->attrib['value'])) unset($this->attrib['value']); - if (strlen($value)) + if (strlen($value) && !isset($this->attrib['mce_editable'])) $value = rep_specialchars_output($value, 'html', 'replace', FALSE); - + // return final tag return sprintf('<%s%s>%s</%s>%s', $this->_conv_case('textarea', 'tag'), @@ -1221,7 +1256,7 @@ if (!ereg("^[_a-zA-Z]{1}[_a-zA-Z0-9]*$", $key) /* || is_js_reserved_word($key) */) $key = "'$key'"; - if (!is_array($value)) + if (!is_array($value) && is_string($value)) { $value = str_replace("\r\n", '\n', $value); $value = str_replace("\n", '\n', $value); @@ -1232,6 +1267,11 @@ { if ($type=='string') $is_string = true; + else if (($type == 'mixed' && is_bool($value)) || $type == 'bool') + { + $is_string = false; + $value = $value ? "true" : "false"; + } else if ((($type=='mixed' && is_numeric($value)) || $type=='int') && strlen($value)<16) // js interprets numbers with digits >15 as ...e+... $is_string = FALSE; else @@ -1258,7 +1298,9 @@ } } else + { return $arr; + } } @@ -1287,12 +1329,25 @@ } -function show_bytes($numbytes) +// create a human readable string for a number of bytes +function show_bytes($bytes) { - if ($numbytes > 1024) - return sprintf('%d KB', round($numbytes/1024)); + if ($bytes > 1073741824) + { + $gb = $bytes/1073741824; + $str = sprintf($gb>=10 ? "%d GB" : "%.1f GB", $gb); + } + else if ($bytes > 1048576) + { + $mb = $bytes/1048576; + $str = sprintf($mb>=10 ? "%d MB" : "%.1f MB", $mb); + } + else if ($bytes > 1024) + $str = sprintf("%d KB", round($bytes/1024)); else - return sprintf('%d B', $numbytes); + $str = sprintf('%d B', $bytes); + + return $str; } @@ -1333,7 +1388,8 @@ } - +// replace the middle part of a string with ... +// if it is longer than the allowed length function abbrevate_string($str, $maxlength, $place_holder='...') { $length = strlen($str); @@ -1348,6 +1404,20 @@ return $str; } + +// make sure the string ends with a slash +function slashify($str) + { + return unslashify($str).'/'; + } + + +// remove slash at the end of the string +function unslashify($str) + { + return preg_replace('/\/$/', '', $str); + } + // delete all files within a folder function clear_directory($dir_path) @@ -1397,4 +1467,31 @@ } +/** + * strrstr + * + * return the last occurence of a string in another string + * @param haystack string string in which to search + * @param needle string string for which to search + * @return index of needle within haystack, or false if not found + */ +function strrstr($haystack, $needle) + { + $pver = phpversion(); + if ($pver[0] >= 5) + { + return strrpos($haystack, $needle); + } + else + { + $index = strpos(strrev($haystack), strrev($needle)); + if($index === false) { + return false; + } + $index = strlen($haystack) - strlen($needle) - $index; + return $index; + } + } + + ?> -- Gitblit v1.9.1