~ubuntu-branches/ubuntu/vivid/php-horde-nag/vivid

« back to all changes in this revision

Viewing changes to nag-4.1.3/lib/Form/Search.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2013-10-29 22:01:43 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131029220143-k16crjhccwr56jxq
Tags: 4.1.3-1
New upstream version 4.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * This file contains all Horde_Form extensions required for searching.
 
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
 * @package Nag
 
9
 */
 
10
 
 
11
/**
 
12
 * The Nag_Form_Search class provides the form for searching.
 
13
 *
 
14
 * @author  Michael J Rubinsky <mrubinsk@horde.org>
 
15
 * @package Nag
 
16
 */
 
17
 
 
18
class Nag_Form_Search extends Horde_Form
 
19
{
 
20
 
 
21
    public function __construct(&$vars, $title = '')
 
22
    {
 
23
        parent::__construct($vars, $title);
 
24
 
 
25
        $GLOBALS['page_output']->addScriptFile('form_helpers.js', 'horde');
 
26
        $this->addHidden('', 'smart_id', 'text', false);
 
27
        $this->addHidden('', 'actionID', 'text', false);
 
28
        $vars->set('actionID', 'search_tasks');
 
29
        $this->addVariable(_("Search Text:"), 'search_pattern', 'text', false);
 
30
        $v = $this->addVariable(
 
31
            _("Search In:"),
 
32
            'search_in',
 
33
            'set',
 
34
            false,
 
35
            false,
 
36
            false,
 
37
            array('values' => array(
 
38
                  'search_name' =>  _("Name"),
 
39
                  'search_desc' => _("Description")
 
40
            ))
 
41
        );
 
42
        $v->setDefault(array('search_name', 'search_desc'));
 
43
 
 
44
        $this->addVariable(_("Tagged with:"), 'search_tags', 'Nag:NagTags', false);
 
45
        $v = $this->addVariable(
 
46
            _("Search:"),
 
47
            'search_completed',
 
48
            'radio',
 
49
            false,
 
50
            false,
 
51
            false,
 
52
            array('values' => array(
 
53
                  Nag::VIEW_ALL => _("All"),
 
54
                  Nag::VIEW_COMPLETE => _("Completed"),
 
55
                  Nag::VIEW_INCOMPLETE => _("Incomplete")
 
56
            ))
 
57
        );
 
58
        $v->setDefault(Nag::VIEW_ALL);
 
59
 
 
60
        $this->addVariable(_("Due date:"), 'due_date', 'Nag:NagSearchDue', false);
 
61
 
 
62
        // If editing a SmartList, allow deletion.
 
63
        if ($vars->get('smart_id')) {
 
64
            $this->addVariable(_("SmartList Name:"), 'smartlist_name', 'text', false);
 
65
            $this->setButtons(_("Save"), _("Reset"));
 
66
            $this->appendButtons(array(array('value' => _("Delete Smart List"), 'name' => 'deletebutton', 'class' => 'horde-delete')));
 
67
        } else {
 
68
            $this->addVariable(_("Save this search as a Smart List?"), 'save_smartlist', 'boolean', false);
 
69
            $sl_name = $this->addVariable(_("Smart List Name:"), 'smartlist_name', 'text', false);
 
70
            $save_action = new Horde_Form_Action_ConditionalEnable(array('target' => 'save_smartlist', 'enabled' => true, 'values' => 'on'));
 
71
            $sl_name->setAction($save_action);
 
72
            $this->setButtons(_("Search"), _("Reset"));
 
73
        }
 
74
 
 
75
    }
 
76
 
 
77
    public function renderActive()
 
78
    {
 
79
        $url = Horde::url('list.php');
 
80
        if ($this->_vars->get('smart_id')) {
 
81
            // Editing an existing smartlist.
 
82
            $url->add(array('actionID' => 'smart', 'list' => $this->_vars->get('smart_id'), 'tab_name' => $this->_vars->get('smart_id')));
 
83
        }
 
84
        return parent::renderActive(
 
85
            $this->getRenderer(array('varrenderer_driver' => array('nag', 'nag'))),
 
86
            $this->_vars,
 
87
            $url->setRaw(true),
 
88
            'post');
 
89
    }
 
90
 
 
91
}
 
 
b'\\ No newline at end of file'