diff options
author | alecpl <alec@alec.pl> | 2011-05-13 17:31:09 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2011-05-13 17:31:09 +0000 |
commit | bff88dcb94a95d53ac37d8ac3c2b86f512b5869a (patch) | |
tree | 7505d48cb671fd1dd0f27e0db8c1e79eee6bacbf /program/include | |
parent | ba9c7b40f0dfcadf1d5711246e7b332ff7a60787 (diff) |
- Apply fixes from trunk (up to r4756)
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/main.inc | 52 | ||||
-rw-r--r-- | program/include/rcube_imap.php | 12 | ||||
-rwxr-xr-x | program/include/rcube_template.php | 40 |
3 files changed, 48 insertions, 56 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index 3ac26dc17..72a190595 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -1289,12 +1289,12 @@ function rcmail_mailbox_list($attrib) { global $RCMAIL; static $a_mailboxes; - + $attrib += array('maxlength' => 100, 'realnames' => false); // add some labels to client $RCMAIL->output->add_label('purgefolderconfirm', 'deletemessagesconfirm'); - + $type = $attrib['type'] ? $attrib['type'] : 'ul'; unset($attrib['type']); @@ -1303,7 +1303,7 @@ function rcmail_mailbox_list($attrib) // get mailbox list $mbox_name = $RCMAIL->imap->get_mailbox_name(); - + // build the folders tree if (empty($a_mailboxes)) { // get mailbox list @@ -1318,20 +1318,20 @@ function rcmail_mailbox_list($attrib) // allow plugins to alter the folder tree or to localize folder names $hook = $RCMAIL->plugins->exec_hook('render_mailboxlist', array('list' => $a_mailboxes, 'delimiter' => $delimiter)); - if ($type=='select') { + if ($type == 'select') { $select = new html_select($attrib); - + // add no-selection option if ($attrib['noselection']) - $select->add(rcube_label($attrib['noselection']), '0'); - + $select->add(rcube_label($attrib['noselection']), ''); + rcmail_render_folder_tree_select($hook['list'], $mbox_name, $attrib['maxlength'], $select, $attrib['realnames']); $out = $select->show(); } else { $js_mailboxlist = array(); $out = html::tag('ul', $attrib, rcmail_render_folder_tree_html($hook['list'], $mbox_name, $js_mailboxlist, $attrib), html::$common_attrib); - + $RCMAIL->output->add_gui_object('mailboxlist', $attrib['id']); $RCMAIL->output->set_env('mailboxes', $js_mailboxlist); $RCMAIL->output->set_env('collapsed_folders', $RCMAIL->config->get('collapsed_folders')); @@ -1350,7 +1350,7 @@ function rcmail_mailbox_list($attrib) function rcmail_mailbox_select($p = array()) { global $RCMAIL; - + $p += array('maxlength' => 100, 'realnames' => false); $a_mailboxes = array(); @@ -1423,7 +1423,7 @@ function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='') if (strlen($subFolders)) rcmail_build_folder_tree($arrFolders[$currentFolder]['folders'], $subFolders, $delm, $path.$delm); } - + /** * Return html for a structured list <ul> for the mailbox tree @@ -1433,7 +1433,7 @@ function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='') function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, &$jslist, $attrib, $nestLevel=0) { global $RCMAIL, $CONFIG; - + $maxlength = intval($attrib['maxlength']); $realnames = (bool)$attrib['realnames']; $msgcounts = $RCMAIL->imap->get_cache('messagecount'); @@ -1476,15 +1476,15 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, &$jslist, $at $classes[] = 'inbox'; else $classes[] = '_'.asciiwords($folder_class ? $folder_class : strtolower($folder['id']), true); - + $classes[] = $zebra_class; - + if ($folder['id'] == $mbox_name) $classes[] = 'selected'; $collapsed = preg_match('/&'.rawurlencode($folder['id']).'&/', $RCMAIL->config->get('collapsed_folders')); $unread = $msgcounts ? intval($msgcounts[$folder['id']]['UNSEEN']) : 0; - + if ($folder['virtual']) $classes[] = 'virtual'; else if ($unread) @@ -1508,9 +1508,9 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, &$jslist, $at 'style' => "position:absolute", 'onclick' => sprintf("%s.command('collapse-folder', '%s')", JS_OBJECT_NAME, $js_name) ), ' ') : '')); - + $jslist[$folder_id] = array('id' => $folder['id'], 'name' => $foldername, 'virtual' => $folder['virtual']); - + if (!empty($folder['folders'])) { $out .= html::tag('ul', array('style' => ($collapsed ? "display:none;" : null)), rcmail_render_folder_tree_html($folder['folders'], $mbox_name, $jslist, $attrib, $nestLevel+1)); @@ -1530,32 +1530,28 @@ function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, &$jslist, $at * @return string */ function rcmail_render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames=false, $nestLevel=0) - { - $idx = 0; +{ $out = ''; - foreach ($arrFolders as $key=>$folder) - { + + foreach ($arrFolders as $key=>$folder) { if (!$realnames && ($folder_class = rcmail_folder_classname($folder['id']))) $foldername = rcube_label($folder_class); - else - { + else { $foldername = $folder['name']; - + // shorten the folder name to a given length if ($maxlength && $maxlength>1) $foldername = abbreviate_string($foldername, $maxlength); - } + } $select->add(str_repeat(' ', $nestLevel*4) . $foldername, $folder['id']); if (!empty($folder['folders'])) $out .= rcmail_render_folder_tree_select($folder['folders'], $mbox_name, $maxlength, $select, $realnames, $nestLevel+1); - - $idx++; - } + } return $out; - } +} /** diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index e2ab550d5..32e7871d7 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -3564,7 +3564,7 @@ class rcube_imap return $this->conn->setMetadata($mailbox, $entries); } else if ($this->get_capability('ANNOTATEMORE') || $this->get_capability('ANNOTATEMORE2')) { - foreach ($entries as $entry => $value) { + foreach ((array)$entries as $entry => $value) { list($ent, $attr) = $this->md2annotate($entry); $entries[$entry] = array($ent, $attr, $value); } @@ -3597,7 +3597,7 @@ class rcube_imap return $this->conn->deleteMetadata($mailbox, $entries); } else if ($this->get_capability('ANNOTATEMORE') || $this->get_capability('ANNOTATEMORE2')) { - foreach ($entries as $idx => $entry) { + foreach ((array)$entries as $idx => $entry) { list($ent, $attr) = $this->md2annotate($entry); $entries[$idx] = array($ent, $attr, NULL); } @@ -3626,7 +3626,7 @@ class rcube_imap $mailbox = $this->mod_mailbox($mailbox); if ($this->get_capability('METADATA') || - !strlen(($mailbox) && $this->get_capability('METADATA-SERVER')) + (!strlen($mailbox) && $this->get_capability('METADATA-SERVER')) ) { return $this->conn->getMetadata($mailbox, $entries, $options); } @@ -3635,7 +3635,7 @@ class rcube_imap $res = array(); // Convert entry names - foreach ($entries as $entry) { + foreach ((array)$entries as $entry) { list($ent, $attr) = $this->md2annotate($entry); $queries[$attr][] = $ent; } @@ -3656,11 +3656,11 @@ class rcube_imap * Converts the METADATA extension entry name into the correct * entry-attrib names for older ANNOTATEMORE version. * - * @param string Entry name + * @param string $entry Entry name * * @return array Entry-attribute list, NULL if not supported (?) */ - private function md2annotate($name) + private function md2annotate($entry) { if (substr($entry, 0, 7) == '/shared') { return array(substr($entry, 7), 'value.shared'); diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php index 5c69290c5..5e0f4c14f 100755 --- a/program/include/rcube_template.php +++ b/program/include/rcube_template.php @@ -113,7 +113,6 @@ class rcube_template extends rcube_html_page } } - /** * Set page title variable */ @@ -122,7 +121,6 @@ class rcube_template extends rcube_html_page $this->pagetitle = $title; } - /** * Getter for the current page title * @@ -143,7 +141,6 @@ class rcube_template extends rcube_html_page return $title; } - /** * Set skin */ @@ -226,7 +223,6 @@ class rcube_template extends rcube_html_page $this->js_commands[] = $cmd; } - /** * Add a localized label to the client environment */ @@ -241,7 +237,6 @@ class rcube_template extends rcube_html_page } } - /** * Invoke display_message command * @@ -262,7 +257,6 @@ class rcube_template extends rcube_html_page } } - /** * Delete all stored env variables and commands * @@ -282,7 +276,6 @@ class rcube_template extends rcube_html_page parent::reset(); } - /** * Redirect to a certain url * @@ -296,7 +289,6 @@ class rcube_template extends rcube_html_page exit; } - /** * Send the request output to the client. * This will either parse a skin tempalte or send an AJAX response @@ -361,16 +353,15 @@ class rcube_template extends rcube_html_page } /** - * Parse a specific skin template and deliver to stdout - * - * Either returns nothing, or exists hard (exit();) + * Parse a specific skin template and deliver to stdout (or return) * * @param string Template name * @param boolean Exit script - * @return void + * @param boolean Don't write to stdout, return parsed content instead + * * @link http://php.net/manual/en/function.exit.php */ - private function parse($name = 'main', $exit = true) + function parse($name = 'main', $exit = true, $write = true) { $skin_path = $this->config['skin_path']; $plugin = false; @@ -428,22 +419,27 @@ class rcube_template extends rcube_html_page // trigger generic hook where plugins can put additional content to the page $hook = $this->app->plugins->exec_hook("render_page", array('template' => $realname, 'content' => $output)); - // add debug console - if ($this->config['debug_level'] & 8) { - $this->add_footer('<div id="console" style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;z-index:9000;"> - <a href="#toggle" onclick="con=$(\'#dbgconsole\');con[con.is(\':visible\')?\'hide\':\'show\']();return false">console</a> - <textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:10px" spellcheck="false"></textarea></div>' - ); + $output = $this->parse_with_globals($hook['content']); + + if ($write) { + // add debug console + if ($this->config['debug_level'] & 8) { + $this->add_footer('<div id="console" style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;z-index:9000;"> + <a href="#toggle" onclick="con=$(\'#dbgconsole\');con[con.is(\':visible\')?\'hide\':\'show\']();return false">console</a> + <textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:10px" spellcheck="false"></textarea></div>' + ); + } + $this->write(trim($output)); + } + else { + return $output; } - $output = $this->parse_with_globals($hook['content']); - $this->write(trim($output)); if ($exit) { exit; } } - /** * Return executable javascript code for all registered commands * |