예제 #1
0
 /**
  * Add items into collection object
  *
  * @param Varien_Simplexml_Element $stagingItem
  * @return Enterprise_Staging_Model_Resource_Staging_Item_Xml_Collection
  */
 public function addStagingItemToCollection($stagingItem)
 {
     $extendInfo = $this->getExtendInfo();
     $_code = (string) $stagingItem->getName();
     $item = Mage::getModel('enterprise_staging/staging_item')->loadFromXmlStagingItem($stagingItem);
     $disabled = false;
     $checked = true;
     $availabilityText = "";
     //process extend information
     if (!empty($extendInfo) && is_array($extendInfo) && isset($extendInfo[$_code])) {
         $item->addData($extendInfo[$_code]);
         if ($extendInfo[$_code]["disabled"] == true) {
             $disabled = true;
             $checked = false;
             $availabilityText = $extendInfo[$_code]["reason"];
         } else {
             $availabilityText = Mage::helper('enterprise_staging')->__('available');
         }
     }
     $item->setData('id', $_code);
     $item->setData('code', $_code);
     $item->setData('checked', $checked);
     $item->setData('disabled', $disabled);
     $item->setData('availability_text', $availabilityText);
     $this->addItem($item);
     return $this;
 }
예제 #2
0
 /**
  * reads an import specification.
  * @see README.md
  * @param Varien_Simplexml_Element $specNode
  * @param Varien_Simplexml_Element $groupNode
  * @param string $configPath
  */
 private function _readImportSpec(Varien_Simplexml_Element $specNode, Varien_Simplexml_Element $groupNode, $configPath)
 {
     foreach ($specNode->children() as $moduleName => $moduleNode) {
         Mage::dispatchEvent(self::EVENT_PREFIX . $moduleName, $this->_prepareEventData($groupNode, $moduleNode, $configPath));
     }
     return $this;
 }
예제 #3
0
 /**
  * Generate sitemap xml
  *
  * @return string
  */
 public function generateXml()
 {
     $storeId = $this->getStoreId();
     $date = date('Y-m-d');
     $simplexml = new Varien_Simplexml_Element('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
     $simplexml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     /**
      * Generate categories sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/category/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/category/priority');
     $categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect('*')->load();
     foreach ($categories as $category) {
         $category = Mage::getModel('catalog/category')->load($category->getId());
         if (!$category->getIsActive()) {
             continue;
         }
         $url = $simplexml->addChild('url');
         $url->addChild('loc', $category->getCategoryUrl());
         $url->addChild('lastmod', $date);
         $url->addChild('changefreq', $changefreq);
         $url->addChild('priority', $priority);
     }
     /**
      * Generate products sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/product/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/product/priority');
     $products = Mage::getModel('catalog/product')->setStoreId($storeId)->getCollection()->addAttributeToSelect('*');
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     $products->load();
     foreach ($products as $product) {
         $product = Mage::getModel('catalog/product')->load($product->getId());
         $url = $simplexml->addChild('url');
         $url->addChild('loc', $product->getProductUrl());
         $url->addChild('lastmod', $date);
         $url->addChild('changefreq', $changefreq);
         $url->addChild('priority', $priority);
     }
     /**
      * Generate CMS pages sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/page/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/page/priority');
     $pages = Mage::getModel('cms/page')->setStoreId($storeId)->getCollection();
     foreach ($pages as $page) {
         $page = Mage::getModel('cms/page')->load($page->getId());
         $url = $simplexml->addChild('url');
         $url->addChild('loc', Mage::getBaseUrl() . $page->getIdentifier());
         $url->addChild('lastmod', $date);
         $url->addChild('changefreq', $changefreq);
         $url->addChild('priority', $priority);
     }
     // record last generation time
     $this->setSitemapTime(now());
     $this->save();
     return $simplexml->asXml();
 }
예제 #4
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;
 }
예제 #5
0
 /**
  * Create config field during runtime.
  *
  * @param Varien_Simplexml_Element $section
  * @return N98_CheckoutFilters_Model_Adminhtml_Config_Observer
  */
 public function createConfigFields($section)
 {
     /**
      * Check if we are in sales tab and sub-tab payment or shipping.
      * Then we create SimpleXMLElements for form init.
      */
     if ($section->tab == 'sales') {
         if (in_array($section->label, array('Payment Methods', 'Shipping Methods'))) {
             foreach ($section->groups as $group) {
                 foreach ($group as $subGroup) {
                     if (isset($subGroup->fields)) {
                         $this->_addCustomergroupFieldToConfigGroup($subGroup);
                     }
                 }
             }
         }
         // Add fields only for payment methods
         if (in_array($section->label, array('Payment Methods'))) {
             foreach ($section->groups as $group) {
                 foreach ($group as $subGroup) {
                     if (isset($subGroup->fields)) {
                         $this->_addMinYearFieldToConfigGroup($subGroup);
                     }
                 }
             }
         }
     }
     /**
      * Paypal uses a special config tab
      */
     if ($section->tab == 'sales' && $section->getName() == 'paypal') {
         if (isset($section->groups->express)) {
             $this->_addCustomergroupFieldToConfigGroup($section->groups->express);
             $this->_addMinYearFieldToConfigGroup($section->groups->express);
         }
         if (isset($section->groups->wps)) {
             $this->_addCustomergroupFieldToConfigGroup($section->groups->wps);
             $this->_addMinYearFieldToConfigGroup($section->groups->wps);
         }
         if (isset($section->groups->wpp)) {
             $this->_addCustomergroupFieldToConfigGroup($section->groups->wpp);
             $this->_addMinYearFieldToConfigGroup($section->groups->wpp);
         }
     }
     /**
      * Ebizmarts_Sagepay uses a special config tab
      */
     if ('sales' == $section->tab && 'sagepaysuite' == $section->getName()) {
         $my_groups = array('sagepayserver', 'sagepayserver_moto', 'sagepaydirectpro_moto', 'sagepaydirectpro', 'sagepayform', 'sagepaypaypal', 'sagepayrepeat');
         foreach ($my_groups as $group) {
             $this_group = $section->groups->{$group};
             $this->_addCustomergroupFieldToConfigGroup($this_group);
             $this->_addMinYearFieldToConfigGroup($this_group);
         }
     }
     return $this;
 }
예제 #6
0
파일: Rule.php 프로젝트: santhosh400/ecart
 /**
  * @todo need create typical interface
  */
 public function import($filePath)
 {
     $content = file_get_contents($filePath);
     $xml = new Varien_Simplexml_Element($content);
     $template = $xml->asArray();
     $model = $this->getCollection()->addFieldToFilter('name', $template['name'])->getFirstItem();
     $model->addData($template)->save();
     return $model;
 }
 /**
  * Returns a scalar representation of actual value,
  * Returns $other if internal acutal value is not set
  *
  * @param Varien_Simplexml_Element $other
  * @return scalar
  */
 protected function getActualValue($other = null)
 {
     if (!$this->_useActualValue && $other->hasChildren()) {
         return $this->getXmlAsDom($other);
     } elseif (!$this->_useActualValue) {
         return (string) $other;
     }
     return parent::getActualValue($other);
 }
예제 #8
0
 /**
  * Returns setup resource for module setup scripts
  * 
  * @param Varien_Simplexml_Element $xml
  * @return string
  */
 protected function getResourceName(Varien_Simplexml_Element $xml)
 {
     foreach ($xml->children() as $resourceNode) {
         if (isset($resourceNode->setup->module) && (string) $resourceNode->setup->module === $this->_moduleName) {
             return $resourceNode->getName();
         }
     }
     return false;
 }
예제 #9
0
 /**
  * @covers Mage_DesignEditor_Model_Layout::sanitizeLayout
  * @expectedException Mage_Core_Exception
  * @expectedExceptionMessage Invalid block type: Namespace_Module_Block_NotSafe
  */
 public function testGenerateElements()
 {
     $layout = $this->_getLayoutWithTestUpdate();
     $layout->generateElements();
     $expectedXml = new Varien_Simplexml_Element(file_get_contents(__DIR__ . '/_files/expected_layout_update.xml'));
     $this->assertStringMatchesFormat($expectedXml->asNiceXml(), $layout->getNode()->asNiceXml());
     $layout = $this->_getLayoutWithTestUpdate(false);
     $layout->generateElements();
 }
예제 #10
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;
 }
예제 #11
0
 public function getData()
 {
     $xml = new \Varien_Simplexml_Element('<config></config>');
     $defaultNode = $xml->addChild('global')->addChild('limesoda')->addChild('environments')->addChild('default');
     foreach ($this->_collection as $item) {
         /** @var $item \Mage_Core_Model_Config_Data */
         $defaultNode->addChild($this->_getNodeName($item), $this->_getNodeValue($item));
     }
     return $xml->asXML();
 }
예제 #12
0
 /**
  * Returns list of module setup resources
  * 
  * @param Varien_Simplexml_Element $xml
  * @return array
  */
 protected function getModuleSetupResources(Varien_Simplexml_Element $xml)
 {
     $resourcesForModule = array();
     foreach ($xml->children() as $resourceNode) {
         if (isset($resourceNode->setup->module) && (string) $resourceNode->setup->module === $this->_moduleName) {
             $resourcesForModule[] = $resourceNode->getName();
         }
     }
     return $resourcesForModule;
 }
 /**
  * Add block object to layout based on xml node data
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Mage_Core_Model_Layout
  */
 protected function _generateBlock($node, $parent)
 {
     $viewerEnabled = Mage::getStoreConfigFlag('dev/debug/widgetslotviewer_enable');
     if ($viewerEnabled && isset($node->label)) {
         $blockLabel = $node->label;
         $viewerName = $node['name'] . '.slot_viewer';
         $viewerXml = "<block type='core/template' name='{$viewerName}' template='widgetslotviewer/slotviewer.phtml'>" . "<action method='setParentLabel'><label>{$blockLabel}</label></action>" . "</block>";
         $viewerChild = new Varien_Simplexml_Element($viewerXml);
         $node->appendChild($viewerChild);
     }
     return parent::_generateBlock($node, $parent);
 }
예제 #14
0
 protected function _getHelperValue(Varien_Simplexml_Element $child)
 {
     $helperName = 'adminhtml';
     $titleNodeName = 'title';
     $childAttributes = $child->attributes();
     if (isset($childAttributes['module'])) {
         $helperName = (string) $childAttributes['module'];
     }
     //        if (isset($childAttributes['translate'])) {
     //            $titleNodeName  = (string)$childAttributes['translate'];
     //        }
     return Mage::helper($helperName)->__((string) $child->{$titleNodeName});
 }
예제 #15
0
 /**
  * Extends one node
  *
  * @param Varien_Simplexml_Element $source
  * @param boolean                  $overwrite
  *
  * @return Varien_Simplexml_Element
  * @access public
  */
 public function extendChild($source, $overwrite = false)
 {
     // this will be our new target node
     $targetChild = null;
     // name of the source node
     $sourceName = $source->getName();
     // here we have children of our source node
     $sourceChildren = $source->children();
     if (!$source->hasChildren()) {
         // handle string node
         if (isset($this->{$sourceName})) {
             // if target already has children return without regard
             if ($this->{$sourceName}->children()) {
                 return $this;
             }
             if ($overwrite) {
                 if (Mage::registry('conflict_datastore_enabled')) {
                     $factory = new Bronto_Verify_Model_Path_Locator_Factory();
                     $locator = $factory->getLocator();
                     $dataStore = Mage::registry('conflict_datastore');
                     $dataStore->addRewrite((string) $this->{$sourceName}, (string) $source, Mage::registry('conflict_datastore_config_file'), $locator->getPath($source));
                 }
                 unset($this->{$sourceName});
             } else {
                 return $this;
             }
         }
         $targetChild = $this->addChild($sourceName, $source->xmlentities());
         $targetChild->setParent($this);
         foreach ($source->attributes() as $key => $value) {
             $targetChild->addAttribute($key, $this->xmlentities($value));
         }
         return $this;
     }
     if (isset($this->{$sourceName})) {
         $targetChild = $this->{$sourceName};
     }
     if (is_null($targetChild)) {
         // if child target is not found create new and descend
         $targetChild = $this->addChild($sourceName);
         $targetChild->setParent($this);
         foreach ($source->attributes() as $key => $value) {
             $targetChild->addAttribute($key, $this->xmlentities($value));
         }
     }
     // finally add our source node children to resulting new target node
     foreach ($sourceChildren as $childNode) {
         $targetChild->extendChild($childNode, $overwrite);
     }
     return $this;
 }
예제 #16
0
 /**
  * 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;
 }
예제 #17
0
 public function import($path)
 {
     $content = file_get_contents($path);
     $xml = new Varien_Simplexml_Element($content);
     $design = $xml->asArray();
     if (isset($design['styles64'])) {
         $design['styles'] = base64_decode($design['styles64']);
     }
     if (isset($design['template64'])) {
         $design['template'] = base64_decode($design['template64']);
     }
     $model = $this->getCollection()->addFieldToFilter('title', $design['title'])->getFirstItem();
     $model->addData($design)->save();
     return $model;
 }
예제 #18
0
 /**
  * Covers Magento bug in 1.3.2.4
  * 
  * @param Varien_Simplexml_Element $element
  * @return array
  */
 protected function _varienSimpleXMLElementAsArray($element)
 {
     if (Mage::helper('awfeatured')->checkVersion('1.4')) {
         return $element->asArray();
     }
     $result = array();
     foreach ($element as $key => $value) {
         if (get_class($value) == 'Varien_Simplexml_Element' && count($value) > 0) {
             $result[$key] = $this->_varienSimpleXMLElementAsArray($value);
         } else {
             $result[$key] = (string) $value;
         }
     }
     return $result;
 }
예제 #19
0
 /**
  * Initialize form element
  *
  * @param array $element
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param array $group
  * @param array $section
  * @param string $path
  * @param string $fieldPrefix
  * @param string $labelPrefix
  */
 protected function _initElement($element, $fieldset, $group, $section, $path, $fieldPrefix = '', $labelPrefix = '')
 {
     $elementId = $section['id'] . '_' . $group['id'] . '_' . $fieldPrefix . $element['id'];
     if (array_key_exists($path, $this->_configData)) {
         $data = $this->_configData[$path];
         $inherit = false;
     } else {
         $data = $this->_configRoot->descend($path);
         $inherit = true;
     }
     $fieldRenderer = $this->_getFieldRenderer($element);
     $fieldRenderer->setForm($this);
     $fieldRenderer->setConfigData($this->_configData);
     $helperName = $this->_systemConfig->getAttributeModule($section, $group, $element);
     $fieldType = isset($element['type']) ? $element['type'] : 'text';
     $name = 'groups[' . $group['id'] . '][fields][' . $fieldPrefix . $element['id'] . '][value]';
     $label = $this->helper($helperName)->__($labelPrefix) . ' ' . $this->helper($helperName)->__(array_key_exists('label', $element) ? (string) $element['label'] : '');
     $hint = isset($element['hint']) ? $this->helper($helperName)->__($element['hint']) : '';
     if (isset($element['backend_model'])) {
         $data = $this->_fetchBackendModelData($element, $path, $data);
     }
     $comment = $this->_prepareFieldComment($element, $helperName, $data);
     $tooltip = $this->_prepareFieldTooltip($element, $helperName);
     if (isset($element['depends'])) {
         $this->_processElementDependencies($element, $section, $group, $elementId, $fieldPrefix);
     }
     $field = $fieldset->addField($elementId, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'tooltip' => $tooltip, 'hint' => $hint, 'value' => $data, 'inherit' => $inherit, 'class' => isset($element['frontend_class']) ? $element['frontend_class'] : '', 'field_config' => $element, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($element), 'can_use_default_value' => $this->canUseDefaultValue(isset($element['showInDefault']) ? (int) $element['showInDefault'] : 0), 'can_use_website_value' => $this->canUseWebsiteValue(isset($element['showInWebsite']) ? (int) $element['showInWebsite'] : 0)));
     $this->_applyFieldConfiguration($field, $element);
     $field->setRenderer($fieldRenderer);
     if (isset($element['source_model'])) {
         $field->setValues($this->_extractDataFromSourceModel($element, $path, $fieldType));
     }
 }
