00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class Mage_Core_Model_Mysql4_Layout extends Mage_Core_Model_Mysql4_Abstract
00029 {
00030 protected function _construct()
00031 {
00032 $this->_init('core/layout_update', 'layout_update_id');
00033 }
00034
00035
00036
00037
00038
00039
00040
00041 public function fetchUpdatesByHandle($handle, $params = array())
00042 {
00043 $storeId = isset($params['store_id']) ? $params['store_id'] : Mage::app()->getStore()->getId();
00044 $package = isset($params['package']) ? $params['package'] : Mage::getSingleton('core/design_package')->getPackageName();
00045 $theme = isset($params['theme']) ? $params['theme'] : Mage::getSingleton('core/design_package')->getTheme('layout');
00046
00047 $read = $this->_getReadAdapter();
00048 $updateStr = '';
00049
00050 if ($read) {
00051 $select = $read->select()->from(array('update'=>$this->getMainTable()), 'xml')
00052 ->join(array('link'=>$this->getTable('core/layout_link')), 'link.layout_update_id=update.layout_update_id', '')
00053 ->where('link.store_id=?', $storeId)
00054 ->where('link.package=?', $package)
00055 ->where('link.theme=?', $theme);
00056
00057 if ($updates = $read->fetchAll($select)) {
00058 foreach ($updates as $update) {
00059 $updateStr .= $update['xml'];
00060 }
00061 }
00062 }
00063 return $updateStr;
00064 }
00065 }