]> git.openstreetmap.org Git - chef.git/blob - cookbooks/dmca/files/default/html/HTML/QuickForm/input.php
Configure the dmca form site on ridley
[chef.git] / cookbooks / dmca / files / default / html / HTML / QuickForm / input.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
4 /**
5  * Base class for <input /> form elements
6  * 
7  * PHP versions 4 and 5
8  *
9  * LICENSE: This source file is subject to version 3.01 of the PHP license
10  * that is available through the world-wide-web at the following URI:
11  * http://www.php.net/license/3_01.txt If you did not receive a copy of
12  * the PHP License and are unable to obtain it through the web, please
13  * send a note to license@php.net so we can mail you a copy immediately.
14  *
15  * @category    HTML
16  * @package     HTML_QuickForm
17  * @author      Adam Daniel <adaniel1@eesus.jnj.com>
18  * @author      Bertrand Mansion <bmansion@mamasam.com>
19  * @copyright   2001-2011 The PHP Group
20  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
21  * @version     CVS: $Id$
22  * @link        http://pear.php.net/package/HTML_QuickForm
23  */
24
25 /**
26  * Base class for form elements
27  */ 
28 require_once 'HTML/QuickForm/element.php';
29
30 /**
31  * Base class for <input /> form elements
32  * 
33  * @category    HTML
34  * @package     HTML_QuickForm
35  * @author      Adam Daniel <adaniel1@eesus.jnj.com>
36  * @author      Bertrand Mansion <bmansion@mamasam.com>
37  * @version     Release: 3.2.16
38  * @since       1.0
39  * @abstract
40  */
41 class HTML_QuickForm_input extends HTML_QuickForm_element
42 {
43     // {{{ constructor
44
45     /**
46      * Class constructor
47      * 
48      * @param    string     Input field name attribute
49      * @param    mixed      Label(s) for the input field
50      * @param    mixed      Either a typical HTML attribute string or an associative array
51      * @since     1.0
52      * @access    public
53      * @return    void
54      */
55     function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null)
56     {
57         $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
58     } //end constructor
59
60     // }}}
61     // {{{ setType()
62
63     /**
64      * Sets the element type
65      *
66      * @param     string    $type   Element type
67      * @since     1.0
68      * @access    public
69      * @return    void
70      */
71     function setType($type)
72     {
73         $this->_type = $type;
74         $this->updateAttributes(array('type'=>$type));
75     } // end func setType
76     
77     // }}}
78     // {{{ setName()
79
80     /**
81      * Sets the input field name
82      * 
83      * @param     string    $name   Input field name attribute
84      * @since     1.0
85      * @access    public
86      * @return    void
87      */
88     function setName($name)
89     {
90         $this->updateAttributes(array('name'=>$name));
91     } //end func setName
92     
93     // }}}
94     // {{{ getName()
95
96     /**
97      * Returns the element name
98      * 
99      * @since     1.0
100      * @access    public
101      * @return    string
102      */
103     function getName()
104     {
105         return $this->getAttribute('name');
106     } //end func getName
107     
108     // }}}
109     // {{{ setValue()
110
111     /**
112      * Sets the value of the form element
113      *
114      * @param     string    $value      Default value of the form element
115      * @since     1.0
116      * @access    public
117      * @return    void
118      */
119     function setValue($value)
120     {
121         $this->updateAttributes(array('value'=>$value));
122     } // end func setValue
123
124     // }}}
125     // {{{ getValue()
126
127     /**
128      * Returns the value of the form element
129      *
130      * @since     1.0
131      * @access    public
132      * @return    string
133      */
134     function getValue()
135     {
136         return $this->getAttribute('value');
137     } // end func getValue
138     
139     // }}}
140     // {{{ toHtml()
141
142     /**
143      * Returns the input field in HTML
144      * 
145      * @since     1.0
146      * @access    public
147      * @return    string
148      */
149     function toHtml()
150     {
151         if ($this->_flagFrozen) {
152             return $this->getFrozenHtml();
153         } else {
154             return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />';
155         }
156     } //end func toHtml
157
158     // }}}
159     // {{{ onQuickFormEvent()
160
161     /**
162      * Called by HTML_QuickForm whenever form event is made on this element
163      *
164      * @param     string    $event  Name of event
165      * @param     mixed     $arg    event arguments
166      * @param     object    &$caller calling object
167      * @since     1.0
168      * @access    public
169      * @return    void
170      * @throws    
171      */
172     function onQuickFormEvent($event, $arg, &$caller)
173     {
174         // do not use submit values for button-type elements
175         $type = $this->getType();
176         if (('updateValue' != $event) ||
177             ('submit' != $type && 'reset' != $type && 'image' != $type && 'button' != $type)) {
178             parent::onQuickFormEvent($event, $arg, $caller);
179         } else {
180             $value = $this->_findValue($caller->_constantValues);
181             if (null === $value) {
182                 $value = $this->_findValue($caller->_defaultValues);
183             }
184             if (null !== $value) {
185                 $this->setValue($value);
186             }
187         }
188         return true;
189     } // end func onQuickFormEvent
190
191     // }}}
192     // {{{ exportValue()
193
194    /**
195     * We don't need values from button-type elements (except submit) and files
196     */
197     function exportValue(&$submitValues, $assoc = false)
198     {
199         $type = $this->getType();
200         if ('reset' == $type || 'image' == $type || 'button' == $type || 'file' == $type) {
201             return null;
202         } else {
203             return parent::exportValue($submitValues, $assoc);
204         }
205     }
206     
207     // }}}
208 } // end class HTML_QuickForm_element
209 ?>