예제 #20
0
파일: Config.php 프로젝트: nemphys/magento2
 /**
  * System configuration section, fieldset or field label getter
  *
  * @param string $sectionName
  * @param string $groupName
  * @param string $fieldName
  * @return string
  */
 public function getSystemConfigNodeLabel($sectionName, $groupName = null, $fieldName = null)
 {
     $sectionName = trim($sectionName, '/');
     $path = '//sections/' . $sectionName;
     $groupNode = $fieldNode = null;
     $sectionNode = $this->_sections->xpath($path);
     if (!empty($groupName)) {
         $path .= '/groups/' . trim($groupName, '/');
         $groupNode = $this->_sections->xpath($path);
     }
     if (!empty($fieldName)) {
         if (!empty($groupName)) {
             $path .= '/fields/' . trim($fieldName, '/');
             $fieldNode = $this->_sections->xpath($path);
         } else {
             Mage::throwException(Mage::helper('Mage_Adminhtml_Helper_Data')->__('The group node name must be specified with field node name.'));
         }
     }
     $moduleName = $this->getAttributeModule($sectionNode, $groupNode, $fieldNode);
     $systemNode = $this->_sections->xpath($path);
     foreach ($systemNode as $node) {
         return Mage::helper($moduleName)->__((string) $node->label);
     }
     return '';
 }
예제 #21
0
 /**
  * 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;
 }
예제 #22
0
 /**
  * Postdispatch action handler
  *
  */
 public function logAction()
 {
     if (!$this->_initAction) {
         return;
     }
     $username = null;
     $userId = null;
     if (Mage::getSingleton('admin/session')->isLoggedIn()) {
         $userId = Mage::getSingleton('admin/session')->getUser()->getId();
         $username = Mage::getSingleton('admin/session')->getUser()->getUsername();
     }
     $errors = Mage::getModel('adminhtml/session')->getMessages()->getErrors();
     $loggingEvent = Mage::getModel('enterprise_logging/event')->setData(array('ip' => Mage::helper('core/http')->getRemoteAddr(), 'x_forwarded_ip' => Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR'), 'user' => $username, 'user_id' => $userId, 'is_success' => empty($errors), 'fullaction' => $this->_initAction, 'error_message' => implode("\n", array_map(create_function('$a', 'return $a->toString();'), $errors))));
     if ($this->_actionName == 'denied') {
         $_conf = $this->_config->getNode($this->_initAction);
         if (!$_conf || !$this->_config->isActive($this->_initAction)) {
             return;
         }
         $loggingEvent->setAction($_conf->action);
         $loggingEvent->setEventCode($_conf->getParent()->getParent()->getName());
         $loggingEvent->setInfo(Mage::helper('enterprise_logging')->__('Access denied'));
         $loggingEvent->setIsSuccess(0);
         $loggingEvent->save();
         return;
     }
     if ($this->_skipNextAction) {
         return;
     }
     $loggingEvent->setAction($this->_eventConfig->action);
     $loggingEvent->setEventCode($this->_eventConfig->getParent()->getParent()->getName());
     try {
         $callback = isset($this->_eventConfig->post_dispatch) ? (string) $this->_eventConfig->post_dispatch : false;
         $defaulfCallback = 'postDispatchGeneric';
         $classMap = $this->_getCallbackFunction($callback, $this->_controllerActionsHandler, $defaulfCallback);
         $handler = $classMap['handler'];
         $callback = $classMap['callback'];
         if (!$handler) {
             return;
         }
         if ($handler->{$callback}($this->_eventConfig, $loggingEvent, $this)) {
             /**
              * Prepare additional info
              */
             if ($this->getCollectedAdditionalData()) {
                 $loggingEvent->setAdditionalInfo($this->getCollectedAdditionalData());
             }
             $loggingEvent->save();
             if ($eventId = $loggingEvent->getId()) {
                 foreach ($this->_eventChanges as $changes) {
                     if ($changes && ($changes->getOriginalData() || $changes->getResultData())) {
                         $changes->setEventId($eventId);
                         $changes->save();
                     }
                 }
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
 /**
  * @param Varien_Object $context
  * @param Varien_Simplexml_Element $module
  * @param Varien_Simplexml_Element $entity
  * @param Varien_Simplexml_Element $scope
  */
 public function _createPrimaryKey($context, $module, $entity, $scope)
 {
     if ((string) $scope['module'] != $this->getModuleName() || (string) $scope['version'] != $this->getVersion()) {
         return;
     }
     /* @var $configHelper Mana_Db_Helper_Config */
     $configHelper = Mage::helper('mana_db/config');
     $primaryField = $scope->xpath('fields/*[primary="1"]');
     if (empty($primaryField)) {
         $scope->fields->id->type = 'bigint';
         $field = $scope->fields->id;
         $field->primary = 1;
         $field->role = Mana_Db_Helper_Config::ROLE_PRIMARY_KEY;
         $configHelper->propagateName($field);
         $configHelper->propagateAttributes($scope, $field, array('module', 'version'));
     }
 }
예제 #24
0
 public function updateMenu(Varien_Simplexml_Element $node)
 {
     $entityTypesCollection = $this->_getEntityTypesCollection();
     if ($entityTypesCollection->getSize()) {
         $children = $node->addChild('children');
         $index = 0;
         foreach ($entityTypesCollection as $entityType) {
             $index += 10;
             $menuItem = $children->addChild(sprintf('goodahead_etm_entity_type_%d', $entityType->getId()));
             $menuItem->addChild('title', strlen($entityType->getEntityTypeName()) ? $entityType->getEntityTypeName() : $entityType->getEntityTypeCode());
             $menuItem->addChild('sort_order', $index);
             $menuItem->addChild('action', sprintf((string) $node->base_link, $entityType->getId()));
         }
     } else {
         $nodeName = $node->getName();
         unset($node->getParent()->{$nodeName});
     }
 }
예제 #25
0
 /**
  * Init fieldset fields
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param Varien_Simplexml_Element $group
  * @param Varien_Simplexml_Element $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
 {
     foreach ($group->fields as $elements) {
         $elements = (array) $elements;
         usort($elements, array($this, '_sortForm'));
         foreach ($elements as $e) {
             if (!$this->_canShowField($e)) {
                 continue;
             }
             $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName();
             $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName();
             if (isset($this->_configData[$path])) {
                 $data = $this->_configData[$path];
                 $inherit = false;
             } else {
                 $data = $this->_configRoot->descend($path);
                 $inherit = true;
             }
             if ($e->frontend_model) {
                 $fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model);
             } else {
                 $fieldRenderer = $this->_defaultFieldRenderer;
             }
             $fieldRenderer->setForm($this);
             $fieldRenderer->setConfigData($this->_configData);
             $helperName = $this->_configFields->getAttributeModule($section, $group, $e);
             $fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text';
             $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $e->getName() . '][value]';
             $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $e->label);
             $comment = (string) $e->comment ? Mage::helper($helperName)->__((string) $e->comment) : '';
             if ($e->backend_model) {
                 $model = Mage::getModel((string) $e->backend_model);
                 if (!$model instanceof Mage_Core_Model_Config_Data) {
                     Mage::throwException('Invalid config field backend model: ' . (string) $e->backend_model);
                 }
                 $model->setPath($path)->setValue($data)->afterLoad();
                 $data = $model->getValue();
             }
             $field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'value' => $data, 'inherit' => $inherit, 'class' => $e->frontend_class, 'field_config' => $e, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'can_use_default_value' => $this->canUseDefaultValue((int) $e->show_in_default), 'can_use_website_value' => $this->canUseWebsiteValue((int) $e->show_in_website)));
             if (isset($e->validate)) {
                 $field->addClass($e->validate);
             }
             if (isset($e->frontend_type) && 'multiselect' === (string) $e->frontend_type && isset($e->can_be_empty)) {
                 $field->setCanBeEmpty(true);
             }
             $field->setRenderer($fieldRenderer);
             if ($e->source_model) {
                 $sourceModel = Mage::getSingleton((string) $e->source_model);
                 if ($sourceModel instanceof Varien_Object) {
                     $sourceModel->setPath($path);
                 }
                 $field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
             }
         }
     }
     return $this;
 }
예제 #26
0
 /**
  * Returns nodes found by xpath expression
  *
  * @param string $xpath
  * @return array
  */
 public function getXpath($xpath)
 {
     if (empty($this->_xml)) {
         return false;
     }
     if (!($result = @$this->_xml->xpath($xpath))) {
         return false;
     }
     return $result;
 }
예제 #27
0
 /**
  * @param Mana_Db_Model_Entity_Indexer $indexer provides access to process record and indexer setup
  * @param Varien_Simplexml_Element $target setup in config.xml
  * @param Varien_Simplexml_Element $scope setup in m_db.xml
  * @param array $options on which records to run
  * @return void
  */
 public function flattenScope($indexer, $target, $scope, $options)
 {
     /** @noinspection PhpUndefinedFieldInspection */
     $targetEntity = (string) $target->entity . '/' . $scope->getName();
     if (isset($options['entity_filters']) && !isset($options['entity_filters'][$targetEntity])) {
         return;
     }
     $options = array_merge(array('provide_field_details_in_exceptions' => true), $options);
     if (isset($options['entity_filters']) && !isset($options['entity_filter_formula'])) {
         $options['entity_filter_formula'] = '{{= ' . $options['entity_filters'][$targetEntity] . '}}';
     }
     $db = $this->_getWriteAdapter();
     /* @var $res Mage_Core_Model_Resource */
     $res = Mage::getSingleton('core/resource');
     /* @var $dbHelper Mana_Db_Helper_Data */
     $dbHelper = Mage::helper('mana_db');
     /* @var $formulaHelper Mana_Db_Helper_Formula */
     $formulaHelper = Mage::helper('mana_db/formula');
     // get basic select from all source tables, properly joined (based on m_db.xml)
     /** @noinspection PhpUndefinedFieldInspection */
     $entity = (string) $scope->flattens;
     //$db->query($formulaHelper->delete($entity, $targetEntity));
     // get formula hashes and formula texts
     $formulaGroups = $formulaHelper->getFormulaGroups($targetEntity, $options);
     // for each formula hash => formula text
     foreach ($formulaGroups as $formulas) {
         $formulas = $formulas ? json_decode($formulas, true) : array();
         // filter basic select by formula hash
         $context = $formulaHelper->select($targetEntity, $formulas, $options);
         // convert SELECT into UPDATE which acts as INSERT on DUPLICATE unique keys
         $sql = $context->getSelect()->insertFromSelect($res->getTableName($dbHelper->getScopedName($targetEntity)), $context->getFields());
         // run the statement
         try {
             $db->query($sql);
         } catch (Exception $e) {
             /* @var $logger Mana_Core_Helper_Logger */
             $logger = Mage::helper('mana_core/logger');
             $logger->logDbIndexerFailure($sql);
             throw $e;
         }
     }
 }
예제 #28
0
 public static function toOptionArray()
 {
     $result = array();
     $path = 'http://facebook.com/translations/FacebookLocales.xml';
     if (file_exists($path)) {
         $xml = new Varien_Simplexml_Element($path, 0, true);
         $xmlData = $xml->children();
         $locales = $xmlData;
         foreach ($locales as $locale) {
             $data = $locale->asArray();
             $codes = $data['codes'];
             $code = trim($codes['code']['standard']['representation']);
             $label = $data['englishName'];
             $result[] = array('value' => $code, 'label' => $label);
         }
     } else {
         $result[] = array('value' => 'en_US', 'label' => 'English (US)');
     }
     return $result;
 }
예제 #29
0
 protected function _getBaseClass(Varien_Simplexml_Element $config)
 {
     $model = null;
     if ($config->class) {
         $model = (string) $config->class;
     } elseif ($config->model) {
         $model = (string) $config->model;
     } else {
         /**
          * Backwards compatibility for pre-MMDB extensions. MMDB introduced since Magebto 1.6.0.0
          * In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left
          * to keep name of previously used nodes, that still may be used by non-updated extensions.
          */
         $deprecatedNodes = $config->xpath('../*[deprecatedNode="' . (string) $config->getName() . '"]');
         if ($deprecatedNodes && $deprecatedNodes[0]->class) {
             $model = (string) $deprecatedNodes[0]->class;
         }
     }
     if (is_null($model)) {
         return false;
     }
     return $this->_getModelClassName($model, $config);
 }
예제 #30
0
 /**
  * Install application using temporary directory and vendor-specific database settings
  *
  * @throws Magento_Exception
  */
 protected function _install()
 {
     $this->_ensureDirExists($this->_installDir);
     $this->_ensureDirExists($this->_installEtcDir);
     $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'media');
     $this->_ensureDirExists($this->_installDir . DIRECTORY_SEPARATOR . 'skin');
     /* Copy *.xml configuration files */
     $dirs = array($this->_installEtcDir => $this->_globalEtcFiles, $this->_installEtcDir . '/modules' => $this->_moduleEtcFiles);
     foreach ($dirs as $targetEtcDir => $sourceEtcFiles) {
         $this->_ensureDirExists($targetEtcDir);
         foreach ($sourceEtcFiles as $sourceEtcFile) {
             $targetEtcFile = $targetEtcDir . '/' . basename($sourceEtcFile);
             copy($sourceEtcFile, $targetEtcFile);
         }
     }
     /* Make sure that local.xml contains an invalid installation date */
     $installDate = (string) $this->_localXml->global->install->date;
     if ($installDate && strtotime($installDate)) {
         throw new Magento_Exception("Configuration file '{$this->_localXmlFile}' must contain an invalid installation date.");
     }
     /* Replace local.xml */
     $targetLocalXml = $this->_installEtcDir . '/local.xml';
     $this->_localXml->asNiceXml($targetLocalXml);
     /* Initialize an application in non-installed mode */
     $this->initialize();
     /* Run all install and data-install scripts */
     Mage_Core_Model_Resource_Setup::applyAllUpdates();
     Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
     /* Enable configuration cache by default in order to improve tests performance */
     Mage::app()->getCacheInstance()->saveOptions(array('config' => 1));
     /* Fill installation date in local.xml to indicate that application is installed */
     $localXml = file_get_contents($targetLocalXml);
     $localXml = str_replace($installDate, date('r'), $localXml, $replacementCount);
     if ($replacementCount != 1) {
         throw new Magento_Exception("Unable to replace installation date properly in '{$targetLocalXml}' file.");
     }
     file_put_contents($targetLocalXml, $localXml, LOCK_EX);
     /* Add predefined admin user to the system */
     $this->_createAdminUser();
     /* Make a database backup to be able to restore it to initial state any time */
     $this->_db->createBackup(self::DB_BACKUP_NAME);
     /* Switch an application to installed mode */
     $this->initialize();
     /**
      * Initialization of front controller with all routers.
      * Should be here as needed only once after installation process.
      */
     Mage::app()->getFrontController();
 }