コード例 #1
0
ファイル: Layout.php プロジェクト: macosxvn/techheroes
 /**
  * If all ifconfig conditions are ok then action runs
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Codnitive_Extifcon_Model_Core_Layout
  */
 private function _runAction($node, $parent)
 {
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helperName = explode('/', (string) $arg['helper']);
                     $helperMethod = array_pop($helperName);
                     $helperName = implode('/', $helperName);
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 } else {
                     /**
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = array();
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }
コード例 #2
0
ファイル: Layout.php プロジェクト: aoepeople/aoe_layout
 /**
  * Convert an action node into a method call on the parent block
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  *
  * @return Aoe_Layout_Model_Layout
  */
 protected function _generateAction($node, $parent)
 {
     if ($node instanceof Mage_Core_Model_Layout_Element) {
         if (!$this->checkConditionals($node)) {
             return $this;
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         $jsonArgs = isset($node['json']) ? explode(' ', (string) $node['json']) : [];
         $jsonHelper = Mage::helper('core');
         $translateArgs = isset($node['translate']) ? explode(' ', (string) $node['translate']) : [];
         $translateHelper = Mage::helper(isset($node['module']) ? (string) $node['module'] : 'core');
         $args = $this->processActionArgs($args, $jsonArgs, $jsonHelper, $translateArgs, $translateHelper);
         call_user_func_array([$block, $method], $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }
コード例 #3
0
ファイル: Layout.php プロジェクト: dragontheme1235/project-1
 /**
  * Checks ifconfig and conditions to run action or not
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Codnitive_Extifcon_Model_Core_Layout
  */
 protected function _generateAction($node, $parent)
 {
     $compiler = Mage::getModel('dgttheme/system_layout_compiler');
     if (isset($node['ifconfig']) && ($configPath = (string) $node['ifconfig'])) {
         $condition = true;
         if (isset($node['condition'])) {
             $condition = $compiler->getXmlCondition($compiler->spaceRemover($node['condition']));
         }
         $config = $compiler->getAdminConfig($compiler->spaceRemover($configPath));
         if ($config !== $condition) {
             return $this;
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helperName = explode('/', (string) $arg['helper']);
                     $helperMethod = array_pop($helperName);
                     $helperName = implode('/', $helperName);
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 } else {
                     /**
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = array();
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }
コード例 #4
0
ファイル: Layout.php プロジェクト: relue/magento2
 /**
  * Enter description here...
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Mage_Core_Model_Layout
  */
 protected function _generateAction($node, $parent)
 {
     if (isset($node['ifconfig']) && ($configPath = (string) $node['ifconfig'])) {
         if (!Mage::getStoreConfigFlag($configPath)) {
             return $this;
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK_ACTION:' . $parentName . '>' . $method;
     Magento_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helper = (string) $arg['helper'];
                     if (strpos($helper, '::') === false) {
                         $helperName = explode('/', $helper);
                         $helperMethod = array_pop($helperName);
                         $helperName = implode('/', $helperName);
                     } else {
                         list($helperName, $helperMethod) = explode('::', $helper);
                     }
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 } else {
                     /**
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = array();
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Mage::helper('Mage_Core_Helper_Data')->jsonDecode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Magento_Profiler::stop($_profilerKey);
     return $this;
 }
コード例 #5
0
ファイル: Layout.php プロジェクト: amr-z/advanced-ifconfig
 /**
  * Modified core generate action method
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Mage_Core_Model_Layout
  */
 protected function _generateAction($node, $parent)
 {
     if (isset($node['ifconfig']) && ($configPath = (string) $node['ifconfig'])) {
         $ifConfig = Mage::getStoreConfigFlag($configPath);
         $nodeArray = (array) $node;
         $advIfconfig = null;
         $dependsCheck = false;
         $requiredDepends = false;
         if (isset($nodeArray['adv_ifconfig'])) {
             $advIfconfig = (array) $nodeArray['adv_ifconfig'];
             if (isset($advIfconfig['depends_check'])) {
                 $dependsCheck = $advIfconfig['depends_check'];
             }
             if (isset($advIfconfig['required_depends'])) {
                 $requiredDepends = $advIfconfig['required_depends'];
             }
         }
         if ($ifConfig && $dependsCheck) {
             if ($dependsCheck == 1 || $dependsCheck == 'tree') {
                 $configPath = explode('/', $configPath);
                 $ifConfig = $ifConfig && Mage::helper('advifconfig')->checkSystemConfigNodeDepends($configPath[0], $configPath[1], $configPath[2], $ifConfig);
             }
             if (($dependsCheck == 1 || $dependsCheck == 'required') && $requiredDepends) {
                 $additionalDepends = array_map('trim', explode(',', $requiredDepends));
                 foreach ($additionalDepends as $depend) {
                     $ifConfig = $ifConfig && Mage::getStoreConfigFlag($depend);
                 }
             }
         }
         if (!$ifConfig) {
             return $this;
         }
         if (isset($advIfconfig['custom_rules'])) {
             $data = array_merge(array('ifconfig' => false), (array) $advIfconfig['custom_rules']);
             $data = new Varien_Object($data);
             Mage::dispatchEvent('adv_ifconfig_custom_rules', $data);
             if (!$data->getIfconfig()) {
                 return $this;
             }
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         if (isset($args['adv_ifconfig'])) {
             unset($args['adv_ifconfig']);
         }
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helperName = explode('/', (string) $arg['helper']);
                     $helperMethod = array_pop($helperName);
                     $helperName = implode('/', $helperName);
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 } else {
                     /**
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = array();
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }
コード例 #6
0
ファイル: Layout.php プロジェクト: arslbbt/mangentovies
 /**
  * Enter description here...
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Mage_Core_Model_Layout
  */
 protected function _generateAction($node, $parent)
 {
     if (isset($node['ifconfig']) && ($configPath = (string) $node['ifconfig'])) {
         if (!Mage::getStoreConfigFlag($configPath)) {
             return $this;
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helperName = explode('/', (string) $arg['helper']);
                     $helperMethod = array_pop($helperName);
                     $helperName = implode('/', $helperName);
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Zend_Json::decode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }