Example #1
0
 /**
  * Get attributes from XML layout update
  *
  * @param Varien_Simplexml_Element $layoutUpdate
  * @return array
  */
 protected function _getAttributes(Varien_Simplexml_Element $layoutUpdate)
 {
     $attributes = array();
     if ($layoutUpdate->getAttribute('name') !== null) {
         $attributes['element_name'] = $layoutUpdate->getAttribute('name');
     }
     $attributes = array_merge($attributes, parent::_getAttributes($layoutUpdate));
     return $attributes;
 }
Example #2
0
 /**
  * translate node
  *
  * @access protected
  * @param Varien_Simplexml_Element $node
  * @return Ultimate_ModuleCreator_Model_Config
  * @author Marius Strajeru <*****@*****.**>
  */
 protected function _translateNode(&$node)
 {
     if ($node->getAttribute('translate')) {
         $fields = explode(' ', $node->getAttribute('translate'));
         $module = $node->getAttribute('module') ? (string) $node->getAttribute('module') : $this->_getDefaultTranslateModule();
         foreach ($fields as $field) {
             if ($node->{$field}) {
                 $node->{$field} = Mage::helper($module)->__((string) $node->{$field});
             }
         }
     }
     if ($node->hasChildren()) {
         foreach ($node->children() as $child) {
             $this->_translateNode($child);
         }
     }
     return $this;
 }
Example #3
0
 /**
  * Get attributes from XML layout update
  *
  * @param Varien_Simplexml_Element $layoutUpdate
  * @return array
  */
 protected function _getAttributes(Varien_Simplexml_Element $layoutUpdate)
 {
     $attributes = array();
     $attributes['type'] = $layoutUpdate->getAttribute('type') ?: 'layout';
     $attributes['action_name'] = $layoutUpdate->getName();
     foreach ($layoutUpdate->attributes() as $attributeName => $attributeValue) {
         $attributes[$attributeName] = (string) $attributeValue;
     }
     return $attributes;
 }
Example #4
0
 /**
  * Lookup module name for translation from current specified layout node
  *
  * Priorities:
  * 1) "module" attribute in the element
  * 2) "module" attribute in any ancestor element
  * 3) layout handle name - first 1 or 2 parts (namespace is determined automatically)
  *
  * @param Varien_Simplexml_Element $node
  * @return string
  */
 public static function findTranslationModuleName(Varien_Simplexml_Element $node)
 {
     $result = $node->getAttribute('module');
     if ($result) {
         return (string) $result;
     }
     foreach (array_reverse($node->xpath('ancestor::*[@module]')) as $element) {
         $result = $element->getAttribute('module');
         if ($result) {
             return (string) $result;
         }
     }
     foreach ($node->xpath('ancestor-or-self::*[last()-1]') as $handle) {
         $name = Mage::getConfig()->determineOmittedNamespace($handle->getName());
         if ($name) {
             return $name;
         }
     }
     return 'core';
 }
Example #5
0
 /**
  * Load layout update attributes
  *
  * @param Varien_Simplexml_Element $layoutUpdate
  * @return array
  */
 protected static function _getAttributes(Varien_Simplexml_Element $layoutUpdate)
 {
     $attributes = array('type' => $layoutUpdate->getAttribute('type') ?: self::DEFAULT_TYPE, 'action_name' => $layoutUpdate->getName());
     return $attributes;
 }
Example #6
0
 /**
  * Get attributes from XML layout update
  *
  * @param Varien_Simplexml_Element $layoutUpdate
  * @return array
  */
 protected function _getAttributes(Varien_Simplexml_Element $layoutUpdate)
 {
     $attributes = array();
     if ($layoutUpdate->getAttribute('element') !== null) {
         $attributes['element_name'] = $layoutUpdate->getAttribute('element');
     }
     if ($layoutUpdate->getAttribute('after') !== null) {
         $attributes['origin_order'] = $attributes['destination_order'] = $layoutUpdate->getAttribute('after');
     }
     if ($layoutUpdate->getAttribute('destination') !== null) {
         $attributes['origin_container'] = $attributes['destination_container'] = $layoutUpdate->getAttribute('destination');
     }
     $attributes = array_merge($attributes, parent::_getAttributes($layoutUpdate));
     return $attributes;
 }
Example #7
0
 /**
  * Lookup module name for translation from current specified layout node
  *
  * Priorities:
  * 1) "module" attribute in the element
  * 2) "module" attribute in any ancestor element
  * 3) layout handle name - first 1 or 2 parts (namespace is determined automatically)
  *
  * @param Varien_Simplexml_Element $node
  * @return string
  */
 public static function findTranslationModuleName(Varien_Simplexml_Element $node)
 {
     // Commented out code uses not yet implemented functionality.
     $result = (string) $node->getAttribute('module');
     if ($result) {
         //return Mage::getConfig()->getModuleConfig($result) ? $result : 'core';
         return $result;
     }
     foreach (array_reverse($node->xpath('ancestor::*[@module]')) as $element) {
         $result = (string) $element->getAttribute('module');
         if ($result) {
             //return Mage::getConfig()->getModuleConfig($result) ? $result : 'core';
             return $result;
         }
     }
     foreach ($node->xpath('ancestor-or-self::*[last()-1]') as $handle) {
         $name = Mage::getConfig()->determineOmittedNamespace($handle->getName(), true);
         if ($name) {
             //return Mage::getConfig()->getModuleConfig($name) ? $name : 'core';
             return $name;
         }
     }
     return 'Mage_Core';
 }
Example #8
0
 /**
  * Determine dependency type from XML node that defines module dependency
  *
  * @param Varien_Simplexml_Element $dependencyNode
  * @return string
  * @throws UnexpectedValueException
  */
 protected function _getDependencyType(Varien_Simplexml_Element $dependencyNode)
 {
     $result = $dependencyNode->getAttribute('type') ?: self::DEPENDENCY_TYPE_HARD;
     if (!in_array($result, array(self::DEPENDENCY_TYPE_HARD, self::DEPENDENCY_TYPE_SOFT))) {
         $dependencyNodeXml = trim($dependencyNode->asNiceXml());
         throw new UnexpectedValueException("Unknown module dependency type '{$result}' in declaration '{$dependencyNodeXml}'.");
     }
     return $result;
 }
Example #9
0
 /**
  * Parse Exception Response Body
  *
  * @param string $message Exception message to parse
  * @return string
  */
 protected function _parseGdataExceptionMessage($message)
 {
     $result = array();
     foreach (explode("\n", $message) as $row) {
         if (strip_tags($row) == $row) {
             $result[] = $row;
             continue;
         }
         try {
             $xml = new Varien_Simplexml_Element($row);
             $error = $xml->getAttribute('reason');
             $result[] = $error;
         } catch (Exception $e) {
             continue;
         }
     }
     return implode(" ", $result);
 }
Example #10
0
 /**
  * Replace "unsafe" types of blocks into Mage_Core_Block_Template and cut all their actions
  *
  * A "stub" template will be assigned for the blocks
  *
  * @param Varien_Simplexml_Element $node
  */
 protected static function _sanitizeBlock(Varien_Simplexml_Element $node)
 {
     $type = $node->getAttribute('type');
     if (!$type) {
         return;
         // we encountered a node with name "block", however it doesn't actually define any block...
     }
     if (self::_isParentSafe($node) || self::_isTypeSafe($type)) {
         return;
     }
     self::_overrideAttribute($node, 'template', 'Mage_DesignEditor::stub.phtml');
     self::_overrideAttribute($node, 'type', 'Mage_Core_Block_Template');
     self::_deleteNodes($node, 'action');
 }