/**
  * @param Mage_Core_Model_Layout_Update $update
  *
  * @return bool
  */
 protected function _isAllowed(Mage_Core_Model_Layout_Update $update)
 {
     $handles = $update->getHandles();
     $allowedHandles = Mage::helper('markdown')->getAllowedLayoutHandles();
     foreach ($handles as $handle) {
         if (isset($allowedHandles[$handle])) {
             $this->_isAllowedFlag = TRUE;
             break;
         }
     }
     return $this->_isAllowedFlag;
 }
Пример #2
0
 public function templatesDataProvider()
 {
     $templates = array();
     $themes = $this->_getDesignThemes();
     foreach ($themes as $view) {
         list($area, $package, $theme) = explode('/', $view);
         $layoutUpdate = new Mage_Core_Model_Layout_Update(array('area' => $area, 'package' => $package, 'theme' => $theme));
         $layoutTemplates = $this->_getLayoutTemplates($layoutUpdate->getFileLayoutUpdatesXml());
         foreach ($layoutTemplates as $templateData) {
             $templates[] = array_merge(array($area, $package, $theme), $templateData);
         }
     }
     return $templates;
 }
Пример #3
0
 /**
  * Cleverly merge the JS and CSS files for the frontend
  *
  * @param string $area
  * @param string $package
  * @param string $theme
  * @param int $storeId = null
  * @return Mage_Core_Model_Layout_Element
  */
 public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId = null)
 {
     $xml = parent::getFileLayoutUpdatesXml($area, $package, $theme, $storeId);
     $new = array();
     foreach ($this->_methods as $method => $type) {
         $defaults = $this->_getDefaultItems($xml, $method);
         foreach ($xml->children() as $handle => $node) {
             if (in_array($handle, $this->_ignoredHandles)) {
                 continue;
             }
             if ($actions = $node->xpath(".//action[@method='" . $method . "']")) {
                 $remove = array();
                 $add = array();
                 foreach ($actions as $i => $action) {
                     list($attributes, $file) = array_values($action->asArray());
                     if (!in_array($file, $defaults)) {
                         $remove[$file] = sprintf('<action method="removeItem"><type>%s</type><file>%s</file></action>', $type, $file);
                         $add[$file] = sprintf('<action method="%s"><file>%s</file></action>', $method, $file);
                     }
                 }
                 if (count($remove) > 0 && count($add) > 0) {
                     $new[] = sprintf('<%s><reference name="head">%s<block type="opti/page_html_head" name="head.%s">%s</block></reference></%s>', $handle, implode('', $remove), $handle, implode('', $add), $handle);
                 }
             }
         }
     }
     #echo implode('', $new);exit;
     return simplexml_load_string('<layouts>' . $xml->innerXml() . (!$new ? implode('', $new) : '') . '</layouts>', $this->getElementClass());
 }
Пример #4
0
 /**
  * @magentoConfigFixture current_store advanced/modules_disable_output/Mage_Catalog true
  * @magentoConfigFixture current_store advanced/modules_disable_output/Mage_Page    true
  */
 public function testGetFileLayoutUpdatesXmlDisabledOutput()
 {
     $this->_replaceConfigLayoutUpdates('
         <catalog module="Mage_Catalog">
             <file>layout.xml</file>
         </catalog>
         <core module="Mage_Core">
             <file>layout.xml</file>
         </core>
         <page module="Mage_Page">
             <file>layout.xml</file>
         </page>
     ');
     $expectedXmlStr = $this->_readLayoutFileContents(__DIR__ . '/../_files/design/frontend/test/default/Mage_Core/layout.xml');
     $actualXml = $this->_model->getFileLayoutUpdatesXml('frontend', 'test', 'default');
     $this->assertXmlStringEqualsXmlString($expectedXmlStr, $actualXml->asNiceXml());
 }
Пример #5
0
 /**
  * Collect and merge layout updates from
  * file based on handle
  *
  * @param string $area
  * @param string $package
  * @param string $theme
  * @param integer|null $storeId
  * @return Mage_Core_Model_Layout_Element
  */
 public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId = null)
 {
     $xml = parent::getFileLayoutUpdatesXml($area, $package, $theme, $storeId);
     $shouldMergeJs = Mage::helper('mergeminify')->isJsMergeEnabled() && Mage::helper('mergeminify')->isJsMergeHandle();
     $shouldMergeCss = Mage::helper('mergeminify')->isCssMergeEnabled() && Mage::helper('mergeminify')->isCssMergeHandle();
     $methods = array();
     if ($shouldMergeJs) {
         $methods[] = 'addJs';
     }
     if ($shouldMergeCss) {
         $methods[] = 'addCss';
     }
     if ($shouldMergeJs || $shouldMergeCss) {
         $methods[] = 'addItem';
     }
     foreach ($methods as $method) {
         foreach ($xml->children() as $handle => $child) {
             $items = $child->xpath('.//action[@method=\'' . $method . '\']');
             foreach ($items as $item) {
                 if ($method == 'addItem' && (!$shouldMergeCss && (string) $item->{'type'} == 'skin_css' || !$shouldMergeJs && (string) $item->{'type'} == 'skin_js')) {
                     continue;
                 }
                 $params = $item->xpath('params');
                 if (count($params)) {
                     foreach ($params as $param) {
                         if (trim($param)) {
                             $param->{0} = (string) $param . ' ' . static::HANDLE_ATTRIBUTE . '="' . $handle . '"';
                         } else {
                             $param->{0} = static::HANDLE_ATTRIBUTE . '="' . $handle . '"';
                         }
                     }
                 } else {
                     $item->addChild('params', static::HANDLE_ATTRIBUTE . '="' . $handle . '"');
                 }
             }
         }
     }
     return $xml;
 }
 /**
  * Collect and merge layout updates from file
  *
  * @param string $area
  * @param string $package
  * @param string $theme
  * @param integer|null $storeId
  * @return Mage_Core_Model_Layout_Element
  */
 public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId = null)
 {
     $xml = parent::getFileLayoutUpdatesXml($area, $package, $theme, $storeId);
     if (Mage::getDesign()->getArea() != 'adminhtml') {
         $shouldMergeJs = Mage::getStoreConfigFlag('dev/js/merge_files') && Mage::getStoreConfigFlag('dev/js/merge_js_by_handle');
         $shouldMergeCss = Mage::getStoreConfigFlag('dev/css/merge_css_files') && Mage::getStoreConfigFlag('dev/css/merge_css_by_handle');
         $methods = array();
         if ($shouldMergeJs) {
             $methods[] = 'addJs';
         }
         if ($shouldMergeCss) {
             $methods[] = 'addCss';
         }
         if ($shouldMergeJs || $shouldMergeCss) {
             $methods[] = 'addItem';
         }
         foreach ($methods as $method) {
             foreach ($xml->children() as $handle => $child) {
                 $items = $child->xpath(".//action[@method='" . $method . "']");
                 foreach ($items as $item) {
                     $params = $item->xpath("params");
                     if (count($params)) {
                         foreach ($params as $param) {
                             if (trim($param)) {
                                 $param->{0} = (string) $param . ' title="' . $handle . '"';
                             } else {
                                 $param->{0} = 'title="' . $handle . '"';
                             }
                         }
                     } else {
                         $item->addChild('params', 'title="' . $handle . '"');
                     }
                 }
             }
         }
     }
     return $xml;
 }
Пример #7
0
 /**
  * Collect getSkinUrl() from theme templates
  *
  * @param string    $area
  * @param string    $package
  * @param string    $theme
  * @param array     &$files
  */
 protected function _collectGetSkinUrlInvokes($area, $package, $theme, &$files)
 {
     $searchDir = Mage::getBaseDir('design') . DIRECTORY_SEPARATOR . $area . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . $theme;
     $dirLength = strlen($searchDir);
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($searchDir)) as $fileInfo) {
         // Check that file path is valid
         $relativePath = substr($fileInfo->getPath(), $dirLength);
         if (!$this->_validateTemplatePath($relativePath)) {
             continue;
         }
         // Scan file for references to other files
         foreach ($this->_findReferencesToSkinFile($fileInfo) as $file) {
             $files[$area][$package][$theme][] = $file;
         }
     }
     // Collect "addCss" and "addJs" from theme layout
     $layoutUpdate = new Mage_Core_Model_Layout_Update(array('area' => $area, 'package' => $package, 'theme' => $theme));
     $fileLayoutUpdates = $layoutUpdate->getFileLayoutUpdatesXml();
     $elements = $fileLayoutUpdates->xpath('//action[@method="addCss" or @method="addJs"]/*[1]');
     if ($elements) {
         foreach ($elements as $filenameNode) {
             $skinFile = (string) $filenameNode;
             if ($this->_isFileForDisabledModule($skinFile)) {
                 continue;
             }
             $files[$area][$package][$theme][] = $skinFile;
         }
     }
 }
Пример #8
0
 /**
  * Composes full layout xml for designated parameters
  *
  * @param string $area
  * @param string $package
  * @param string $theme
  * @return Mage_Core_Model_Layout_Element
  */
 protected function _composeXml($area, $package, $theme)
 {
     $layoutUpdate = new Mage_Core_Model_Layout_Update(array('area' => $area, 'package' => $package, 'theme' => $theme));
     return $layoutUpdate->getFileLayoutUpdatesXml();
 }
Пример #9
0
 /**
  * @magentoDataFixture Mage/Core/Model/Layout/_files/db_layout_update.php
  */
 public function testFetchDbLayoutUpdates()
 {
     $this->_model->load('fixture_handle');
     $this->assertStringMatchesFormat('<reference name="root">%w<block type="Mage_Core_Block_Template" template="dummy.phtml"/>%w</reference>', trim($this->_model->asString()));
 }
Пример #10
0
 /**
  * @magentoDbIsolation enabled
  */
 public function testCrud()
 {
     $this->_model->setData(array('handle' => 'default', 'xml' => '<layout/>', 'sort_order' => 123));
     $entityHelper = new Magento_Test_Entity($this->_model, array('handle' => 'custom', 'xml' => '<layout version="0.1.0"/>', 'sort_order' => 456));
     $entityHelper->testCrud();
 }
Пример #11
0
 /**
  * Set true for flag is_vde
  *
  * @return Mage_DesignEditor_Model_Layout_Update
  */
 protected function _beforeSave()
 {
     $this->setIsVde(true);
     return parent::_beforeSave();
 }
Пример #12
0
/**
 * A layout update stored in database
 *
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Mage
 * @package     Mage_Core
 * @subpackage  integration_tests
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$layoutUpdate = new Mage_Core_Model_Layout_Update();
$layoutUpdate->setData(array('handle' => 'fixture_handle', 'xml' => '<reference name="root"><block type="Mage_Core_Block_Template" template="dummy.phtml"/></reference>', 'sort_order' => 0, 'store_id' => 1, 'area' => 'frontend', 'package' => 'test', 'theme' => 'default'));
$layoutUpdate->save();