1: <?php
2: /**
3: * Copyright 2010-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2010-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * This class handles header-related search queries.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2010-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Search_Element_Header extends IMP_Search_Element
24: {
25: /**
26: * Constructor.
27: *
28: * @param string $text The search text.
29: * @param string $header The header field.
30: * @param boolean $not If true, do a 'NOT' search of $text.
31: */
32: public function __construct($text, $header, $not = false)
33: {
34: /* Data element:
35: * h = (string) Header name (lower case).
36: * n = (integer) Do a NOT search?
37: * t = (string) The search text. */
38: $this->_data = new stdClass;
39: $this->_data->h = trim(Horde_String::lower($header));
40: $this->_data->n = intval(!empty($not));
41: $this->_data->t = $text;
42: }
43:
44: /**
45: */
46: public function createQuery($mbox, $queryob)
47: {
48: $queryob->headerText($this->_data->h, $this->_data->t, $this->_data->n);
49:
50: return $queryob;
51: }
52:
53: /**
54: */
55: public function queryText()
56: {
57: return sprintf(_("%s (Header) for \"%s\""), _(Horde_String::ucfirst($this->_data->h)), ($this->_data->n ? _("not") . ' ' : '') . $this->_data->t);
58: }
59:
60: }
61: