1: <?php
2: /**
3: * This class handles size-related search queries.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (GPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/gpl.
9: *
10: * @author Michael Slusarz <slusarz@horde.org>
11: * @category Horde
12: * @license http://www.horde.org/licenses/gpl GPL
13: * @package IMP
14: */
15: class IMP_Search_Element_Size extends IMP_Search_Element
16: {
17: /**
18: * Allow NOT search on this element?
19: *
20: * @var boolean
21: */
22: public $not = false;
23:
24: /**
25: * Constructor.
26: *
27: * @param integer $size The size (in bytes).
28: * @param boolean $larger Search for messages larger than $size?
29: */
30: public function __construct($size, $larger = false)
31: {
32: /* Data element:
33: * l = (integer) Larger if non-zero, smaller if zero.
34: * s = (integer) Size (in bytes). */
35: $this->_data = new stdClass;
36: $this->_data->s = intval($size);
37: $this->_data->l = intval(!empty($larger));
38: }
39:
40: /**
41: */
42: public function createQuery($mbox, $queryob)
43: {
44: $queryob->size($this->_data->s, $this->_data->l);
45:
46: return $queryob;
47: }
48:
49: /**
50: */
51: public function queryText()
52: {
53: $label = $this->_data->l
54: ? _("Size - Greater Than (KB)")
55: : _("Size - Less Than (KB)");
56:
57: return $label . ' ' . ($this->_data->s / 1024);
58: }
59:
60: }
61: