/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FEText.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/form/form_elements/FEText.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Feb 22 21:07:48 2003 UTC (21 years, 7 months ago) by jonen
Branch: MAIN
+ updated whole lib to version 2.2.1 (new FormProcessing since 2.2.0!)

1 <?php
2 /**
3 * This file contains the FEText, FEName, FEEmail,
4 * FEDomainName classes
5 *
6 * $Id: FEText.inc,v 1.14 2003/02/18 23:02:00 hemna Exp $
7 *
8 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
9 * @author Suren Markosyan <suren@bcsweb.com>
10 * @package phpHtmlLib
11 * @subpackage FormProcessing
12 *
13 * @copyright LGPL - See LICENCE
14 *
15 */
16
17 /**
18 * This is the Text FormElement which builds a
19 * text input field. It has no validation method.
20 *
21 *
22 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
23 * @author Suren Markossian <suren@bcsweb.com>
24 * @package phpHtmlLib
25 * @subpackage FormProcessing
26 *
27 * @copyright LGPL - See LICENCE
28 */
29 class FEText extends FormElement {
30
31 /**
32 * The constructor
33 *
34 * @param label string - text label for the element
35 * @param bool required - is this a required element
36 * @param int required - element width in characters, pixels (px), percentage (%) or elements (em)
37 * @param int required - maximum number of chars allowed to type in
38 */
39 function FEText($label, $required = TRUE, $width = NULL, $maxlength = NULL) {
40 $this->FormElement($label, $required);
41
42 if ($width != NULL) {
43 if (is_numeric($width))
44 $this->set_attribute("size", $width);
45 else
46 $this->set_style_attribute("width", $width);
47 }
48
49 if ($maxlength != NULL)
50 $this->set_attribute("maxlength", $maxlength);
51 }
52
53
54 /**
55 * This function builds and returns the
56 * form element object
57 *
58 * @return object
59 */
60 function get_element() {
61
62 $attributes = $this->_build_element_attributes();
63 $attributes["type"] = "text";
64
65 if (($value = $this->get_value()) != NULL)
66 $attributes["value"] = $value;
67
68 $tag = new INPUTtag($attributes);
69
70
71 return $tag;
72 }
73 }
74
75 /**
76 * This is the Name FormElement which builds a
77 * text input field, and validates against the
78 * is_name() method.
79 *
80 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
81 * @author Suren Markossian <suren@bcsweb.com>
82 * @package phpHtmlLib
83 * @subpackage FormProcessing
84 *
85 * @copyright LGPL - See LICENCE
86 */
87 class FEName extends FEText {
88
89 /**
90 * This method validates the data
91 * for this Form Element.
92 *
93 * It validates as is_name().
94 */
95 function validate() {
96 $v = new FormValidation;
97 if (!$v->is_name($this->get_value())) {
98 $this->set_error_message( $v->get_error_message() );
99 return FALSE;
100 }
101 return TRUE;
102 }
103 }
104
105 /**
106 * This is the Email FormElement which builds a
107 * text input field.
108 * It validatest he data as is_email()
109 *
110 *
111 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
112 * @author Suren Markossian <suren@bcsweb.com>
113 * @package phpHtmlLib
114 * @subpackage FormProcessing
115 *
116 * @copyright LGPL - See LICENCE
117 */
118 class FEEmail extends FEText {
119
120 /**
121 * This method validates the data
122 * for this Form Element.
123 *
124 * It validates as is_email().
125 */
126 function validate() {
127 $v = new FormValidation;
128 if (!$v->is_email($this->get_value())) {
129 $this->set_error_message( $v->get_error_message() );
130 return FALSE;
131 }
132 return TRUE;
133 }
134 }
135
136 /**
137 * This is the EmailMany FormElement which builds a
138 * text input field. This allows for multiple email
139 * addresses in 1 text input field seperated by commas.
140 *
141 * It validatest he data as is_manyemails()
142 *
143 *
144 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
145 * @author Suren Markossian <suren@bcsweb.com>
146 * @package phpHtmlLib
147 * @subpackage FormProcessing
148 *
149 * @copyright LGPL - See LICENCE
150 */
151 class FEEmailMany extends FEText {
152
153 /**
154 * This method validates the data
155 * for this Form Element.
156 *
157 * It validates as is_manyemails().
158 */
159 function validate() {
160 $v = new FormValidation;
161 if (!$v->is_manyemails($this->get_value())) {
162 $this->set_error_message( $v->get_error_message() );
163 return FALSE;
164 }
165 return TRUE;
166 }
167 }
168
169 /**
170 * This is the DomainName FormElement which builds a
171 * text input field.
172 * It validates as is_domainname().
173 *
174 *
175 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
176 * @author Suren Markossian <suren@bcsweb.com>
177 * @package phpHtmlLib
178 * @subpackage FormProcessing
179 *
180 * @copyright LGPL - See LICENCE
181 */
182 class FEDomainName extends FEText {
183
184 /**
185 * This method validates the data
186 * for this Form Element.
187 *
188 * It validates as is_domainname().
189 */
190 function validate() {
191 $v = new FormValidation;
192 if (!$v->is_domainname($this->get_value())) {
193 $this->set_error_message( $v->get_error_message() );
194 return FALSE;
195 }
196 return TRUE;
197 }
198 }
199
200 /**
201 * This is the Ip Address FormElement which builds a
202 * text input field.
203 * It validates as is_ip().
204 *
205 *
206 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
207 * @author Suren Markossian <suren@bcsweb.com>
208 * @package phpHtmlLib
209 * @subpackage FormProcessing
210 *
211 * @copyright LGPL - See LICENCE
212 */
213 class FEIPAddress extends FEText {
214
215 /**
216 * This method validates the data
217 * for this Form Element.
218 *
219 * It validates as is_ip().
220 */
221 function validate() {
222 $v = new FormValidation;
223 if (!$v->is_ip($this->get_value())) {
224 $this->set_error_message( $v->get_error_message() );
225 return FALSE;
226 }
227 return TRUE;
228 }
229 }
230
231 /**
232 * This is the float FormElement which builds a
233 * text input field.
234 * It validates as is_float().
235 *
236 *
237 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
238 * @author Suren Markossian <suren@bcsweb.com>
239 * @package phpHtmlLib
240 * @subpackage FormProcessing
241 *
242 * @copyright LGPL - See LICENCE
243 */
244 class FENumberFloat extends FEText {
245
246 /**
247 * This method validates the data
248 * for this Form Element.
249 *
250 * It validates as is_float().
251 */
252 function validate() {
253 $v = new FormValidation;
254 if (!$v->is_float($this->get_value())) {
255 $this->set_error_message( $v->get_error_message() );
256 return FALSE;
257 }
258 return TRUE;
259 }
260 }
261
262 /**
263 * This is the Price FormElement which builds a
264 * text input field.
265 * It validates as is_price().
266 *
267 *
268 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
269 * @author Suren Markossian <suren@bcsweb.com>
270 * @package phpHtmlLib
271 * @subpackage FormProcessing
272 *
273 * @copyright LGPL - See LICENCE
274 */
275 class FENumberPrice extends FEText {
276
277 /**
278 * This method validates the data
279 * for this Form Element.
280 *
281 * It validates as is_price().
282 */
283 function validate() {
284 $v = new FormValidation;
285 if (!$v->is_price($this->get_value())) {
286 $this->set_error_message( $v->get_error_message() );
287 return FALSE;
288 }
289 return TRUE;
290 }
291 }
292
293 /**
294 * This is the URL FormElement which builds a
295 * text input field.
296 * It validates as is_url().
297 *
298 *
299 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
300 * @author Suren Markossian <suren@bcsweb.com>
301 * @package phpHtmlLib
302 * @subpackage FormProcessing
303 *
304 * @copyright LGPL - See LICENCE
305 */
306 class FEUrl extends FEText {
307
308 /**
309 * This method validates the data
310 * for this Form Element.
311 *
312 * It validates as is_url().
313 */
314 function validate() {
315 $v = new FormValidation;
316 if (!$v->is_url($this->get_value())) {
317 $this->set_error_message( $v->get_error_message() );
318 return FALSE;
319 }
320 return TRUE;
321 }
322 }
323
324 /**
325 * This is the URLStrict FormElement which builds a
326 * text input field.
327 * This is the same as FEUrl, but it requires the http://
328 * It validates as is_strict_url().
329 *
330 *
331 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
332 * @author Suren Markossian <suren@bcsweb.com>
333 * @package phpHtmlLib
334 * @subpackage FormProcessing
335 *
336 * @copyright LGPL - See LICENCE
337 */
338 class FEUrlStrict extends FEText {
339
340 /**
341 * This method validates the data
342 * for this Form Element.
343 *
344 * It validates as is_strict_url().
345 */
346 function validate() {
347 $v = new FormValidation;
348 if (!$v->is_strict_url($this->get_value())) {
349 $this->set_error_message( $v->get_error_message() );
350 return FALSE;
351 }
352 return TRUE;
353 }
354 }
355 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed