File indexing completed on 2025-03-02 05:29:19
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Dojo 0017 * @subpackage Form_Element 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** Zend_Dojo_Form_Element_DateTextBox */ 0023 // require_once 'Zend/Dojo/Form/Element/DateTextBox.php'; 0024 0025 /** 0026 * TimeTextBox dijit 0027 * 0028 * @uses Zend_Dojo_Form_Element_DateTextBox 0029 * @package Zend_Dojo 0030 * @subpackage Form_Element 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 * @version $Id$ 0034 */ 0035 class Zend_Dojo_Form_Element_TimeTextBox extends Zend_Dojo_Form_Element_DateTextBox 0036 { 0037 /** 0038 * Use TimeTextBox dijit view helper 0039 * @var string 0040 */ 0041 public $helper = 'TimeTextBox'; 0042 0043 /** 0044 * Validate ISO 8601 time format 0045 * 0046 * @param string $format 0047 * @return true 0048 * @throws Zend_Form_Element_Exception 0049 */ 0050 protected function _validateIso8601($format) 0051 { 0052 if (!preg_match('/^T\d{2}:\d{2}:\d{2}$/', $format)) { 0053 // require_once 'Zend/Form/Element/Exception.php'; 0054 throw new Zend_Form_Element_Exception(sprintf('Invalid format "%s" provided; must match T:00:00:00 format', $format)); 0055 } 0056 return true; 0057 } 0058 0059 /** 0060 * Set time format pattern 0061 * 0062 * @param string $pattern 0063 * @return Zend_Dojo_Form_Element_NumberTextBox 0064 */ 0065 public function setTimePattern($pattern) 0066 { 0067 $this->setConstraint('timePattern', (string) $pattern); 0068 return $this; 0069 } 0070 0071 /** 0072 * Retrieve time format pattern 0073 * 0074 * @return string|null 0075 */ 0076 public function getTimePattern() 0077 { 0078 return $this->getConstraint('timePattern'); 0079 } 0080 0081 /** 0082 * Set clickableIncrement 0083 * 0084 * @param string $format 0085 * @return Zend_Dojo_Form_Element_NumberTextBox 0086 */ 0087 public function setClickableIncrement($format) 0088 { 0089 $format = (string) $format; 0090 $this->_validateIso8601($format); 0091 $this->setConstraint('clickableIncrement', $format); 0092 return $this; 0093 } 0094 0095 /** 0096 * Retrieve clickableIncrement 0097 * 0098 * @return string|null 0099 */ 0100 public function getClickableIncrement() 0101 { 0102 return $this->getConstraint('clickableIncrement'); 0103 } 0104 0105 /** 0106 * Set visibleIncrement 0107 * 0108 * @param string $format 0109 * @return Zend_Dojo_Form_Element_NumberTextBox 0110 */ 0111 public function setVisibleIncrement($format) 0112 { 0113 $format = (string) $format; 0114 $this->_validateIso8601($format); 0115 $this->setConstraint('visibleIncrement', $format); 0116 return $this; 0117 } 0118 0119 /** 0120 * Retrieve visibleIncrement 0121 * 0122 * @return string|null 0123 */ 0124 public function getVisibleIncrement() 0125 { 0126 return $this->getConstraint('visibleIncrement'); 0127 } 0128 0129 /** 0130 * Set visibleRange 0131 * 0132 * @param string $format 0133 * @return Zend_Dojo_Form_Element_NumberTextBox 0134 */ 0135 public function setVisibleRange($format) 0136 { 0137 $format = (string) $format; 0138 $this->_validateIso8601($format); 0139 $this->setConstraint('visibleRange', $format); 0140 return $this; 0141 } 0142 0143 /** 0144 * Retrieve visibleRange 0145 * 0146 * @return string|null 0147 */ 0148 public function getVisibleRange() 0149 { 0150 return $this->getConstraint('visibleRange'); 0151 } 0152 }