5 |
* |
* |
6 |
* $Id$ |
* $Id$ |
7 |
* |
* |
8 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
9 |
* @author Suren Markosyan <suren@bcsweb.com> |
* @author Suren Markosyan <suren@bcsweb.com> |
10 |
* @package phpHtmlLib |
* @package phpHtmlLib |
11 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
19 |
* text input field. It has no validation method. |
* text input field. It has no validation method. |
20 |
* |
* |
21 |
* |
* |
22 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
23 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
24 |
* @package phpHtmlLib |
* @package phpHtmlLib |
25 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
36 |
* @param int required - element width in characters, pixels (px), percentage (%) or elements (em) |
* @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 |
* @param int required - maximum number of chars allowed to type in |
38 |
*/ |
*/ |
39 |
function FEText($label, $required = TRUE, $width = NULL, $maxlength = NULL) { |
function FEText($label, $required = FALSE, $width = NULL, $maxlength = NULL) { |
40 |
$this->FormElement($label, $required); |
$this->FormElement($label, $required); |
41 |
|
|
42 |
if ($width != NULL) { |
if ($width != NULL) { |
74 |
* text input field, and validates against the |
* text input field, and validates against the |
75 |
* is_name() method. |
* is_name() method. |
76 |
* |
* |
77 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
78 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
79 |
* @package phpHtmlLib |
* @package phpHtmlLib |
80 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
105 |
* It validatest he data as is_email() |
* It validatest he data as is_email() |
106 |
* |
* |
107 |
* |
* |
108 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
109 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
110 |
* @package phpHtmlLib |
* @package phpHtmlLib |
111 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
113 |
* @copyright LGPL - See LICENCE |
* @copyright LGPL - See LICENCE |
114 |
*/ |
*/ |
115 |
class FEEmail extends FEText { |
class FEEmail extends FEText { |
116 |
|
|
117 |
|
/** Holds the flag to indicate |
118 |
|
* whether we allow email in |
119 |
|
* the long name format like |
120 |
|
* Foo Bar <email@email.com> |
121 |
|
*/ |
122 |
|
var $_allow_name = true; |
123 |
|
|
124 |
/** |
/** |
125 |
* This method validates the data |
* This method validates the data |
129 |
* @param FormValidation object. |
* @param FormValidation object. |
130 |
*/ |
*/ |
131 |
function validate($_FormValidation) { |
function validate($_FormValidation) { |
132 |
if (!$_FormValidation->is_email($this->get_value())) { |
if (!$_FormValidation->is_email($this->get_value(), $this->_allow_name)) { |
133 |
$this->set_error_message( $_FormValidation->get_error_message() ); |
$this->set_error_message( $_FormValidation->get_error_message() ); |
134 |
return FALSE; |
return FALSE; |
135 |
} |
} |
136 |
return TRUE; |
return TRUE; |
137 |
} |
} |
138 |
|
|
139 |
|
/** |
140 |
|
* Sets the flag to indicate |
141 |
|
* whether we allow email in |
142 |
|
* the long name format like |
143 |
|
* Foo Bar <email@email.com> |
144 |
|
* |
145 |
|
* @param bool |
146 |
|
*/ |
147 |
|
function set_allow_name($flag) { |
148 |
|
$this->_allow_name = $flag; |
149 |
|
} |
150 |
} |
} |
151 |
|
|
152 |
/** |
/** |
157 |
* It validatest he data as is_manyemails() |
* It validatest he data as is_manyemails() |
158 |
* |
* |
159 |
* |
* |
160 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
161 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
162 |
* @package phpHtmlLib |
* @package phpHtmlLib |
163 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
188 |
* It validates as is_domainname(). |
* It validates as is_domainname(). |
189 |
* |
* |
190 |
* |
* |
191 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
192 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
193 |
* @package phpHtmlLib |
* @package phpHtmlLib |
194 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
219 |
* It validates as is_domainname(). |
* It validates as is_domainname(). |
220 |
* |
* |
221 |
* |
* |
222 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
223 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
224 |
* @package phpHtmlLib |
* @package phpHtmlLib |
225 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
356 |
* It validates as is_ip(). |
* It validates as is_ip(). |
357 |
* |
* |
358 |
* |
* |
359 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
360 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
361 |
* @package phpHtmlLib |
* @package phpHtmlLib |
362 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
387 |
* It validates as is_ip(). |
* It validates as is_ip(). |
388 |
* |
* |
389 |
* |
* |
390 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
391 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
392 |
* @package phpHtmlLib |
* @package phpHtmlLib |
393 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
420 |
* It validates as is_url(). |
* It validates as is_url(). |
421 |
* |
* |
422 |
* |
* |
423 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
424 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
425 |
* @package phpHtmlLib |
* @package phpHtmlLib |
426 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
452 |
* It validates as is_strict_url(). |
* It validates as is_strict_url(). |
453 |
* |
* |
454 |
* |
* |
455 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
456 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
457 |
* @package phpHtmlLib |
* @package phpHtmlLib |
458 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
474 |
return FALSE; |
return FALSE; |
475 |
} |
} |
476 |
return TRUE; |
return TRUE; |
477 |
|
} |
478 |
|
} |
479 |
|
|
480 |
|
/** |
481 |
|
* This is the FEZipcode class. |
482 |
|
* |
483 |
|
* @author Walter A. Boring IV <waboring@newsblob.com> |
484 |
|
*/ |
485 |
|
class FEZipcode extends FEText { |
486 |
|
/** |
487 |
|
* The constructor |
488 |
|
* |
489 |
|
* @param label string - text label for the element |
490 |
|
* @param bool required - is this a required element |
491 |
|
* @param int required - element width in characters, pixels (px), percentage (%) or elements (em) |
492 |
|
* @param int required - maximum number of chars allowed to type in |
493 |
|
*/ |
494 |
|
function FEZipcode($label, $required=false, $width = NULL, $maxlength = 5) { |
495 |
|
$this->FEText($label, $required, $width, $maxlength); |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
|
/** |
500 |
|
* This method validates the data |
501 |
|
* for this Form Element. |
502 |
|
* |
503 |
|
* It validates as is_name(). |
504 |
|
* @param FormValidation object. |
505 |
|
*/ |
506 |
|
function validate(&$_FormValidation) { |
507 |
|
if (!$_FormValidation->is_zip($this->get_value())) { |
508 |
|
$this->set_error_message( $_FormValidation->get_error_message() ); |
509 |
|
return FALSE; |
510 |
|
} |
511 |
|
return TRUE; |
512 |
|
} |
513 |
|
} |
514 |
|
|
515 |
|
/** |
516 |
|
* This is the RegEx FormElement which builds a text input field, and validates |
517 |
|
* against the is_regex() method. |
518 |
|
* |
519 |
|
* Example as it would appear in FormContent::form_init_elements(): |
520 |
|
* <code> |
521 |
|
* $this->add_element( new FERegEx("FERegEx label", false, '200px', 3, '/^pattern to match$/', 'error message when pattern does not match') ); |
522 |
|
* </code> |
523 |
|
* |
524 |
|
* @author Culley Harrelson <culley@fastmail.fm> |
525 |
|
* @package phpHtmlLib |
526 |
|
* @subpackage FormProcessing |
527 |
|
* |
528 |
|
* @copyright LGPL - See LICENCE |
529 |
|
*/ |
530 |
|
class FERegEx extends FEText { |
531 |
|
|
532 |
|
var $_regex; |
533 |
|
var $_error_message; |
534 |
|
|
535 |
|
/** |
536 |
|
* The constructor |
537 |
|
* |
538 |
|
* @param label string - text label for the element |
539 |
|
* @param required bool- is this a required element |
540 |
|
* @param width int - element width in characters, pixels (px), percentage (%) or elements (em) |
541 |
|
* @param maxlength int- maximum number of chars allowed to type in |
542 |
|
* @param regex string - a valid regular expression i.e. '/[a-z]+$/i' |
543 |
|
* @param error_message string - error message for failure to match the regex |
544 |
|
*/ |
545 |
|
function FERegEx($label, $required=false, $width = NULL, $maxlength = NULL, $regex, $error_message) { |
546 |
|
$this->FEText($label, $required, $width, $maxlength); |
547 |
|
$this->_regex = $regex; |
548 |
|
$this->_error_message = $error_message; |
549 |
|
} |
550 |
|
|
551 |
|
/** |
552 |
|
* This method validates the data |
553 |
|
* for this Form Element. |
554 |
|
* |
555 |
|
* It validates as is_regex(). |
556 |
|
* @param FormValidation object. |
557 |
|
* @return boolean |
558 |
|
*/ |
559 |
|
function validate(&$_FormValidation) { |
560 |
|
if (!$_FormValidation->is_regex($this->_regex, $this->get_value())) { |
561 |
|
$this->set_error_message( $this->_error_message ); |
562 |
|
return FALSE; |
563 |
|
} |
564 |
|
return TRUE; |
565 |
} |
} |
566 |
} |
} |
567 |
?> |
?> |