|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Dojo |
|
17 * @subpackage Form_Element |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 */ |
|
21 |
|
22 /** Zend_Dojo_Form_Element_DateTextBox */ |
|
23 require_once 'Zend/Dojo/Form/Element/DateTextBox.php'; |
|
24 |
|
25 /** |
|
26 * TimeTextBox dijit |
|
27 * |
|
28 * @uses Zend_Dojo_Form_Element_DateTextBox |
|
29 * @package Zend_Dojo |
|
30 * @subpackage Form_Element |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 * @version $Id: TimeTextBox.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
34 */ |
|
35 class Zend_Dojo_Form_Element_TimeTextBox extends Zend_Dojo_Form_Element_DateTextBox |
|
36 { |
|
37 /** |
|
38 * Use TimeTextBox dijit view helper |
|
39 * @var string |
|
40 */ |
|
41 public $helper = 'TimeTextBox'; |
|
42 |
|
43 /** |
|
44 * Validate ISO 8601 time format |
|
45 * |
|
46 * @param string $format |
|
47 * @return true |
|
48 * @throws Zend_Form_Element_Exception |
|
49 */ |
|
50 protected function _validateIso8601($format) |
|
51 { |
|
52 if (!preg_match('/^T\d{2}:\d{2}:\d{2}$/', $format)) { |
|
53 require_once 'Zend/Form/Element/Exception.php'; |
|
54 throw new Zend_Form_Element_Exception(sprintf('Invalid format "%s" provided; must match T:00:00:00 format', $format)); |
|
55 } |
|
56 return true; |
|
57 } |
|
58 |
|
59 /** |
|
60 * Set time format pattern |
|
61 * |
|
62 * @param string $pattern |
|
63 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
64 */ |
|
65 public function setTimePattern($pattern) |
|
66 { |
|
67 $this->setConstraint('timePattern', (string) $pattern); |
|
68 return $this; |
|
69 } |
|
70 |
|
71 /** |
|
72 * Retrieve time format pattern |
|
73 * |
|
74 * @return string|null |
|
75 */ |
|
76 public function getTimePattern() |
|
77 { |
|
78 return $this->getConstraint('timePattern'); |
|
79 } |
|
80 |
|
81 /** |
|
82 * Set clickableIncrement |
|
83 * |
|
84 * @param string $format |
|
85 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
86 */ |
|
87 public function setClickableIncrement($format) |
|
88 { |
|
89 $format = (string) $format; |
|
90 $this->_validateIso8601($format); |
|
91 $this->setConstraint('clickableIncrement', $format); |
|
92 return $this; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Retrieve clickableIncrement |
|
97 * |
|
98 * @return string|null |
|
99 */ |
|
100 public function getClickableIncrement() |
|
101 { |
|
102 return $this->getConstraint('clickableIncrement'); |
|
103 } |
|
104 |
|
105 /** |
|
106 * Set visibleIncrement |
|
107 * |
|
108 * @param string $format |
|
109 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
110 */ |
|
111 public function setVisibleIncrement($format) |
|
112 { |
|
113 $format = (string) $format; |
|
114 $this->_validateIso8601($format); |
|
115 $this->setConstraint('visibleIncrement', $format); |
|
116 return $this; |
|
117 } |
|
118 |
|
119 /** |
|
120 * Retrieve visibleIncrement |
|
121 * |
|
122 * @return string|null |
|
123 */ |
|
124 public function getVisibleIncrement() |
|
125 { |
|
126 return $this->getConstraint('visibleIncrement'); |
|
127 } |
|
128 |
|
129 /** |
|
130 * Set visibleRange |
|
131 * |
|
132 * @param string $format |
|
133 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
134 */ |
|
135 public function setVisibleRange($format) |
|
136 { |
|
137 $format = (string) $format; |
|
138 $this->_validateIso8601($format); |
|
139 $this->setConstraint('visibleRange', $format); |
|
140 return $this; |
|
141 } |
|
142 |
|
143 /** |
|
144 * Retrieve visibleRange |
|
145 * |
|
146 * @return string|null |
|
147 */ |
|
148 public function getVisibleRange() |
|
149 { |
|
150 return $this->getConstraint('visibleRange'); |
|
151 } |
|
152 } |