Mage_Core_Model_Mysql4_Design Class Reference

Inheritance diagram for Mage_Core_Model_Mysql4_Design:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 _beforeSave (Mage_Core_Model_Abstract $object)
 loadChange ($storeId, $date=null)

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 28 of file Design.php.


Member Function Documentation

_beforeSave ( Mage_Core_Model_Abstract object  ) 

Perform actions before object save

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 35 of file Design.php.

00036     {
00037         $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
00038         if ($date = $object->getDateFrom()) {
00039             $date = Mage::app()->getLocale()->date($date, $format, null, false);
00040             $object->setDateFrom($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
00041         } else {
00042             $object->setDateFrom(null);
00043         }
00044 
00045         if ($date = $object->getDateTo()) {
00046             $date = Mage::app()->getLocale()->date($date, $format, null, false);
00047             $object->setDateTo($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
00048         } else {
00049             $object->setDateTo(null);
00050         }
00051 
00052         if (!is_null($object->getDateFrom()) && !is_null($object->getDateTo()) && strtotime($object->getDateFrom()) > strtotime($object->getDateTo())){
00053             Mage::throwException(Mage::helper('core')->__('Start date can\'t be greater than end date'));
00054         }
00055 
00056         $check = $this->_checkIntersection(
00057             $object->getStoreId(),
00058             $object->getDateFrom(),
00059             $object->getDateTo(),
00060             $object->getId()
00061         );
00062 
00063         if ($check){
00064             Mage::throwException(Mage::helper('core')->__('Your design change for the specified store intersects with another one, please specify another date range'));
00065         }
00066 
00067         if (is_null($object->getDateFrom()))
00068             $object->setDateFrom(new Zend_Db_Expr('null'));
00069         if (is_null($object->getDateTo()))
00070             $object->setDateTo(new Zend_Db_Expr('null'));
00071 
00072         parent::_beforeSave($object);
00073     }

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 30 of file Design.php.

00031     {
00032         $this->_init('core/design_change', 'design_change_id');
00033     }

loadChange ( storeId,
date = null 
)

Definition at line 150 of file Design.php.

00151     {
00152         if (is_null($date)) {
00153             //$date = new Zend_Db_Expr('NOW()');
00154             $date = now();
00155         }
00156 
00157         $select = $this->_getReadAdapter()->select()
00158             ->from(array('main_table'=>$this->getTable('design_change')))
00159             ->where('store_id = ?', $storeId)
00160             ->where('(date_from <= ? or date_from is null)', $date)
00161             ->where('(date_to >= ? or date_to is null)', $date);
00162 
00163         return $this->_getReadAdapter()->fetchRow($select);
00164     }


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

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