adding some strings
[moodle-linuxchix.git] / lib / pear / HTML / QuickForm / static.php
blob69879312afa39111aa0ba635891475cba57a306f
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
4 // | PHP version 4.0 |
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.0 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Adam Daniel <adaniel1@eesus.jnj.com> |
17 // | Bertrand Mansion <bmansion@mamasam.com> |
18 // +----------------------------------------------------------------------+
20 // $Id$
22 require_once("HTML/QuickForm/element.php");
24 /**
25 * HTML class for static data
27 * @author Wojciech Gdela <eltehaem@poczta.onet.pl>
28 * @access public
30 class HTML_QuickForm_static extends HTML_QuickForm_element {
32 // {{{ properties
34 /**
35 * Display text
36 * @var string
37 * @access private
39 var $_text = null;
41 // }}}
42 // {{{ constructor
44 /**
45 * Class constructor
47 * @param string $elementLabel (optional)Label
48 * @param string $text (optional)Display text
49 * @access public
50 * @return void
52 function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null)
54 HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel);
55 $this->_persistantFreeze = false;
56 $this->_type = 'static';
57 $this->_text = $text;
58 } //end constructor
60 // }}}
61 // {{{ setName()
63 /**
64 * Sets the element name
66 * @param string $name Element name
67 * @access public
68 * @return void
70 function setName($name)
72 $this->updateAttributes(array('name'=>$name));
73 } //end func setName
75 // }}}
76 // {{{ getName()
78 /**
79 * Returns the element name
81 * @access public
82 * @return string
84 function getName()
86 return $this->getAttribute('name');
87 } //end func getName
89 // }}}
90 // {{{ setText()
92 /**
93 * Sets the text
95 * @param string $text
96 * @access public
97 * @return void
99 function setText($text)
101 $this->_text = $text;
102 } // end func setText
104 // }}}
105 // {{{ setValue()
108 * Sets the text (uses the standard setValue call to emulate a form element.
110 * @param string $text
111 * @access public
112 * @return void
114 function setValue($text)
116 $this->setText($text);
117 } // end func setValue
119 // }}}
120 // {{{ toHtml()
123 * Returns the static text element in HTML
125 * @access public
126 * @return string
128 function toHtml()
130 return $this->_getTabs() . $this->_text;
131 } //end func toHtml
133 // }}}
134 // {{{ getFrozenHtml()
137 * Returns the value of field without HTML tags
139 * @access public
140 * @return string
142 function getFrozenHtml()
144 return $this->toHtml();
145 } //end func getFrozenHtml
147 // }}}
148 // {{{ onQuickFormEvent()
151 * Called by HTML_QuickForm whenever form event is made on this element
153 * @param string $event Name of event
154 * @param mixed $arg event arguments
155 * @param object $caller calling object
156 * @since 1.0
157 * @access public
158 * @return void
159 * @throws
161 function onQuickFormEvent($event, $arg, &$caller)
163 switch ($event) {
164 case 'updateValue':
165 // do NOT use submitted values for static elements
166 $value = $this->_findValue($caller->_constantValues);
167 if (null === $value) {
168 $value = $this->_findValue($caller->_defaultValues);
170 if (null !== $value) {
171 $this->setValue($value);
173 break;
174 default:
175 parent::onQuickFormEvent($event, $arg, $caller);
177 return true;
178 } // end func onQuickFormEvent
180 // }}}
181 // {{{ exportValue()
184 * We override this here because we don't want any values from static elements
186 function exportValue(&$submitValues, $assoc = false)
188 return null;
191 // }}}
192 } //end class HTML_QuickForm_static