1: <?php
2: 3: 4:
5: class Whups_Form_Query_TextCriterion extends Horde_Form
6: {
7: public function __construct(&$vars)
8: {
9: parent::__construct(
10: $vars,
11: $vars->get('edit') ? _("Edit Text Criterion") : _("Add Text Criterion"),
12: 'Whups_Form_Query_TextCriterion');
13:
14: $this->addHidden('', 'edit', 'boolean', false);
15: $this->addVariable(_("Text"), 'text', 'text', true);
16: $this->addVariable(
17: _("Match Operator"), 'operator', 'enum', true, false, null,
18: array(Whups_Query::textOperators()));
19: $this->addVariable(_("Search Summary"), 'summary', 'boolean', false);
20: $this->addVariable(_("Search Comments"), 'comments', 'boolean', false);
21: }
22:
23: public function execute(&$vars)
24: {
25: $path = $vars->get('path');
26: $text = $vars->get('text');
27: $operator = $vars->get('operator');
28: $summary = $vars->get('summary');
29: $comments = $vars->get('comments');
30:
31: if ($summary && $comments) {
32: $path = $GLOBALS['whups_query']->insertBranch($path, Whups_Query::TYPE_OR);
33: }
34:
35: if ($summary) {
36: $GLOBALS['whups_query']->insertCriterion(
37: $path, Whups_Query::CRITERION_SUMMARY, null, $operator, $text);
38: }
39:
40: if ($comments) {
41: $GLOBALS['whups_query']->insertCriterion(
42: $path, Whups_Query::CRITERION_COMMENT, null, $operator, $text);
43: }
44:
45: $this->unsetVars($vars);
46: }
47:
48: }