| | |
| | | var $scripts_path = ''; |
| | | var $script_files = 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"; |
| | |
| | | |
| | | } |
| | | |
| | | function set_charset($charset) |
| | | { |
| | | $this->charset = $charset; |
| | | } |
| | | |
| | | |
| | | function write($templ='', $base_path='') |
| | | { |
| | |
| | | // replace specialchars in content |
| | | $__page_title = rep_specialchars_output($this->title, 'html', 'show', FALSE); |
| | | $__page_header = $__page_body = $__page_footer = ''; |
| | | |
| | | |
| | | // include meta tag with charset |
| | | if (!empty($this->charset)) |
| | | $__page_header = '<meta http-equiv="content-type" content="text/html; charset='.$this->charset.'" />'."\n";; |
| | | |
| | | |
| | | // definition of the code to be placed in the document header and footer |
| | |
| | | // provide details about the client's browser |
| | | function rcube_browser() |
| | | { |
| | | global $HTTP_USER_AGENT; |
| | | $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; |
| | | |
| | | $bw['ver'] = 0; |
| | | $bw['win'] = stristr($HTTP_USER_AGENT, 'win'); |
| | |
| | | // get text in the desired language from the language file |
| | | function rcube_label($attrib) |
| | | { |
| | | global $sess_user_lang, $INSTALL_PATH; |
| | | static $sa_text_data, $s_language; |
| | | global $sess_user_lang, $INSTALL_PATH, $OUTPUT; |
| | | static $sa_text_data, $s_language, $utf8_decode; |
| | | |
| | | // extract attributes |
| | | if (is_string($attrib)) |
| | |
| | | $sa_text_data = array_merge($sa_text_data, $labels); |
| | | if (is_array($messages)) |
| | | $sa_text_data = array_merge($sa_text_data, $messages); |
| | | } |
| | | |
| | | if (isset($utf8_decoding) && $utf8_decoding==TRUE) |
| | | { |
| | | @include_once('lib/utf8.inc'); |
| | | $utf8_decode = TRUE; |
| | | } |
| | | |
| | | $s_language = $sess_user_lang; |
| | |
| | | if ($text=='') |
| | | $text = $a_text_item['single']; |
| | | |
| | | |
| | | // replace vars in text |
| | | if (is_array($attrib['vars'])) |
| | | { |
| | |
| | | $text |
| | | EOF; |
| | | "); |
| | | |
| | | |
| | | // perform utf-8 decoding |
| | | if ($utf8_decode && function_exists('utf8ToUnicodeEntities')) |
| | | $text = utf8ToUnicodeEntities($text); |
| | | else if ($utf8_decode) |
| | | $OUTPUT->set_charset('UTF-8'); |
| | | |
| | | |
| | | // format output |
| | |
| | | // replace specials characters to a specific encoding type |
| | | function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE) |
| | | { |
| | | global $OUTPUT_TYPE; |
| | | global $OUTPUT_TYPE, $CHARSET; |
| | | static $html_encode_arr, $js_rep_table, $rtf_rep_table, $xml_rep_table; |
| | | |
| | | if (!$enctype) |
| | |
| | | { |
| | | if (!$html_encode_arr) |
| | | { |
| | | $html_encode_arr = get_html_translation_table(HTML_ENTITIES); |
| | | $html_encode_arr["?"] = '–'; |
| | | $html_encode_arr[chr(128)] = '€'; |
| | | if ($CHARSET=='ISO-8859-1') |
| | | { |
| | | $html_encode_arr = get_html_translation_table(HTML_ENTITIES); |
| | | $html_encode_arr[chr(128)] = '€'; |
| | | } |
| | | else |
| | | $html_encode_arr = get_html_translation_table(HTML_SPECIALCHARS); |
| | | |
| | | unset($html_encode_arr['?']); |
| | | unset($html_encode_arr['&']); |
| | | } |
| | | |
| | | |
| | | $ltpos = strpos($str, '<'); |
| | | $encode_arr = $html_encode_arr; |
| | | |
| | |
| | | // if the replace tables for RTF, XML and JS are not yet defined |
| | | if (!$js_rep_table) |
| | | { |
| | | $js_rep_table = $rtf_rep_table = $xml_rep_table = array(); |
| | | |
| | | for ($c=160; $c<256; $c++) // can be increased to support more charsets |
| | | { |
| | | $hex = dechex($c); |
| | | $js_rep_table[Chr($c)] = sprintf("\u%s%s", str_repeat('0', 4-strlen($hex)), $hex); |
| | | $rtf_rep_table[Chr($c)] = "\\'$hex"; |
| | | $xml_rep_table[Chr($c)] = "&#$c;"; |
| | | |
| | | if ($CHARSET=='ISO-8859-1') |
| | | $js_rep_table[Chr($c)] = sprintf("\u%s%s", str_repeat('0', 4-strlen($hex)), $hex); |
| | | } |
| | | |
| | | $js_rep_table['"'] = sprintf("\u%s%s", str_repeat('0', 4-strlen(dechex(34))), dechex(34)); |
| | |
| | | |
| | | // encode for javascript use |
| | | if ($enctype=='js') |
| | | return preg_replace(array("/\r\n/", '/"/', "/'/"), array('\n', '\"', "\'"), strtr($str, $js_rep_table)); |
| | | return preg_replace(array("/\r\n/", '/"/', "/([^\\\])'/"), array('\n', '\"', "$1\'"), strtr($str, $js_rep_table)); |
| | | |
| | | // encode for RTF |
| | | if ($enctype=='rtf') |
| | |
| | | { |
| | | $charset = strtolower($charset); |
| | | |
| | | if (strcasecmp($charset, 'utf-8')==0) |
| | | return utf8_decode($input); |
| | | if ($charset=='utf-8') |
| | | { |
| | | require_once('lib/utf8.inc'); |
| | | return utf8ToUnicodeEntities($input); |
| | | } |
| | | else if ($charset=="koi8-r") |
| | | return convert_cyr_string($input, 'k', 'w'); |
| | | else if ($charset=="iso8859-5") |
| | |
| | | |
| | | |
| | | |
| | | function abbrevate_string($str, $maxlength, $place_holder='...') |
| | | { |
| | | $length = strlen($str); |
| | | $first_part_length = floor($maxlength/2) - strlen($place_holder); |
| | | |
| | | if ($length > $maxlength) |
| | | { |
| | | $second_starting_location = $length - $maxlength + $first_part_length + 1; |
| | | $str = substr($str, 0, $first_part_length) . $place_holder . substr($str, $second_starting_location, $length); |
| | | } |
| | | |
| | | return $str; |
| | | } |
| | | |
| | | |
| | | |
| | | ?> |