Example #1
0
 public function testPrepare()
 {
     $this->_model = new Mage_Core_Model_Layout_Element(__DIR__ . '/../_files/_layout_update.xml', 0, true);
     list($blockNode) = $this->_model->xpath('//block[@name="head"]');
     list($actionNode) = $this->_model->xpath('//action[@method="setTitle"]');
     $this->assertEmpty($blockNode->attributes()->parent);
     $this->assertEmpty($blockNode->attributes()->class);
     $this->assertEmpty($actionNode->attributes()->block);
     $this->_model->prepare(array());
     $this->assertEquals('root', (string) $blockNode->attributes()->parent);
     $this->assertEquals('Mage_Adminhtml_Block_Page_Head', (string) $blockNode->attributes()->class);
     $this->assertEquals('head', (string) $actionNode->attributes()->block);
 }
Example #2
0
 public function testPrepare()
 {
     /**
      * @TODO: Need to use ObjectManager instead 'new'.
      * On this moment we have next bug MAGETWO-4274 which blocker for this key.
      */
     $this->_model = new Mage_Core_Model_Layout_Element(__DIR__ . '/../_files/_layout_update.xml', 0, true);
     list($blockNode) = $this->_model->xpath('//block[@name="head"]');
     list($actionNode) = $this->_model->xpath('//action[@method="setTitle"]');
     $this->assertEmpty($blockNode->attributes()->parent);
     $this->assertEmpty($blockNode->attributes()->class);
     $this->assertEmpty($actionNode->attributes()->block);
     $this->_model->prepare(array());
     $this->assertEquals('root', (string) $blockNode->attributes()->parent);
     $this->assertEquals('Mage_Adminhtml_Block_Page_Head', (string) $blockNode->attributes()->class);
     $this->assertEquals('head', (string) $actionNode->attributes()->block);
 }
Example #3
0
 /**
  * Validate node's declared position in hierarchy and add errors to the specified array if found
  *
  * @param SimpleXMLElement $node
  * @param Mage_Core_Model_Layout_Element $xml
  * @param array &$errors
  */
 protected function _collectHierarchyErrors($node, $xml, &$errors)
 {
     $name = $node->getName();
     $refName = $node->getAttribute('type') == Mage_Core_Model_Layout_Update::TYPE_FRAGMENT ? $node->getAttribute('owner') : $node->getAttribute('parent');
     if ($refName) {
         $refNode = $xml->xpath("/layouts/{$refName}");
         if (!$refNode) {
             $errors[$name][] = "Node '{$refName}', referenced in hierarchy, does not exist";
         } elseif ($refNode[0]->getAttribute('type') == Mage_Core_Model_Layout_Update::TYPE_FRAGMENT) {
             $errors[$name][] = "Page fragment type '{$refName}', cannot be an ancestor in a hierarchy";
         }
     }
 }
 /**
  * Filter and collect layout handles into array
  *
  * @param Mage_Core_Model_Layout_Element $layoutHandles
  */
 protected function _collectLayoutHandles($layoutHandles)
 {
     if ($layoutHandlesArr = $layoutHandles->xpath('/*/*/label/..')) {
         foreach ($layoutHandlesArr as $node) {
             if ($this->_filterLayoutHandle($node->getName())) {
                 $helper = Mage::helper(Mage_Core_Model_Layout::findTranslationModuleName($node));
                 $this->_layoutHandles[$node->getName()] = $helper->__((string) $node->label);
             }
         }
         asort($this->_layoutHandles, SORT_STRING);
     }
 }
Example #5
0
 /**
  * The actual recursive implementation of getChildBlockNames
  *
  * @param  Mage_Core_Model_Layout_Element $blockNode
  * @return array
  */
 protected function _getChildBlockNames($blockNode)
 {
     Varien_Profiler::start('turpentine::helper::data::_getChildBlockNames');
     if ($blockNode instanceof Mage_Core_Model_Layout_Element) {
         $blockNames = array((string) $blockNode['name']);
         foreach ($blockNode->xpath('./block | ./reference') as $childBlockNode) {
             $blockNames = array_merge($blockNames, $this->_getChildBlockNames($childBlockNode));
             if ($this->getLayout() instanceof Varien_Simplexml_Config) {
                 foreach ($this->getLayout()->getNode()->xpath(sprintf('//reference[@name=\'%s\']', (string) $childBlockNode['name'])) as $childBlockLayoutNode) {
                     $blockNames = array_merge($blockNames, $this->_getChildBlockNames($childBlockLayoutNode));
                 }
             }
         }
     } else {
         $blockNames = array();
     }
     Varien_Profiler::stop('turpentine::helper::data::_getChildBlockNames');
     return $blockNames;
 }
 /**
  * The actual recursive implementation of getChildBlockNames
  *
  * @param  Mage_Core_Model_Layout_Element $blockNode
  * @return array
  */
 protected function _getChildBlockNames($blockNode)
 {
     Varien_Profiler::start('turpentine::helper::data::_getChildBlockNames');
     if ($blockNode instanceof Mage_Core_Model_Layout_Element) {
         $blockNames = array((string) $blockNode['name']);
         foreach ($blockNode->xpath('./block | ./reference') as $childBlockNode) {
             $blockNames = array_merge($blockNames, $this->_getChildBlockNames($childBlockNode));
         }
     } else {
         $blockNames = array();
     }
     Varien_Profiler::stop('turpentine::helper::data::_getChildBlockNames');
     return $blockNames;
 }