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