Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date:

Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract Mage_Adminhtml_Block_Abstract Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Interface Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Datetime

List of all members.

Public Member Functions

 getHtml ()
 getEscapedValue ($index=null)
 getValue ($index=null)
 getCondition ()
 setValue ($value)
 getLocale ()

Protected Member Functions

 _prepareLayout ()
 _convertDate ($date, $locale)

Protected Attributes

 $_locale


Detailed Description

Definition at line 35 of file Date.php.


Member Function Documentation

_convertDate ( date,
locale 
) [protected]

Convert given date to default (UTC) timezone

Parameters:
string $date
string $locale
Returns:
Zend_Date

Reimplemented in Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Datetime.

Definition at line 150 of file Date.php.

00151     {
00152         try {
00153             $dateObj = $this->getLocale()->date(null, null, $locale, false);
00154 
00155             //set default timezone for store (admin)
00156             $dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
00157 
00158             //set begining of day
00159             $dateObj->setHour(00);
00160             $dateObj->setMinute(00);
00161             $dateObj->setSecond(00);
00162 
00163             //set date with applying timezone of store
00164             $dateObj->set($date, Zend_Date::DATE_SHORT, $locale);
00165 
00166             //convert store date to default date in UTC timezone without DST
00167             $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
00168 
00169             return $dateObj;
00170         }
00171         catch (Exception $e) {
00172             return null;
00173         }
00174     }

_prepareLayout (  )  [protected]

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 39 of file Date.php.

00040     {
00041         if ($head = $this->getLayout()->getBlock('head')) {
00042             $head->setCanLoadCalendarJs(true);
00043         }
00044         return $this;
00045     }

getCondition (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract.

Definition at line 104 of file Date.php.

00105     {
00106         $value = $this->getValue();
00107 
00108         return $value;
00109     }

getEscapedValue ( index = null  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract.

Reimplemented in Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Datetime.

Definition at line 80 of file Date.php.

00081     {
00082         $value = $this->getValue($index);
00083         if ($value instanceof Zend_Date) {
00084             return $value->toString($this->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
00085         }
00086         return $value;
00087     }

getHtml (  ) 

Reimplemented from Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract.

Reimplemented in Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Datetime.

Definition at line 47 of file Date.php.

00048     {
00049         $htmlId = $this->_getHtmlId() . microtime(true);
00050         $format = $this->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
00051         $html = '<div class="range"><div class="range-line date">
00052             <span class="label">' . Mage::helper('adminhtml')->__('From').':</span>
00053             <input type="text" name="'.$this->_getHtmlName().'[from]" id="'.$htmlId.'_from" value="'.$this->getEscapedValue('from').'" class="input-text no-changes"/>
00054             <img src="' . Mage::getDesign()->getSkinUrl('images/grid-cal.gif') . '" alt="" class="v-middle" id="'.$htmlId.'_from_trig" title="'.$this->htmlEscape(Mage::helper('adminhtml')->__('Date selector')).'"/>
00055             </div>';
00056         $html.= '<div class="range-line date">
00057             <span class="label">' . Mage::helper('adminhtml')->__('To').' :</span>
00058             <input type="text" name="'.$this->_getHtmlName().'[to]" id="'.$htmlId.'_to" value="'.$this->getEscapedValue('to').'" class="input-text no-changes"/>
00059             <img src="' . Mage::getDesign()->getSkinUrl('images/grid-cal.gif') . '" alt="" class="v-middle" id="'.$htmlId.'_to_trig" title="'.$this->htmlEscape(Mage::helper('adminhtml')->__('Date selector')).'"/>
00060             </div></div>';
00061         $html.= '<input type="hidden" name="'.$this->_getHtmlName().'[locale]" value="'.$this->getLocale()->getLocaleCode().'"/>';
00062         $html.= '<script type="text/javascript">
00063             Calendar.setup({
00064                 inputField : "'.$htmlId.'_from",
00065                 ifFormat : "'.$format.'",
00066                 button : "'.$htmlId.'_from_trig",
00067                 align : "Bl",
00068                 singleClick : true
00069             });
00070             Calendar.setup({
00071                 inputField : "'.$htmlId.'_to",
00072                 ifFormat : "'.$format.'",
00073                 button : "'.$htmlId.'_to_trig",
00074                 align : "Bl",
00075                 singleClick : true
00076             });
00077         </script>';
00078         return $html;
00079     }

getLocale (  ) 

Retrieve locale

Returns:
Mage_Core_Model_Locale

Definition at line 135 of file Date.php.

00136     {
00137         if (!$this->_locale) {
00138             $this->_locale = Mage::app()->getLocale();
00139         }
00140         return $this->_locale;
00141     }

getValue ( index = null  ) 

Reimplemented in Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Datetime.

Definition at line 89 of file Date.php.

00090     {
00091         if ($index) {
00092             if ($data = $this->getData('value', 'orig_' . $index)) {
00093                 return $data;//date('Y-m-d', strtotime($data));
00094             }
00095             return null;
00096         }
00097         $value = $this->getData('value');
00098         if (is_array($value)) {
00099             $value['date'] = true;
00100         }
00101         return $value;
00102     }

setValue ( value  ) 

Definition at line 111 of file Date.php.

00112     {
00113         if (isset($value['locale'])) {
00114             if (!empty($value['from'])) {
00115                 $value['orig_from'] = $value['from'];
00116                 $value['from'] = $this->_convertDate($value['from'], $value['locale']);
00117             }
00118             if (!empty($value['to'])) {
00119                 $value['orig_to'] = $value['to'];
00120                 $value['to'] = $this->_convertDate($value['to'], $value['locale']);
00121             }
00122         }
00123         if (empty($value['from']) && empty($value['to'])) {
00124             $value = null;
00125         }
00126         $this->setData('value', $value);
00127         return $this;
00128     }


Member Data Documentation

$_locale [protected]

Definition at line 37 of file Date.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:08 2009 for Magento by  doxygen 1.5.8