Public Member Functions | |
__construct ($attributes=array()) | |
setValue ($value, $format=null, $locale=null) | |
getValue ($format=null) | |
getValueInstance () | |
getElementHtml () | |
Protected Attributes | |
$_value |
Definition at line 34 of file Date.php.
__construct | ( | $ | attributes = array() |
) |
Enter description here...
array | $attributes |
Reimplemented from Varien_Data_Form_Element_Abstract.
Definition at line 41 of file Date.php.
00042 { 00043 parent::__construct($attributes); 00044 $this->setType('text'); 00045 $this->setExtType('textfield'); 00046 if (isset($attributes['value'])) { 00047 $this->setValue($attributes['value']); 00048 } 00049 }
getElementHtml | ( | ) |
Output the input field and assign calendar instance to it. In order to output the date:
Reimplemented from Varien_Data_Form_Element_Abstract.
Definition at line 136 of file Date.php.
00137 { 00138 $this->addClass('input-text'); 00139 00140 $html = sprintf( 00141 '<input name="%s" id="%s" value="%s" %s style="width:110px;" />' 00142 .' <img src="%s" alt="" class="v-middle" id="%s_trig" title="%s" style="%s" />', 00143 $this->getName(), $this->getHtmlId(), $this->_escape($this->getValue()), $this->serialize($this->getHtmlAttributes()), 00144 $this->getImage(), $this->getHtmlId(), __('Select Date'), ($this->getDisabled() ? 'display:none;' : '') 00145 ); 00146 $outputFormat = $this->getFormat(); 00147 if (empty($outputFormat)) { 00148 throw new Exception(__('Output format is not specified. Please, specify "format" key in constructor, or set it using setFormat().')); 00149 } 00150 $displayFormat = Varien_Date::convertZendToStrFtime($outputFormat, true, (bool)$this->getTime()); 00151 00152 $html .= sprintf(' 00153 <script type="text/javascript"> 00154 //<![CDATA[ 00155 Calendar.setup({ 00156 inputField: "%s", 00157 ifFormat: "%s", 00158 showsTime: %s, 00159 button: "%s_trig", 00160 align: "Bl", 00161 singleClick : true 00162 }); 00163 //]]> 00164 </script>', 00165 $this->getHtmlId(), $displayFormat, 00166 $this->getTime() ? 'true' : 'false', $this->getHtmlId() 00167 ); 00168 00169 $html .= $this->getAfterElementHtml(); 00170 00171 return $html; 00172 }
getValue | ( | $ | format = null |
) |
Get date value as string. Format can be specified, or it will be taken from $this->getFormat()
string | $format (compatible with Zend_Date) |
Definition at line 104 of file Date.php.
00105 { 00106 if (empty($this->_value)) { 00107 return ''; 00108 } 00109 if (null === $format) { 00110 $format = $this->getFormat(); 00111 } 00112 return $this->_value->toString($format); 00113 }
getValueInstance | ( | ) |
setValue | ( | $ | value, | |
$ | format = null , |
|||
$ | locale = null | |||
) |
Set date value If Zend_Date instance is provided instead of value, other params will be ignored. Format and locale must be compatible with Zend_Date
mixed | $value | |
string | $format | |
string | $locale |
Definition at line 61 of file Date.php.
00062 { 00063 if (empty($value)) { 00064 $this->_value = ''; 00065 return $this; 00066 } 00067 if ($value instanceof Zend_Date) { 00068 $this->_value = $value; 00069 return $this; 00070 } 00071 if (preg_match('/^[0-9]+$/', $value)) { 00072 $this->_value = new Zend_Date((int)$value); 00073 return $this; 00074 } 00075 // last check, if input format was set 00076 if (null === $format) { 00077 $format = Varien_Date::DATETIME_INTERNAL_FORMAT; 00078 if ($this->getInputFormat()) { 00079 $format = $this->getInputFormat(); 00080 } 00081 } 00082 // last check, if locale was set 00083 if (null === $locale) { 00084 if (!$locale = $this->getLocale()) { 00085 $locale = null; 00086 } 00087 } 00088 try { 00089 $this->_value = new Zend_Date($value, $format, $locale); 00090 } 00091 catch (Exception $e) { 00092 $this->_value = ''; 00093 } 00094 return $this; 00095 }