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: * Text-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_Text extends IMP_Search_Element
24: {
25: /**
26: * Constructor.
27: *
28: * @param string $text The search text.
29: * @param string $bodyonly If true, only search in the body of the
30: * message. If false, also search in the headers.
31: * @param boolean $not If true, do a 'NOT' search of $text.
32: */
33: public function __construct($text, $bodyonly = true, $not = false)
34: {
35: /* Data element:
36: * b = (integer) Search in body only?
37: * n = (integer) Do a NOT search?
38: * t = (string) The search text. */
39: $this->_data = new stdClass;
40: $this->_data->b = intval(!empty($bodyonly));
41: $this->_data->n = intval(!empty($not));
42: $this->_data->t = $text;
43: }
44:
45: /**
46: */
47: public function createQuery($mbox, $queryob)
48: {
49: $queryob->text($this->_data->t, $this->_data->b, $this->_data->n);
50:
51: return $queryob;
52: }
53:
54: /**
55: */
56: public function queryText()
57: {
58: $label = $this->_data->b
59: ? _("Message Body")
60: : _("Entire Message (including Headers)");
61:
62: return sprintf(_("%s for '%s'"), $label, ((!empty($this->_data->n)) ? _("not") . ' ' : '') . $this->_data->t);
63: }
64:
65: }
66: