Beispiel #1
0
 public function fetchFileLayoutUpdates()
 {
     $coreConfig = AO::getConfig();
     $elementClass = $this->getElementClass();
     $design = Mage_Core_Model_Design_Package::getDesign();
     $area = $design->getArea();
     $storeId = AO::app()->getStore()->getId();
     $cacheKey = 'LAYOUT_' . $area . '_STORE' . $storeId . '_' . $design->getPackageName() . '_' . $design->getTheme('layout');
     #echo "TEST:".$cacheKey;
     $cacheTags = array('layout');
     if (AO::app()->useCache('layout') && ($layoutStr = AO::app()->loadCache($cacheKey))) {
         $this->_packageLayout = simplexml_load_string($layoutStr);
     }
     if (empty($layoutStr)) {
         $updatesRoot = $coreConfig->getNode($area . '/layout/updates');
         $updateFiles = array();
         foreach ($updatesRoot->children() as $updateNode) {
             if ($updateNode->file) {
                 $module = $coreConfig->getAttribute($updateNode, 'module');
                 if ($module && AO::getStoreConfigFlag('advanced/modules_disable_output/' . $module)) {
                     continue;
                 }
                 $updateFiles[] = (string) $updateNode->file;
             }
         }
         // custom local layout updates file - load always last
         $updateFiles[] = 'local.xml';
         $layoutStr = '';
         #$layoutXml = new $elementClass('<layouts/>');
         foreach ($updateFiles as $file) {
             $filename = $design->getLayoutFilename($file);
             if (!is_readable($filename)) {
                 continue;
             }
             $fileStr = file_get_contents($filename);
             $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
             $fileXml = simplexml_load_string($fileStr);
             if (!$fileXml instanceof SimpleXMLElement) {
                 continue;
             }
             $layoutStr .= $coreConfig->innerXml($fileXml);
             #$layoutXml->appendChild($fileXml);
         }
         $layoutXml = simplexml_load_string('<layouts>' . $layoutStr . '</layouts>');
         $this->_packageLayout = $layoutXml;
         if (AO::app()->useCache('layout')) {
             AO::app()->saveCache($this->_packageLayout->asXml(), $cacheKey, $cacheTags, null);
         }
     }
     return $this;
 }
Beispiel #2
0
 public function fetchFileLayoutUpdates()
 {
     $elementClass = $this->getElementClass();
     $design = Mage::getSingleton('core/design_package');
     $area = $design->getArea();
     $cacheKey = 'layout_' . $area . '_' . $design->getPackageName() . '_' . $design->getTheme('layout');
     $cacheTags = array('layout');
     if (Mage::app()->useCache('layout') && ($layoutStr = Mage::app()->loadCache($cacheKey))) {
         $this->_packageLayout = simplexml_load_string($layoutStr, $elementClass);
     }
     if (empty($layoutStr)) {
         $updatesRoot = Mage::app()->getConfig()->getNode($area . '/layout/updates');
         $updateFiles = array();
         foreach ($updatesRoot->children() as $updateNode) {
             if ($updateNode->file) {
                 $updateFiles[] = (string) $updateNode->file;
             }
         }
         // custom local layout updates file - load always last
         $updateFiles[] = 'local.xml';
         $layoutStr = '';
         #$layoutXml = new $elementClass('<layouts/>');
         foreach ($updateFiles as $file) {
             $filename = $design->getLayoutFilename($file);
             if (!is_readable($filename)) {
                 continue;
             }
             $fileStr = file_get_contents($filename);
             $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
             $fileXml = simplexml_load_string($fileStr, $elementClass);
             if (!$fileXml instanceof SimpleXMLElement) {
                 continue;
             }
             $layoutStr .= $fileXml->innerXml();
             #$layoutXml->appendChild($fileXml);
         }
         $layoutXml = simplexml_load_string('<layouts>' . $layoutStr . '</layouts>', $elementClass);
         $this->_packageLayout = $layoutXml;
         if (Mage::app()->useCache('layout')) {
             Mage::app()->saveCache($this->_packageLayout->asXml(), $cacheKey, $cacheTags, null);
         }
     }
     return $this;
 }
Beispiel #3
0
 /**
  * Collect  layout updates.
  *
  * TODO need to plan as for of laravel theming
  *
  * @return \Layout\Layout\Update
  */
 public function fetchFileLayoutUpdates()
 {
     $elementClass = $this->getElementClass();
     $cacheKey = 'LAYOUT_' . 'THEME_DEFAULT';
     $cacheTags = [self::LAYOUT_GENERAL_CACHE_TAG];
     if (config('layout.cache.layout') && ($layoutStr = Cache::get($cacheKey, false))) {
         $this->_moduleLayout = simplexml_load_string($layoutStr, $elementClass);
     }
     if (empty($layoutStr)) {
         $this->_moduleLayout = $this->getFileLayoutUpdatesXml();
         if (config('layout.cache.layout')) {
             if (config('cache.default') == 'file') {
                 Cache::put($cacheKey, $this->_moduleLayout->asXml(), 0);
             } else {
                 Cache::tags($cacheTags)->put($cacheKey, $this->_moduleLayout->asXml(), 0);
             }
         }
     }
     return $this;
 }
Beispiel #4
0
 public function fetchFileLayoutUpdates()
 {
     $storeId = Mage::app()->getStore()->getId();
     $elementClass = $this->getElementClass();
     $design = Mage::getSingleton('core/design_package');
     $cacheKey = 'LAYOUT_' . $design->getArea() . '_STORE' . $storeId . '_' . $design->getPackageName() . '_' . $design->getTheme('layout');
     $cacheTags = array(self::LAYOUT_GENERAL_CACHE_TAG);
     if (Mage::app()->useCache('layout') && ($layoutStr = Mage::app()->loadCache($cacheKey))) {
         $this->_packageLayout = simplexml_load_string($layoutStr, $elementClass);
     }
     if (empty($layoutStr)) {
         $this->_packageLayout = $this->getFileLayoutUpdatesXml($design->getArea(), $design->getPackageName(), $design->getTheme('layout'), $storeId);
         if (Mage::app()->useCache('layout')) {
             Mage::app()->saveCache($this->_packageLayout->asXml(), $cacheKey, $cacheTags, null);
         }
     }
     //        $elementClass = $this->getElementClass();
     //
     //        $design = Mage::getSingleton('core/design_package');
     //        $area = $design->getArea();
     //        $storeId = Mage::app()->getStore()->getId();
     //        $cacheKey = 'LAYOUT_'.$area.'_STORE'.$storeId.'_'.$design->getPackageName().'_'.$design->getTheme('layout');
     //#echo "TEST:".$cacheKey;
     //        $cacheTags = array('layout');
     //
     //        if (Mage::app()->useCache('layout') && ($layoutStr = Mage::app()->loadCache($cacheKey))) {
     //            $this->_packageLayout = simplexml_load_string($layoutStr, $elementClass);
     //        }
     //
     //        if (empty($layoutStr)) {
     //            $updatesRoot = Mage::app()->getConfig()->getNode($area.'/layout/updates');
     //            Mage::dispatchEvent('core_layout_update_updates_get_after', array('updates' => $updatesRoot));
     //            $updateFiles = array();
     //            foreach ($updatesRoot->children() as $updateNode) {
     //                if ($updateNode->file) {
     //                    $module = $updateNode->getAttribute('module');
     //                    if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module)) {
     //                        continue;
     //                    }
     //                    $updateFiles[] = (string)$updateNode->file;
     //                }
     //            }
     //
     //            // custom local layout updates file - load always last
     //            $updateFiles[] = 'local.xml';
     //
     //            $layoutStr = '';
     //            #$layoutXml = new $elementClass('<layouts/>');
     //            foreach ($updateFiles as $file) {
     //                $filename = $design->getLayoutFilename($file);
     //                if (!is_readable($filename)) {
     //                    continue;
     //                }
     //                $fileStr = file_get_contents($filename);
     //                $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);
     //                $fileXml = simplexml_load_string($fileStr, $elementClass);
     //                if (!$fileXml instanceof SimpleXMLElement) {
     //                    continue;
     //                }
     //                $layoutStr .= $fileXml->innerXml();
     //
     //                #$layoutXml->appendChild($fileXml);
     //            }
     //            $layoutXml = simplexml_load_string('<layouts>'.$layoutStr.'</layouts>', $elementClass);
     //
     //            $this->_packageLayout = $layoutXml;
     //
     //            if (Mage::app()->useCache('layout')) {
     //                Mage::app()->saveCache($this->_packageLayout->asXml(), $cacheKey, $cacheTags, null);
     //            }
     //        }
     return $this;
 }