1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Core_Block_Html_Date extends Mage_Core_Block_Template
36: {
37:
38: protected function _toHtml()
39: {
40: $displayFormat = Varien_Date::convertZendToStrFtime($this->getFormat(), true, (bool)$this->getTime());
41:
42: $html = '<input type="text" name="' . $this->getName() . '" id="' . $this->getId() . '" ';
43: $html .= 'value="' . $this->escapeHtml($this->getValue()) . '" class="' . $this->getClass() . '" ' . $this->getExtraParams() . '/> ';
44:
45: $html .= '<img src="' . $this->getImage() . '" alt="' . $this->helper('core')->__('Select Date') . '" class="v-middle" ';
46: $html .= 'title="' . $this->helper('core')->__('Select Date') . '" id="' . $this->getId() . '_trig" />';
47:
48: $html .=
49: '<script type="text/javascript">
50: //<![CDATA[
51: var calendarSetupObject = {
52: inputField : "' . $this->getId() . '",
53: ifFormat : "' . $displayFormat . '",
54: showsTime : "' . ($this->getTime() ? 'true' : 'false') . '",
55: button : "' . $this->getId() . '_trig",
56: align : "Bl",
57: singleClick : true
58: }';
59:
60: $calendarYearsRange = $this->getYearsRange();
61: if ($calendarYearsRange) {
62: $html .= '
63: calendarSetupObject.range = ' . $calendarYearsRange . '
64: ';
65: }
66:
67: $html .= '
68: Calendar.setup(calendarSetupObject);
69: //]]>
70: </script>';
71:
72:
73: return $html;
74: }
75:
76: public function getEscapedValue($index=null) {
77:
78: if($this->getFormat() && $this->getValue()) {
79: return strftime($this->getFormat(), strtotime($this->getValue()));
80: }
81:
82: return htmlspecialchars($this->getValue());
83: }
84:
85: public function getHtml()
86: {
87: return $this->toHtml();
88: }
89:
90: }
91: