]> git.openstreetmap.org Git - chef.git/blob - cookbooks/dmca/files/default/html/HTML/QuickForm/static.php
split configuration in two, include new templates
[chef.git] / cookbooks / dmca / files / default / html / HTML / QuickForm / static.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
4 /**
5  * HTML class for static data
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      Wojciech Gdela <eltehaem@poczta.onet.pl>
18  * @copyright   2001-2011 The PHP Group
19  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
20  * @version     CVS: $Id$
21  * @link        http://pear.php.net/package/HTML_QuickForm
22  */
23
24 /**
25  * Base class for form elements
26  */ 
27 require_once 'HTML/QuickForm/element.php';
28
29 /**
30  * HTML class for static data
31  * 
32  * @category    HTML
33  * @package     HTML_QuickForm
34  * @author      Wojciech Gdela <eltehaem@poczta.onet.pl>
35  * @version     Release: 3.2.16
36  * @since       2.7
37  */
38 class HTML_QuickForm_static extends HTML_QuickForm_element {
39     
40     // {{{ properties
41
42     /**
43      * Display text
44      * @var       string
45      * @access    private
46      */
47     var $_text = null;
48
49     // }}}
50     // {{{ constructor
51     
52     /**
53      * Class constructor
54      * 
55      * @param     string    $elementLabel   (optional)Label
56      * @param     string    $text           (optional)Display text
57      * @access    public
58      * @return    void
59      */
60     function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null)
61     {
62         HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel);
63         $this->_persistantFreeze = false;
64         $this->_type = 'static';
65         $this->_text = $text;
66     } //end constructor
67     
68     // }}}
69     // {{{ setName()
70
71     /**
72      * Sets the element name
73      * 
74      * @param     string    $name   Element name
75      * @access    public
76      * @return    void
77      */
78     function setName($name)
79     {
80         $this->updateAttributes(array('name'=>$name));
81     } //end func setName
82     
83     // }}}
84     // {{{ getName()
85
86     /**
87      * Returns the element name
88      * 
89      * @access    public
90      * @return    string
91      */
92     function getName()
93     {
94         return $this->getAttribute('name');
95     } //end func getName
96
97     // }}}
98     // {{{ setText()
99
100     /**
101      * Sets the text
102      *
103      * @param     string    $text
104      * @access    public
105      * @return    void
106      */
107     function setText($text)
108     {
109         $this->_text = $text;
110     } // end func setText
111
112     // }}}
113     // {{{ setValue()
114
115     /**
116      * Sets the text (uses the standard setValue call to emulate a form element.
117      *
118      * @param     string    $text
119      * @access    public
120      * @return    void
121      */
122     function setValue($text)
123     {
124         $this->setText($text);
125     } // end func setValue
126
127     // }}}    
128     // {{{ toHtml()
129
130     /**
131      * Returns the static text element in HTML
132      * 
133      * @access    public
134      * @return    string
135      */
136     function toHtml()
137     {
138         return $this->_getTabs() . $this->_text;
139     } //end func toHtml
140     
141     // }}}
142     // {{{ getFrozenHtml()
143
144     /**
145      * Returns the value of field without HTML tags
146      * 
147      * @access    public
148      * @return    string
149      */
150     function getFrozenHtml()
151     {
152         return $this->toHtml();
153     } //end func getFrozenHtml
154
155     // }}}
156     // {{{ onQuickFormEvent()
157
158     /**
159      * Called by HTML_QuickForm whenever form event is made on this element
160      *
161      * @param     string    $event  Name of event
162      * @param     mixed     $arg    event arguments
163      * @param     object    &$caller calling object
164      * @since     1.0
165      * @access    public
166      * @return    void
167      * @throws    
168      */
169     function onQuickFormEvent($event, $arg, &$caller)
170     {
171         switch ($event) {
172             case 'updateValue':
173                 // do NOT use submitted values for static elements
174                 $value = $this->_findValue($caller->_constantValues);
175                 if (null === $value) {
176                     $value = $this->_findValue($caller->_defaultValues);
177                 }
178                 if (null !== $value) {
179                     $this->setValue($value);
180                 }
181                 break;
182             default:
183                 parent::onQuickFormEvent($event, $arg, $caller);
184         }
185         return true;
186     } // end func onQuickFormEvent
187
188     // }}}
189     // {{{ exportValue()
190
191    /**
192     * We override this here because we don't want any values from static elements
193     */
194     function exportValue(&$submitValues, $assoc = false)
195     {
196         return null;
197     }
198     
199     // }}}
200 } //end class HTML_QuickForm_static
201 ?>