alecpl
2012-01-12 fd43a92b5d31bab019d9afec1c9846b7ab9291bb
program/include/rcube_result_thread.php
@@ -17,7 +17,7 @@
 | Author: Aleksander Machniak <alec@alec.pl>                            |
 +-----------------------------------------------------------------------+
 $Id: rcube_imap.php 5347 2011-10-19 06:35:29Z alec $
 $Id$
*/
@@ -116,8 +116,9 @@
        if (empty($this->raw_data)) {
            $this->meta['count'] = 0;
        }
        else
        else {
            $this->meta['count'] = 1 + substr_count($this->raw_data, self::SEPARATOR_ELEMENT);
        }
        if (!$this->meta['count'])
            $this->meta['messages'] = 0;
@@ -140,11 +141,9 @@
            $this->meta['messages'] = 0;
        }
        else {
            $regexp = '/((^|' . preg_quote(self::SEPARATOR_ELEMENT, '/')
                . '|' . preg_quote(self::SEPARATOR_ITEM, '/') . ')[0-9]+)/';
            // @TODO: can we do this in a better way?
            $this->meta['messages'] = preg_match_all($regexp, $this->raw_data, $m);
            $this->meta['messages'] = 1
                + substr_count($this->raw_data, self::SEPARATOR_ELEMENT)
                + substr_count($this->raw_data, self::SEPARATOR_ITEM);
        }
        if ($this->meta['messages'] == 0 || $this->meta['messages'] == 1)
@@ -162,7 +161,6 @@
    public function max()
    {
        if (!isset($this->meta['max'])) {
            // @TODO: do it by parsing raw_data?
            $this->meta['max'] = (int) @max($this->get());
        }
        return $this->meta['max'];
@@ -177,7 +175,6 @@
    public function min()
    {
        if (!isset($this->meta['min'])) {
            // @TODO: do it by parsing raw_data?
            $this->meta['min'] = (int) @min($this->get());
        }
        return $this->meta['min'];
@@ -556,10 +553,12 @@
    private function buildThreadData($data, &$depth, &$children, $level = 0)
    {
        foreach ((array)$data as $key => $val) {
            $children[$key] = !empty($val);
            $depth[$key] = $level;
            if (!empty($val))
            $empty          = empty($val) || !is_array($val);
            $children[$key] = !$empty;
            $depth[$key]    = $level;
            if (!$empty) {
                $this->buildThreadData($val, $depth, $children, $level + 1);
            }
        }
    }