|
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_ValidationTextBox */ |
|
23 require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php'; |
|
24 |
|
25 /** |
|
26 * DateTextBox dijit |
|
27 * |
|
28 * @uses Zend_Dojo_Form_Element_ValidationTextBox |
|
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: DateTextBox.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
34 */ |
|
35 class Zend_Dojo_Form_Element_DateTextBox extends Zend_Dojo_Form_Element_ValidationTextBox |
|
36 { |
|
37 /** |
|
38 * Use DateTextBox dijit view helper |
|
39 * @var string |
|
40 */ |
|
41 public $helper = 'DateTextBox'; |
|
42 |
|
43 /** |
|
44 * Allowed formatLength types |
|
45 * @var array |
|
46 */ |
|
47 protected $_allowedFormatTypes = array( |
|
48 'long', |
|
49 'short', |
|
50 'medium', |
|
51 'full', |
|
52 ); |
|
53 |
|
54 /** |
|
55 * Allowed selector types |
|
56 * @var array |
|
57 */ |
|
58 protected $_allowedSelectorTypes = array( |
|
59 'time', |
|
60 'date', |
|
61 ); |
|
62 |
|
63 /** |
|
64 * Set am,pm flag |
|
65 * |
|
66 * @param bool $am,pm |
|
67 * @return Zend_Dojo_Form_Element_DateTextBox |
|
68 */ |
|
69 public function setAmPm($flag) |
|
70 { |
|
71 $this->setConstraint('am,pm', (bool) $flag); |
|
72 return $this; |
|
73 } |
|
74 |
|
75 /** |
|
76 * Retrieve am,pm flag |
|
77 * |
|
78 * @return bool |
|
79 */ |
|
80 public function getAmPm() |
|
81 { |
|
82 if (!$this->hasConstraint('am,pm')) { |
|
83 return false; |
|
84 } |
|
85 return ('true' ==$this->getConstraint('am,pm')); |
|
86 } |
|
87 |
|
88 /** |
|
89 * Set strict flag |
|
90 * |
|
91 * @param bool $strict |
|
92 * @return Zend_Dojo_Form_Element_DateTextBox |
|
93 */ |
|
94 public function setStrict($flag) |
|
95 { |
|
96 $this->setConstraint('strict', (bool) $flag); |
|
97 return $this; |
|
98 } |
|
99 |
|
100 /** |
|
101 * Retrieve strict flag |
|
102 * |
|
103 * @return bool |
|
104 */ |
|
105 public function getStrict() |
|
106 { |
|
107 if (!$this->hasConstraint('strict')) { |
|
108 return false; |
|
109 } |
|
110 return ('true' == $this->getConstraint('strict')); |
|
111 } |
|
112 |
|
113 /** |
|
114 * Set locale |
|
115 * |
|
116 * @param string $locale |
|
117 * @return Zend_Dojo_Form_Element_DateTextBox |
|
118 */ |
|
119 public function setLocale($locale) |
|
120 { |
|
121 $this->setConstraint('locale', (string) $locale); |
|
122 return $this; |
|
123 } |
|
124 |
|
125 /** |
|
126 * Retrieve locale |
|
127 * |
|
128 * @return string|null |
|
129 */ |
|
130 public function getLocale() |
|
131 { |
|
132 return $this->getConstraint('locale'); |
|
133 } |
|
134 |
|
135 /** |
|
136 * Set date format pattern |
|
137 * |
|
138 * @param string $pattern |
|
139 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
140 */ |
|
141 public function setDatePattern($pattern) |
|
142 { |
|
143 $this->setConstraint('datePattern', (string) $pattern); |
|
144 return $this; |
|
145 } |
|
146 |
|
147 /** |
|
148 * Retrieve date format pattern |
|
149 * |
|
150 * @return string|null |
|
151 */ |
|
152 public function getDatePattern() |
|
153 { |
|
154 return $this->getConstraint('datePattern'); |
|
155 } |
|
156 |
|
157 /** |
|
158 * Set numeric format formatLength |
|
159 * |
|
160 * @see $_allowedFormatTypes |
|
161 * @param string $formatLength |
|
162 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
163 */ |
|
164 public function setFormatLength($formatLength) |
|
165 { |
|
166 $formatLength = strtolower($formatLength); |
|
167 if (!in_array($formatLength, $this->_allowedFormatTypes)) { |
|
168 require_once 'Zend/Form/Element/Exception.php'; |
|
169 throw new Zend_Form_Element_Exception(sprintf('Invalid formatLength "%s" specified', $formatLength)); |
|
170 } |
|
171 |
|
172 $this->setConstraint('formatLength', $formatLength); |
|
173 return $this; |
|
174 } |
|
175 |
|
176 /** |
|
177 * Retrieve formatLength |
|
178 * |
|
179 * @return string|null |
|
180 */ |
|
181 public function getFormatLength() |
|
182 { |
|
183 return $this->getConstraint('formatLength'); |
|
184 } |
|
185 |
|
186 /** |
|
187 * Set numeric format Selector |
|
188 * |
|
189 * @see $_allowedSelectorTypes |
|
190 * @param string $selector |
|
191 * @return Zend_Dojo_Form_Element_NumberTextBox |
|
192 */ |
|
193 public function setSelector($selector) |
|
194 { |
|
195 $selector = strtolower($selector); |
|
196 if (!in_array($selector, $this->_allowedSelectorTypes)) { |
|
197 require_once 'Zend/Form/Element/Exception.php'; |
|
198 throw new Zend_Form_Element_Exception(sprintf('Invalid Selector "%s" specified', $selector)); |
|
199 } |
|
200 |
|
201 $this->setConstraint('selector', $selector); |
|
202 return $this; |
|
203 } |
|
204 |
|
205 /** |
|
206 * Retrieve selector |
|
207 * |
|
208 * @return string|null |
|
209 */ |
|
210 public function getSelector() |
|
211 { |
|
212 return $this->getConstraint('selector'); |
|
213 } |
|
214 } |