From b076a460e5418ae8f0db0b4b392d91853fd2a21b Mon Sep 17 00:00:00 2001 From: thomascube Date: Wed, 26 Oct 2005 22:12:36 +0000 Subject: Finished message sorting and fixed some skin issues --- program/steps/mail/func.inc | 50 +++++++++++++++++++++++++++------------------ program/steps/mail/list.inc | 21 ++++--------------- program/steps/mail/show.inc | 2 +- 3 files changed, 35 insertions(+), 38 deletions(-) (limited to 'program/steps') diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 0875c0477..c1eafaad7 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -234,13 +234,13 @@ function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox, $maxl function rcmail_message_list($attrib) { global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT, $JS_OBJECT_NAME; - + $skin_path = $CONFIG['skin_path']; $image_tag = '%s'; - + // check to see if we have some settings for sorting - $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : 'date'; - $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : 'DESC'; + $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; + $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; // get message headers $a_headers = $IMAP->list_headers('', '', $sort_col, $sort_order); @@ -256,6 +256,7 @@ function rcmail_message_list($attrib) // define list of cols to be displayed $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); + $a_sort_cols = array('subject', 'date', 'from', 'to'); // show 'to' instead of from in sent messages if (strtolower($IMAP->get_mailbox_name())=='sent' && ($f = array_search('from', $a_show_cols))) @@ -264,7 +265,7 @@ function rcmail_message_list($attrib) // add table title $out .= "\n \n"; - + $javascript = ''; foreach ($a_show_cols as $col) { @@ -273,26 +274,33 @@ function rcmail_message_list($attrib) // make sort links $sort = ''; - if ($col != 'size') + if (in_array($col, $a_sort_cols) && (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton']))) { + $sort = '  '; + // asc link - $asc = '_ASC'; - $sort .= '' - . ''; + if (!empty($attrib['sortascbutton'])) + { + $sort .= rcube_button(array('command' => 'sort', + 'prop' => $col.'_ASC', + 'image' => $attrib['sortascbutton'], + 'title' => 'sortasc')); + } + // desc link - $desc = '_DESC'; - $sort .= ' ' - . ''; + if (!empty($attrib['sortdescbutton'])) + { + $sort .= rcube_button(array('command' => 'sort', + 'prop' => $col.'_DESC', + 'image' => $attrib['sortdescbutton'], + 'title' => 'sortdesc')); + } } + + $sort_class = $col==$sort_col ? " sorted$sort_order" : ''; // put it all together - $out .= '' . "$col_name  $sort\n"; - - // register sort buttons - $javascript .= "rcmail.register_button('sort', 'sort_{$col_name}_desc', 'link', 'active', '', '');\n"; - $javascript .= "rcmail.register_button('sort', 'sort_{$col_name}_asc', 'link', 'active', '', '');\n"; + $out .= '' . "$col_name$sort\n"; } $out .= ''.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : '')."\n"; @@ -374,6 +382,8 @@ function rcmail_message_list($attrib) $javascript .= sprintf("%s.set_env('messagecount', %d);\n", $JS_OBJECT_NAME, $message_count); $javascript .= sprintf("%s.set_env('current_page', %d);\n", $JS_OBJECT_NAME, $IMAP->list_page); $javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, ceil($message_count/$IMAP->page_size)); + $javascript .= sprintf("%s.set_env('sort_col', '%s');\n", $JS_OBJECT_NAME, $sort_col); + $javascript .= sprintf("%s.set_env('sort_order', '%s');\n", $JS_OBJECT_NAME, $sort_order); if ($attrib['messageicon']) $javascript .= sprintf("%s.set_env('messageicon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['messageicon']); @@ -849,7 +859,7 @@ function rcmail_message_headers($attrib, $headers=NULL) if (!$headers[$hkey]) continue; - if ($hkey=='date') + if ($hkey=='date' && !empty($headers[$hkey])) $header_value = format_date(strtotime($headers[$hkey])); else if (in_array($hkey, array('from', 'to', 'cc', 'reply-to'))) $header_value = rep_specialchars_output(rcmail_address_string($IMAP->decode_header($headers[$hkey]), NULL, $attrib['addicon'])); diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index 5dd652d44..cb1d7a6c7 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -31,28 +31,15 @@ if ($sort = isset($_GET['_sort']) ? $_GET['_sort'] : false) // yes, so set the sort vars list($sort_col, $sort_order) = explode('_', $sort); - // iloha mail sort func doesn't know about a 'Sender' col - $sort_col = $sort_col == 'Sender' ? 'From' : $sort_col; - // set session vars for sort (so next page and task switch know how to sort) $_SESSION['sort_col'] = $sort_col; $_SESSION['sort_order'] = $sort_order; } else - { - // if switching folder, use default sorting - if ($_GET['_refresh'] == '1') - { - $sort_col = 'date'; - $sort_order = 'desc'; - unset($_SESSION['sort_col'], $_SESSION['sort_order']); - } - else - { - // use session settings if set, defaults if not - $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : 'date'; - $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : 'desc'; - } + { + // use session settings if set, defaults if not + $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; + $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; } diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index d9ff5d443..992d06f79 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -65,7 +65,7 @@ if ($_GET['_uid']) $javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']); // get previous and next message UID - $a_msg_index = $IMAP->message_index(); + $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); $MESSAGE['index'] = array_search((string)$_GET['_uid'], $a_msg_index, TRUE); if (isset($a_msg_index[$MESSAGE['index']-1])) -- cgit v1.2.3