当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Model_Layout::getNode方法代码示例

本文整理汇总了PHP中Mage_Core_Model_Layout::getNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Layout::getNode方法的具体用法?PHP Mage_Core_Model_Layout::getNode怎么用?PHP Mage_Core_Model_Layout::getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Core_Model_Layout的用法示例。


在下文中一共展示了Mage_Core_Model_Layout::getNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processFiles

 /**
  * @param Mage_Core_Controller_Varien_Action $action
  * @param Mage_Core_Model_Layout $layout
  */
 public function processFiles($action, $layout)
 {
     // TODO: refactor phases, find positions, then insert all, then delete all
     Mana_Core_Profiler::start(__METHOD__);
     $layoutXml = $layout->getNode();
     $layoutDom = new DOMDocument('1.0');
     $layoutNode = $layoutDom->importNode(dom_import_simplexml($layoutXml), true);
     $layoutDom->appendChild($layoutNode);
     $layoutXPath = new DOMXPath($layoutDom);
     $layoutModified = false;
     $headBlock = $this->_findHeadBlock($layoutXPath);
     $prototypeAction = $this->_findPrototypeAction($layoutXPath);
     $insertOnDemand = array();
     $insertEverywhere = array();
     $delete = array();
     $onDemandInsertPlace = null;
     $xpath = '';
     foreach ($this->_getFileConfig() as $name => $fileConfig) {
         /* @var $config array */
         /* @var $options array */
         extract($fileConfig);
         if ($xpath) {
             $xpath .= ' | ';
         }
         $xpath .= $this->_getActionsXPath($config);
     }
     foreach ($layoutXPath->query($xpath) as $element) {
         $onDemandInsertPlace = $element;
         break;
     }
     // handle javascript minification, merging and inclusion on all pages
     foreach ($this->_getFileConfig() as $name => $fileConfig) {
         /* @var $config array */
         /* @var $options array */
         extract($fileConfig);
         if (in_array('skip', $options)) {
             continue;
         }
         // find all statically defined actions of including a given script
         $fileActions = $this->_findDomActions($layoutXPath, $config);
         // prepare layout XML action depending on script parameters
         $action = $this->_createConfigurableAction($layoutDom, $config, $options);
         // insert script where and if appropriate
         if (in_array('ondemand', $options)) {
             if ($fileAction = $this->_getFirstElement($fileActions)) {
                 $insertOnDemand[] = array($action, $onDemandInsertPlace);
             }
             $delete[] = $fileActions;
         } elseif (in_array('everywhere', $options)) {
             $insertEverywhere[] = $action;
             foreach (array_reverse($insertOnDemand) as $insertOptions) {
                 list($action, $fileAction) = $insertOptions;
                 array_unshift($insertEverywhere, $action);
             }
             $insertOnDemand = array();
             $delete[] = $fileActions;
         } elseif (in_array('unload', $options)) {
             $delete[] = $fileActions;
         }
     }
     // insert configurable on demand js files
     foreach ($insertOnDemand as $insertOptions) {
         list($action, $fileAction) = $insertOptions;
         /* @var $fileAction DOMElement */
         $fileAction->parentNode->insertBefore($action, $fileAction);
         $layoutModified = true;
     }
     // insert configurable global js files
     if ($prototypeAction) {
         foreach (array_reverse($insertEverywhere) as $action) {
             $prototypeAction->parentNode->insertBefore($action, $prototypeAction->nextSibling);
             $layoutModified = true;
         }
     } elseif ($headBlock) {
         foreach (array_reverse($insertEverywhere) as $action) {
             $headBlock->insertBefore($action, $headBlock->firstChild);
             $layoutModified = true;
         }
     }
     // delete js files includes via layout XML instructions
     foreach ($delete as $fileActions) {
         foreach ($fileActions as $firstFileAction) {
             /* @var $firstFileAction DOMElement */
             $firstFileAction->parentNode->removeChild($firstFileAction);
             $layoutModified = true;
         }
     }
     if ($layoutModified) {
         $layout->loadDom($layoutNode);
     }
     Mana_Core_Profiler::stop(__METHOD__);
 }
开发者ID:smitmanglam,项目名称:staging,代码行数:96,代码来源:Js.php


注:本文中的Mage_Core_Model_Layout::getNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。