| Revision 256,
1.6 KB
checked in by schst, 8 years ago
(diff) |
|
Adjusted the subpackage to Element to match all other files
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * patForms Date subelement Minute |
|---|
| 4 | * |
|---|
| 5 | * Handles minutes input and validation for the date element |
|---|
| 6 | * |
|---|
| 7 | * $Id$ |
|---|
| 8 | * |
|---|
| 9 | * @access public |
|---|
| 10 | * @package patForms |
|---|
| 11 | * @subpackage Element |
|---|
| 12 | * @author Sebastian 'The Argh' Mordziol <argh@php-tools.net> |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * patForms Date subelement Minute |
|---|
| 17 | * |
|---|
| 18 | * Handles minutes input and validation for the date element |
|---|
| 19 | * |
|---|
| 20 | * $Id$ |
|---|
| 21 | * |
|---|
| 22 | * @access public |
|---|
| 23 | * @package patForms |
|---|
| 24 | * @subpackage Element |
|---|
| 25 | * @author Sebastian 'The Argh' Mordziol <argh@php-tools.net> |
|---|
| 26 | */ |
|---|
| 27 | class patForms_Element_Date_Element_Minute extends patForms_Element_Date_Element |
|---|
| 28 | { |
|---|
| 29 | /** |
|---|
| 30 | * Stores all needed token configurations, i.e. the length and output |
|---|
| 31 | * format of the corresponding values. |
|---|
| 32 | * |
|---|
| 33 | * @access private |
|---|
| 34 | * @var array |
|---|
| 35 | */ |
|---|
| 36 | var $tokens = array( |
|---|
| 37 | 'i' => array( |
|---|
| 38 | 'length' => 2, |
|---|
| 39 | 'format' => '%02d', |
|---|
| 40 | 'getter' => 'getMinute', |
|---|
| 41 | 'setter' => 'setMinute', |
|---|
| 42 | ), |
|---|
| 43 | ); |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * Retrieves values for the selector when using the preset mode. |
|---|
| 47 | * |
|---|
| 48 | * @access private |
|---|
| 49 | * @return array $values Values list in patForms format |
|---|
| 50 | */ |
|---|
| 51 | function getValues() |
|---|
| 52 | { |
|---|
| 53 | $values = array(); |
|---|
| 54 | |
|---|
| 55 | for( $i=0; $i <= 59; $i++ ) { |
|---|
| 56 | $label = sprintf( $this->tokens[$this->token]['format'], $i ); |
|---|
| 57 | |
|---|
| 58 | array_push( |
|---|
| 59 | $values, |
|---|
| 60 | array( |
|---|
| 61 | 'label' => $label, |
|---|
| 62 | 'value' => $label |
|---|
| 63 | ) |
|---|
| 64 | ); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | return $values; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | /** |
|---|
| 71 | * Validates the element. |
|---|
| 72 | * |
|---|
| 73 | * @access public |
|---|
| 74 | * @return bool $valid True if valid, false otherwise |
|---|
| 75 | */ |
|---|
| 76 | function validate() |
|---|
| 77 | { |
|---|
| 78 | $value = $this->getValue(); |
|---|
| 79 | if( is_null( $value ) ) { |
|---|
| 80 | return false; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | if( $value < 0 || $value > 59 ) { |
|---|
| 84 | return false; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | return true; |
|---|
| 88 | } |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | ?> |
|---|
Note: See
TracBrowser
for help on using the repository browser.