📄 func.inc
字号:
$framename = $attrib['id']; $out = sprintf('<iframe name="%s"%s></iframe>'."\n", $framename, $attrib_str); $OUTPUT->set_env('contentframe', $framename); $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif'); return $out; }/** * */function rcmail_messagecount_display($attrib) { global $IMAP, $OUTPUT; if (!$attrib['id']) $attrib['id'] = 'rcmcountdisplay'; $OUTPUT->add_gui_object('countdisplay', $attrib['id']); // allow the following attributes to be added to the <span> tag $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); $out = '<span' . $attrib_str . '>'; $out .= rcmail_get_messagecount_text(); $out .= '</span>'; return $out; }/** * */function rcmail_quota_display($attrib) { global $OUTPUT, $COMM_PATH; if (!$attrib['id']) $attrib['id'] = 'rcmquotadisplay'; if(isset($attrib['display'])) $_SESSION['quota_display'] = $attrib['display']; $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); // allow the following attributes to be added to the <span> tag $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display')); $out = '<span' . $attrib_str . '>'; $out .= rcmail_quota_content(); $out .= '</span>'; return $out; }/** * */function rcmail_quota_content($quota=NULL) { global $IMAP, $COMM_PATH; $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; if (is_array($quota) && !empty($quota['used']) && !empty($quota['total'])) { if (!isset($quota['percent'])) $quota['percent'] = $quota['used'] / $quota['total']; } elseif (!$IMAP->get_capability('QUOTA')) return rcube_label('unknown'); else $quota = $IMAP->get_quota(); if ($quota) { $quota_text = sprintf('%s / %s (%.0f%%)', show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024), $quota['percent']); // show quota as image (by Brett Patterson) if ($display == 'image' && function_exists('imagegif')) { $attrib = array('width' => 100, 'height' => 14); $quota_text = sprintf('<img src="./bin/quotaimg.php?u=%s&q=%d&w=%d&h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', $quota['used'], $quota['total'], $attrib['width'], $attrib['height'], $attrib['width'], $attrib['height'], $quota_text, show_bytes($quota["used"] * 1024), show_bytes($quota["total"] * 1024)); } } else $quota_text = rcube_label('unlimited'); return $quota_text; }/** * */function rcmail_get_messagecount_text($count=NULL, $page=NULL) { global $IMAP, $MESSAGE; if (isset($MESSAGE->index)) { return rcube_label(array('name' => 'messagenrof', 'vars' => array('nr' => $MESSAGE->index+1, 'count' => $count!==NULL ? $count : $IMAP->messagecount()))); } if ($page===NULL) $page = $IMAP->list_page; $start_msg = ($page-1) * $IMAP->page_size + 1; $max = $count!==NULL ? $count : $IMAP->messagecount(); if ($max==0) $out = rcube_label('mailboxempty'); else $out = rcube_label(array('name' => 'messagesfromto', 'vars' => array('from' => $start_msg, 'to' => min($max, $start_msg + $IMAP->page_size - 1), 'count' => $max))); return Q($out); }/** * Convert the given message part to proper HTML * which can be displayed the message view * * @param object rcube_message_part Message part * @param bool True if external objects (ie. images ) are allowed * @param bool True if part should be converted to plaintext * @return string Formatted HTML string */function rcmail_print_body($part, $safe=false, $plain=false){ global $REMOTE_OBJECTS; // convert html to text/plain if ($part->ctype_secondary == 'html' && $plain) { $txt = new html2text($part->body, false, true); $body = $txt->get_text(); $part->ctype_secondary = 'plain'; } // text/html else if ($part->ctype_secondary == 'html') { // charset was converted to UTF-8 in rcube_imap::get_message_part() -> change charset specification in HTML accordingly $html = $part->body; if(preg_match('/(\s+content=[\'"]\w+\/\w+;\s+charset)=([a-z0-9-]+)/i', $html)) $html = preg_replace('/(\s+content=[\'"]\w+\/\w+;\s+charset)=([a-z0-9-]+)/i', '\\1='.RCMAIL_CHARSET, $html); else $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '</head>')), 0); // clean HTML with washhtml by Frederic Motte $body = washtml::wash($html, array( 'show_washed' => false, 'allow_remote' => $safe, 'blocked_src' => "./program/blocked.gif", 'charset' => RCMAIL_CHARSET, 'cid_map' => $part->replaces, ), $full_inline); $REMOTE_OBJECTS = !$full_inline; return $body; } // text/enriched else if ($part->ctype_secondary=='enriched') { $part->ctype_secondary = 'html'; return Q(enriched_to_html($body), 'show'); } else $body = $part->body; /**** assert plaintext ****/ // make links and email-addresses clickable $convert_patterns = $convert_replaces = $replace_strings = array(); $url_chars = 'a-z0-9_\-\+\*\$\/&%=@#:;'; $url_chars_within = '\?\.~,!'; $convert_patterns[] = "/([\w]+):\/\/([a-z0-9\-\.]+[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/ie"; $convert_replaces[] = "rcmail_str_replacement('<a href=\"\\1://\\2\" target=\"_blank\">\\1://\\2</a>', \$replace_strings)"; $convert_patterns[] = "/([^\/:]|\s)(www\.)([a-z0-9\-]{2,}[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/ie"; $convert_replaces[] = "rcmail_str_replacement('\\1<a href=\"http://\\2\\3\" target=\"_blank\">\\2\\3</a>', \$replace_strings)"; $convert_patterns[] = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/ie'; $convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)"; // if ($part->ctype_parameters['format'] != 'flowed')// $body = wordwrap(trim($body), 80); // search for patterns like links and e-mail addresses $body = preg_replace($convert_patterns, $convert_replaces, $body); // split body into single lines $a_lines = preg_split('/\r?\n/', $body); $quote_level = 0; // colorize quoted parts for ($n=0; $n < sizeof($a_lines); $n++) { $line = $a_lines[$n]; $quotation = ''; $q = 0; if (preg_match('/^(>+\s*)+/', $line, $regs)) { $q = strlen(preg_replace('/\s/', '', $regs[0])); $line = substr($line, strlen($regs[0])); if ($q > $quote_level) $quotation = str_repeat('<blockquote>', $q - $quote_level); else if ($q < $quote_level) $quotation = str_repeat("</blockquote>", $quote_level - $q); } else if ($quote_level > 0) $quotation = str_repeat("</blockquote>", $quote_level); $quote_level = $q; $a_lines[$n] = $quotation . Q($line, 'replace', false); // htmlquote plaintext } // insert the links for urls and mailtos $body = preg_replace("/##string_replacement\{([0-9]+)\}##/e", "\$replace_strings[\\1]", join("\n", $a_lines)); return "<div class=\"pre\">".$body."\n</div>"; }/** * add a string to the replacement array and return a replacement string */function rcmail_str_replacement($str, &$rep) { static $count = 0; $rep[$count] = stripslashes($str); return "##string_replacement{".($count++)."}##"; }/** * return table with message headers */function rcmail_message_headers($attrib, $headers=NULL) { global $IMAP, $OUTPUT, $MESSAGE; static $sa_attrib; // keep header table attrib if (is_array($attrib) && !$sa_attrib) $sa_attrib = $attrib; else if (!is_array($attrib) && is_array($sa_attrib)) $attrib = $sa_attrib; if (!isset($MESSAGE)) return FALSE; // get associative array of headers object if (!$headers) $headers = is_object($MESSAGE->headers) ? get_object_vars($MESSAGE->headers) : $MESSAGE->headers; // add empty subject if none exsists if (empty($headers['subject'])) $headers['subject'] = rcube_label('nosubject'); $header_count = 0; // allow the following attributes to be added to the <table> tag $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); $out = '<table' . $attrib_str . ">\n"; // show these headers $standard_headers = array('subject', 'from', 'organization', 'to', 'cc', 'bcc', 'reply-to', 'date'); foreach ($standard_headers as $hkey) { if (!$headers[$hkey]) continue; if ($hkey=='date' && !empty($headers[$hkey])) $header_value = format_date($headers[$hkey]); else if (in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to'))) $header_value = Q(rcmail_address_string($headers[$hkey], NULL, $attrib['addicon']), 'show'); else $header_value = Q($IMAP->decode_header($headers[$hkey])); $out .= "\n<tr>\n"; $out .= '<td class="header-title">'.Q(rcube_label($hkey)).": </td>\n"; $out .= '<td class="'.$hkey.'" width="90%">'.$header_value."</td>\n</tr>"; $header_count++; } $out .= "\n</table>\n\n"; return $header_count ? $out : ''; }/** * Handler for the 'messagebody' GUI object * * @param array Named parameters * @return string HTML content showing the message body */function rcmail_message_body($attrib) { global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $REMOTE_OBJECTS; if (!is_array($MESSAGE->parts) && empty($MESSAGE->body)) return ''; if (!$attrib['id']) $attrib['id'] = 'rcmailMsgBody'; $safe_mode = $MESSAGE->is_safe || intval($_GET['_safe']); $out = ''; $header_attrib = array(); foreach ($attrib as $attr => $value) if (preg_match('/^headertable([a-z]+)$/i', $attr, $regs)) $header_attrib[$regs[1]] = $value; if (!empty($MESSAGE->parts)) { foreach ($MESSAGE->parts as $i => $part) { if ($part->type == 'headers') $out .= rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : NULL, $part->headers); else if ($part->type == 'content') { if (empty($part->ctype_parameters) || empty($part->ctype_parameters['charset'])) $part->ctype_parameters['charset'] = $MESSAGE->headers->charset; // fetch part if not available if (!isset($part->body)) $part->body = $MESSAGE->get_part_content($part->mime_id); $body = rcmail_print_body($part, $safe_mode, !$CONFIG['prefer_html']); if ($part->ctype_secondary == 'html') $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'])); else $out .= html::div('message-part', $body); } } } else $out .= html::div('message-part', html::div('pre', Q($MESSAGE->body))); $ctype_primary = strtolower($MESSAGE->structure->ctype_primary); $ctype_secondary = strtolower($MESSAGE->structure->ctype_secondary); // list images after mail body if (get_boolean($attrib['showimages']) && $ctype_primary == 'multipart' && !empty($MESSAGE->attachments) && !strstr($message_body, '<html')) { foreach ($MESSAGE->attachments as $attach_prop) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -