public function getDataSlide($num) { $slide = 'slide' . $num; $xml = new Varien_Simplexml_Config(Mage::getBaseDir() . '/app/code/local/Etheme/Evoqueparallax/Model/data_slides.xml'); $slides = $xml->getXpath('slides'); $slides = $slides[0]; return (string) $slides->{$slide}; }
function getRewritesList() { $moduleFiles = glob(Mage::getBaseDir('etc') . DS . 'modules' . DS . '*.xml'); if (!$moduleFiles) { return false; } // load file contents $unsortedConfig = new Varien_Simplexml_Config(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($moduleFiles as $filePath) { $fileConfig->loadFile($filePath); $unsortedConfig->extend($fileConfig); } // create sorted config [only active modules] $sortedConfig = new Varien_Simplexml_Config(); $sortedConfig->loadString('<config><modules/></config>'); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if ('true' === (string) $moduleNode->active) { $sortedConfig->getNode('modules')->appendChild($moduleNode); } } $fileConfig = new Varien_Simplexml_Config(); $_finalResult = array(); foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { $codePool = (string) $moduleNode->codePool; $configPath = BP . DS . 'app' . DS . 'code' . DS . $codePool . DS . uc_words($moduleName, DS) . DS . 'etc' . DS . 'config.xml'; $fileConfig->loadFile($configPath); $rewriteBlocks = array('blocks', 'models', 'helpers'); foreach ($rewriteBlocks as $param) { if (!isset($_finalResult[$param])) { $_finalResult[$param] = array(); } if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewrite')) { foreach ($rewrites as $rewrite) { $parentElement = $rewrite->xpath('../..'); foreach ($parentElement[0] as $moduleKey => $moduleItems) { $moduleItemsArray['rewrite'] = array(); $moduleItemsArray['codePool'] = array(); foreach ($moduleItems->rewrite as $rewriteLine) { foreach ($rewriteLine as $key => $value) { $moduleItemsArray['rewrite'][$key] = (string) $value; $moduleItemsArray['codePool'][$key] = $codePool; } } if ($moduleItems->rewrite) { $_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray)); } } } } } } return $_finalResult; }
/** * Lookup configuration nodes by full action name * * @param string $fullActionName * @return array */ protected function _getNodesByFullActionName($fullActionName) { if (!$fullActionName) { return array(); } $actionNodes = $this->_xmlConfig->getXpath("/logging/*/actions/{$fullActionName}[1]"); if ($actionNodes) { return $actionNodes; } return array(); }
/** * Parse xml tracking response * * @param string $trackingvalue * @param string $response * @return null */ protected function _parseXmlTrackingResponse($trackingvalue, $xmlResponse) { $errorTitle = 'Unable to retrieve tracking'; $resultArr = array(); $packageProgress = array(); if ($xmlResponse) { $xml = new Varien_Simplexml_Config(); $xml->loadString($xmlResponse); $arr = $xml->getXpath("//TrackResponse/Response/ResponseStatusCode/text()"); $success = (int) $arr[0][0]; if ($success === 1) { $arr = $xml->getXpath("//TrackResponse/Shipment/Service/Description/text()"); $resultArr['service'] = (string) $arr[0]; $arr = $xml->getXpath("//TrackResponse/Shipment/PickupDate/text()"); $resultArr['shippeddate'] = (string) $arr[0]; $arr = $xml->getXpath("//TrackResponse/Shipment/Package/PackageWeight/Weight/text()"); $weight = (string) $arr[0]; $arr = $xml->getXpath("//TrackResponse/Shipment/Package/PackageWeight/UnitOfMeasurement/Code/text()"); $unit = (string) $arr[0]; $resultArr['weight'] = "{$weight} {$unit}"; $activityTags = $xml->getXpath("//TrackResponse/Shipment/Package/Activity"); if ($activityTags) { $i = 1; foreach ($activityTags as $activityTag) { $addArr = array(); if (isset($activityTag->ActivityLocation->Address->City)) { $addArr[] = (string) $activityTag->ActivityLocation->Address->City; } if (isset($activityTag->ActivityLocation->Address->StateProvinceCode)) { $addArr[] = (string) $activityTag->ActivityLocation->Address->StateProvinceCode; } if (isset($activityTag->ActivityLocation->Address->CountryCode)) { $addArr[] = (string) $activityTag->ActivityLocation->Address->CountryCode; } $dateArr = array(); $date = (string) $activityTag->Date; //YYYYMMDD $dateArr[] = substr($date, 0, 4); $dateArr[] = substr($date, 4, 2); $dateArr[] = substr($date, -2, 2); $timeArr = array(); $time = (string) $activityTag->Time; //HHMMSS $timeArr[] = substr($time, 0, 2); $timeArr[] = substr($time, 2, 2); $timeArr[] = substr($time, -2, 2); if ($i == 1) { $resultArr['status'] = (string) $activityTag->Status->StatusType->Description; $resultArr['deliverydate'] = implode('-', $dateArr); //YYYY-MM-DD $resultArr['deliverytime'] = implode(':', $timeArr); //HH:MM:SS $resultArr['deliverylocation'] = (string) $activityTag->ActivityLocation->Description; $resultArr['signedby'] = (string) $activityTag->ActivityLocation->SignedForByName; if ($addArr) { $resultArr['deliveryto'] = implode(', ', $addArr); } } else { $tempArr = array(); $tempArr['activity'] = (string) $activityTag->Status->StatusType->Description; $tempArr['deliverydate'] = implode('-', $dateArr); //YYYY-MM-DD $tempArr['deliverytime'] = implode(':', $timeArr); //HH:MM:SS if ($addArr) { $tempArr['deliverylocation'] = implode(', ', $addArr); } $packageProgress[] = $tempArr; } $i++; } $resultArr['progressdetail'] = $packageProgress; } } else { $arr = $xml->getXpath("//TrackResponse/Response/Error/ErrorDescription/text()"); $errorTitle = (string) $arr[0][0]; } } if (!$this->_result) { $this->_result = Mage::getModel('shipping/tracking_result'); } $defaults = $this->getDefaults(); if ($resultArr) { $tracking = Mage::getModel('shipping/tracking_result_status'); $tracking->setCarrier('ups'); $tracking->setCarrierTitle($this->getConfigData('title')); $tracking->setTracking($trackingvalue); $tracking->addData($resultArr); $this->_result->append($tracking); } else { $error = Mage::getModel('shipping/tracking_result_error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); $error->setTracking($trackingvalue); $error->setErrorMessage($errorTitle); $this->_result->append($error); } return $this->_result; }
/** * Retrive possible conflicts list * * @return array */ public function getConflictList() { $moduleFiles = glob($this->_etcDir . 'modules' . DIRECTORY_SEPARATOR . '*.xml'); if (!$moduleFiles) { return false; } // load file contents $unsortedConfig = new Varien_Simplexml_Config(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($moduleFiles as $filePath) { $fileConfig->loadFile($filePath); $unsortedConfig->extend($fileConfig); } // create sorted config [only active modules] $sortedConfig = new Varien_Simplexml_Config(); $sortedConfig->loadString('<config><modules/></config>'); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if ('true' === (string) $moduleNode->active) { $sortedConfig->getNode('modules')->appendChild($moduleNode); } } $fileConfig = new Varien_Simplexml_Config(); $_finalResult = array(); $_finalResultAbstract = array(); foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { $codePool = (string) $moduleNode->codePool; $configPath = $this->_codeDir . $codePool . DIRECTORY_SEPARATOR . uc_words($moduleName, DS) . DIRECTORY_SEPARATOR . 'etc' . DS . 'config.xml'; $fileConfig->loadFile($configPath); $rewriteBlocks = array('blocks', 'models', 'helpers'); foreach ($rewriteBlocks as $param) { if (!isset($_finalResult[$param])) { $_finalResult[$param] = array(); } if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewrite')) { foreach ($rewrites as $rewrite) { $parentElement = $rewrite->xpath('../..'); foreach ($parentElement[0] as $moduleKey => $moduleItems) { $moduleItemsArray['rewrite'] = array(); foreach ($moduleItems->rewrite as $rewriteLine) { foreach ($rewriteLine as $key => $value) { $moduleItemsArray['rewrite'][$key] = (string) $value; } #$moduleItemsArray['rewrite'] += $rewriteLine->asArray(); #echo "<pre>".print_r($moduleItemsArray['rewrite'],1)."</pre>"; } if ($moduleItems->rewrite) { // $_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItems->asArray())); $_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray)); } } } } #echo "<pre>".print_r($_finalResult,1)."</pre>"; if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewriteabstract')) { foreach ($rewrites as $rewrite) { $parentElement = $rewrite->xpath('../..'); foreach ($parentElement[0] as $moduleKey => $moduleItems) { if ($moduleItems->rewriteabstract) { // $_finalResultAbstract[$param] = array_merge_recursive($_finalResultAbstract[$param], array($moduleKey => $moduleItems->asArray())); $list = array(); foreach ($moduleItems->rewriteabstract->children() as $key => $value) { $list[$key] = (string) $value; } #echo "<pre>--".print_r($list,1)."</pre>"; #echo "<pre>++".print_r($moduleItems->asArray(),1)."</pre>"; $_finalResultAbstract[$param] = array($moduleKey => array('rewriteabstract' => $list)); } } } } } } foreach (array_keys($_finalResult) as $groupType) { foreach (array_keys($_finalResult[$groupType]) as $key) { // remove some repeating elements after merging all parents foreach ($_finalResult[$groupType][$key]['rewrite'] as $key1 => $value) { if (is_array($value)) { $_finalResult[$groupType][$key]['rewrite'][$key1] = array_unique($value); } // if rewrites count < 2 - no conflicts - remove if (gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array' && count($_finalResult[$groupType][$key]['rewrite'][$key1]) < 2 || gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'string') { unset($_finalResult[$groupType][$key]['rewrite'][$key1]); } } // clear empty elements if (count($_finalResult[$groupType][$key]['rewrite']) < 1) { unset($_finalResult[$groupType][$key]); } } // clear empty elements if (count($_finalResult[$groupType]) < 1) { unset($_finalResult[$groupType]); } } foreach (array_keys($_finalResultAbstract) as $groupType) { foreach (array_keys($_finalResultAbstract[$groupType]) as $key) { // remove some repeating elements after merging all parents foreach ($_finalResultAbstract[$groupType][$key]['rewriteabstract'] as $key1 => $value) { if (is_array($value)) { $_finalResultAbstract[$groupType][$key]['rewriteabstract'][$key1] = array_unique($value); } } // clear empty elements if (count($_finalResultAbstract[$groupType][$key]['rewriteabstract']) < 1) { unset($_finalResultAbstract[$groupType][$key]); } } // clear empty elements if (count($_finalResultAbstract[$groupType]) < 1) { unset($_finalResultAbstract[$groupType]); } } // filter aitoc modules foreach ($_finalResult as $type => $data) { foreach ($data as $module => $data) { foreach ($data['rewrite'] as $model => $classes) { $remove = true; foreach ($classes as $class) { if (strstr($class, 'Aitoc') || strstr($class, 'AdjustWare')) { $remove = false; break; } } if ($remove) { unset($_finalResult[$type][$module]['rewrite'][$model]); } } if (!$_finalResult[$type][$module]['rewrite']) { unset($_finalResult[$type][$module]); } } } return array($_finalResult, $_finalResultAbstract); }
/** * Retrive possible conflicts list * * @return array */ protected function _getPossibleConflictsList() { $moduleFiles = glob($this->_etcDir . DS . 'modules' . DS . '*.xml'); if (!$moduleFiles) { return false; } // load file contents $unsortedConfig = new Varien_Simplexml_Config(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($moduleFiles as $filePath) { $fileConfig->loadFile($filePath); $unsortedConfig->extend($fileConfig); } // create sorted config [only active modules] $sortedConfig = new Varien_Simplexml_Config(); $sortedConfig->loadString('<config><modules/></config>'); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if ('true' === (string) $moduleNode->active) { $sortedConfig->getNode('modules')->appendChild($moduleNode); } } $fileConfig = new Varien_Simplexml_Config(); $_finalResult = array(); foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { $codePool = (string) $moduleNode->codePool; $configPath = $this->_codeDir . DS . $codePool . DS . uc_words($moduleName, DS) . DS . 'etc' . DS . 'config.xml'; $fileConfig->loadFile($configPath); $rewriteBlocks = array('blocks', 'models', 'helpers'); foreach ($rewriteBlocks as $param) { if (!isset($_finalResult[$param])) { $_finalResult[$param] = array(); } if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewrite')) { foreach ($rewrites as $rewrite) { $parentElement = $rewrite->xpath('../..'); foreach ($parentElement[0] as $moduleKey => $moduleItems) { if ($moduleItems->rewrite) { $_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItems->asArray())); } } } } } } foreach (array_keys($_finalResult) as $groupType) { foreach (array_keys($_finalResult[$groupType]) as $key) { // remove some repeating elements after merging all parents foreach ($_finalResult[$groupType][$key]['rewrite'] as $key1 => $value) { if (is_array($value)) { $_finalResult[$groupType][$key]['rewrite'][$key1] = array_unique($value); } // if rewrites count < 2 - no conflicts - remove if (gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array' && count($_finalResult[$groupType][$key]['rewrite'][$key1]) < 2 || gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'string') { unset($_finalResult[$groupType][$key]['rewrite'][$key1]); } } // clear empty elements if (count($_finalResult[$groupType][$key]['rewrite']) < 1) { unset($_finalResult[$groupType][$key]); } } // clear empty elements if (count($_finalResult[$groupType]) < 1) { unset($_finalResult[$groupType]); } } return $_finalResult; }
protected function getModulesList() { $ret = array(); $moduleFiles = glob($this->_etcDir . DS . 'modules' . DS . '*.xml'); if ($moduleFiles) { // load file contents $unsortedConfig = new Varien_Simplexml_Config(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($moduleFiles as $filePath) { $fileConfig->loadFile($filePath); $unsortedConfig->extend($fileConfig); } // create sorted config [only active modules] $sortedConfig = new Varien_Simplexml_Config(); $sortedConfig->loadString('<config><modules/></config>'); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if ('true' === (string) $moduleNode->active) { $sortedConfig->getNode('modules')->appendChild($moduleNode); } } $fileConfig = new Varien_Simplexml_Config(); foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if (strpos($moduleName, "Mage_") === FALSE) { $codePool = (string) $moduleNode->codePool; $configPath = $this->_codeDir . DS . $codePool . DS . uc_words($moduleName, DS) . DS . 'etc' . DS . 'config.xml'; $fileConfig->loadFile($configPath); $version = $fileConfig->getXpath('modules/' . $moduleName . '/version'); $ret[] = array('version' => $version && $version[0] ? (string) $version[0] : NULL, 'key' => $moduleName); } } } return $ret; }
protected function generatePriceArr($xmlResponse, &$costArr, &$priceArr) { if (strlen(trim($xmlResponse)) > 0) { $xml = new Varien_Simplexml_Config(); $xml->loadString($xmlResponse); $arr = $xml->getXpath("//RatingServiceSelectionResponse/Response/ResponseStatusCode/text()"); $success = (int) $arr[0]; if ($success === 1) { $arr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment"); // WSA change for Dropship if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Dropcommon', 'carriers/dropship/active') || Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Dropship', 'carriers/dropship/active')) { $allowedMethods = $this->_request->getUpsAllowedMethods(); if ($allowedMethods == null) { $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); } } else { $allowedMethods = explode(",", $this->getConfigData('allowed_methods')); } // Negotiated rates $negotiatedArr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment/NegotiatedRates"); $negotiatedActive = $this->getConfigFlag('negotiated_active') && $this->getConfigData('shipper_number') && !empty($negotiatedArr); foreach ($arr as $shipElement) { $code = (string) $shipElement->Service->Code; if (in_array($code, $allowedMethods)) { if ($negotiatedActive) { $cost = $shipElement->NegotiatedRates->NetSummaryCharges->GrandTotal->MonetaryValue; } else { $cost = $shipElement->TotalCharges->MonetaryValue; } //convert price with Origin country currency code to base currency code $successConversion = true; $responseCurrencyCode = (string) $shipElement->TotalCharges->CurrencyCode; if ($responseCurrencyCode) { $allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies(); if (in_array($responseCurrencyCode, $allowedCurrencies) && $this->_getBaseCurrencyRate($responseCurrencyCode) > 0) { $cost = (double) $cost * $this->_getBaseCurrencyRate($responseCurrencyCode); } else { $errorTitle = Mage::helper('directory')->__('Can\'t convert rate from "%s-%s".', $responseCurrencyCode, $this->_request->getPackageCurrency()->getCode()); $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); $error->setErrorMessage($errorTitle); $successConversion = false; } } if ($successConversion) { $costArr[$code] = $cost; $priceArr[$code] = $this->getMethodPrice(floatval($cost), $code); } } } } else { $arr = $xml->getXpath("//RatingServiceSelectionResponse/Response/Error/ErrorDescription/text()"); $errorTitle = (string) $arr[0][0]; $error = Mage::getModel('shipping/rate_result_error'); $error->setCarrier('ups'); $error->setCarrierTitle($this->getConfigData('title')); //$error->setErrorMessage($errorTitle); $error->setErrorMessage($this->getConfigData('specificerrmsg')); if ($this->getDebugFlag()) { Mage::helper('wsalogger/log')->postWarning('usashipping', 'UPS Error Raised', ''); } } } return $priceArr; }
/** * Retrive possible conflicts list * * @return array */ public function getConflictList() { $moduleFiles = glob($this->_etcDir . 'modules' . DIRECTORY_SEPARATOR . '*.xml'); if (!$moduleFiles) { return false; } // load file contents $unsortedConfig = new Varien_Simplexml_Config(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Varien_Simplexml_Config(); foreach ($moduleFiles as $filePath) { $fileConfig->loadFile($filePath); $unsortedConfig->extend($fileConfig); } // create sorted config [only active modules] $sortedConfig = new Varien_Simplexml_Config(); $sortedConfig->loadString('<config><modules/></config>'); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if ('true' === (string) $moduleNode->active) { $sortedConfig->getNode('modules')->appendChild($moduleNode); } } $fileConfig = new Varien_Simplexml_Config(); $_finalResult = array(); foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { $codePool = (string) $moduleNode->codePool; $configPath = $this->_codeDir . $codePool . DIRECTORY_SEPARATOR . uc_words($moduleName, DS) . DIRECTORY_SEPARATOR . 'etc' . DS . 'config.xml'; $fileConfig->loadFile($configPath); $rewriteBlocks = array('blocks', 'models', 'helpers'); foreach ($rewriteBlocks as $param) { if (!isset($_finalResult[$param])) { $_finalResult[$param] = array(); } if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewrite')) { foreach ($rewrites as $rewrite) { $parentElement = $rewrite->xpath('../..'); foreach ($parentElement[0] as $moduleKey => $moduleItems) { $moduleItemsArray['rewrite'] = array(); foreach ($moduleItems->rewrite as $rewriteLine) { foreach ($rewriteLine as $key => $value) { $moduleItemsArray['rewrite'][$key] = (string) $value; } #echo "<pre>".print_r($moduleItemsArray['rewrite'],1)."</pre>"; } if ($moduleItems->rewrite) { $_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray)); } } } } } } $_finalResult = $this->_fillAllClassesToRewrite($_finalResult); $_finalResult = $this->_clearEmptyRows($_finalResult); $_finalResult = $this->_recoverDeletedClassRewrites($_finalResult); // filter aitoc modules foreach ($_finalResult as $type => $data) { foreach ($data as $module => $data) { foreach ($data['rewrite'] as $model => $classes) { $remove = true; foreach ($classes as $class) { if (strstr($class, 'Aitoc') || strstr($class, 'AdjustWare')) { $remove = false; break; } } if ($remove) { unset($_finalResult[$type][$module]['rewrite'][$model]); } } if (!$_finalResult[$type][$module]['rewrite']) { unset($_finalResult[$type][$module]); } } } return $_finalResult; }