| | |
| | | return array_values($a_msg_headers); |
| | | } |
| | | else { // SEARCH searching result, need sorting |
| | | if ($cnt > $this->pagesize * 2) { |
| | | $cnt = count($msgs); |
| | | if ($cnt > 300 && $cnt > $this->page_size) { // experimantal value for best result |
| | | // use memory less expensive (and quick) method for big result set |
| | | $a_index = $this->message_index($mailbox, $this->sort_field, $this->sort_order); |
| | | // get messages uids for one page... |
| | | $msgs = array_slice(array_keys($a_index), $start_msg, min(count($msgs)-$start_msg, $this->page_size)); |
| | | $msgs = array_slice(array_keys($a_index), $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | // ...and fetch headers |
| | | $this->_fetch_headers($mailbox, join(',', $msgs), $a_msg_headers, NULL); |
| | | |
| | |
| | | $a_msg_headers = iil_SortHeaders($a_msg_headers, $this->sort_field, $this->sort_order); |
| | | |
| | | // only return the requested part of the set |
| | | return array_slice(array_values($a_msg_headers), $start_msg, min(count($msgs)-$start_msg, $this->page_size)); |
| | | return array_slice(array_values($a_msg_headers), $start_msg, min($cnt-$start_msg, $this->page_size)); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @access private |
| | | * @see rcube_imap::search() |
| | | */ |
| | | function _search_index($mailbox, $criteria='ALL', $charset='', $sort_field='') |
| | | function _search_index($mailbox, $criteria='ALL', $charset=NULL, $sort_field=NULL) |
| | | { |
| | | if ($this->get_capability('sort')) |
| | | if ($sort_field && $this->get_capability('sort')) |
| | | { |
| | | $charset = $charset ? $charset : $this->default_charset; |
| | | $a_messages = iil_C_Sort($this->conn, $mailbox, $sort_field, $criteria, FALSE, $charset); |
| | | } |
| | | else |
| | | $a_messages = iil_C_Search($this->conn, $mailbox, ($charset ? "CHARSET $charset " : '') . $criteria); |
| | | |
| | |
| | | /** |
| | | * Decode a mime-encoded string to internal charset |
| | | * |
| | | * @param string Header value |
| | | * @param string Fallback charset if none specified |
| | | * @param string $input Header value |
| | | * @param string $fallback Fallback charset if none specified |
| | | * |
| | | * @return string Decoded string |
| | | * @static |
| | | */ |
| | | function decode_mime_string($input, $fallback=null) |
| | | public static function decode_mime_string($input, $fallback=null) |
| | | { |
| | | // Initialize variable |
| | | $out = ''; |