1: <?php
2: /**
3: * This class handles header-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_Header extends IMP_Search_Element
16: {
17: /**
18: * Constructor.
19: *
20: * @param string $text The search text.
21: * @param string $header The header field.
22: * @param boolean $not If true, do a 'NOT' search of $text.
23: */
24: public function __construct($text, $header, $not = false)
25: {
26: /* Data element:
27: * h = (string) Header name (lower case).
28: * n = (integer) Do a NOT search?
29: * t = (string) The search text. */
30: $this->_data = new stdClass;
31: $this->_data->h = trim(Horde_String::lower($header));
32: $this->_data->n = intval(!empty($not));
33: $this->_data->t = $text;
34: }
35:
36: /**
37: */
38: public function createQuery($mbox, $queryob)
39: {
40: $queryob->headerText($this->_data->h, $this->_data->t, $this->_data->n);
41:
42: return $queryob;
43: }
44:
45: /**
46: */
47: public function queryText()
48: {
49: return sprintf(_("%s (Header) for '%s'"), _(Horde_String::ucfirst($this->_data->h)), ($this->_data->n ? _("not") . ' ' : '') . $this->_data->t);
50: }
51:
52: }
53: