/** * Render address * * @param Mage_Customer_Model_Address_Abstract $address * @return string */ public function render(Mage_Customer_Model_Address_Abstract $address) { $format = $this->getType()->getDefaultFormat(); $countryFormat = $address->getCountryModel()->getFormat($this->getType()->getCode()); $address->getRegion(); $address->getCountry(); $address->explodeStreetAddress(); if ($countryFormat) { $format = $countryFormat->getFormat(); } $formater = new Varien_Filter_Template(); $formater->setVariables(array_merge($address->getData(), array('country' => $address->getCountryModel()->getName()))); return $formater->filter($format); }
/** * Render address * * @param Mage_Customer_Model_Address_Abstract $address * @return string */ public function render(Mage_Customer_Model_Address_Abstract $address, $format = null) { $address->getRegion(); $address->getCountry(); $address->explodeStreetAddress(); $formater = new Varien_Filter_Template(); $data = $address->getData(); if ($this->getType()->getHtmlEscape()) { foreach ($data as $key => $value) { $data[$key] = $this->htmlEscape($value); } } $formater->setVariables(array_merge($data, array('country' => $address->getCountryModel()->getName()))); $format = !is_null($format) ? $format : $this->getFormat($address); return $formater->filter($format); }
/** * Render address * * @param Mage_Customer_Model_Address_Abstract $address * @return string */ public function render(Mage_Customer_Model_Address_Abstract $address, $format = null) { $address->getRegion(); $address->getCountry(); $address->explodeStreetAddress(); $formater = new Varien_Filter_Template(); $data = $address->getData(); if ($this->getType()->getHtmlEscape()) { foreach ($data as $key => $value) { if (is_object($value)) { unset($data[$key]); } else { $data[$key] = $this->htmlEscape($value); } } } /** * Remove data that mustn't show */ if (!$this->helper('customer/address')->canShowConfig('prefix_show')) { unset($data['prefix']); } if (!$this->helper('customer/address')->canShowConfig('middlename_show')) { unset($data['middlename']); } if (!$this->helper('customer/address')->canShowConfig('suffix_show')) { unset($data['suffix']); } $formater->setVariables(array_merge($data, array('country' => $address->getCountryModel()->getName()))); $format = !is_null($format) ? $format : $this->getFormat($address); return $formater->filter($format); }
/** * Render address * * @param Mage_Customer_Model_Address_Abstract $address * @return string */ public function render(Mage_Customer_Model_Address_Abstract $address, $format = null) { switch ($this->getType()->getCode()) { case 'html': $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_HTML; break; case 'pdf': $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_PDF; break; case 'oneline': $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE; break; default: $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_TEXT; break; } $formater = new Varien_Filter_Template(); $attributes = Mage::helper('customer/address')->getAttributes(); $data = array(); foreach ($attributes as $attribute) { /* @var $attribute Mage_Customer_Model_Attribute */ if (!$attribute->getIsVisible()) { continue; } if ($attribute->getAttributeCode() == 'country_id') { $data['country'] = $address->getCountryModel()->getName(); } else { if ($attribute->getAttributeCode() == 'region') { $data['region'] = Mage::helper('directory')->__($address->getRegion()); } else { $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address); $value = $dataModel->outputValue($dataFormat); if ($attribute->getFrontendInput() == 'multiline') { $values = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY); // explode lines foreach ($values as $k => $v) { $key = sprintf('%s%d', $attribute->getAttributeCode(), $k + 1); $data[$key] = $v; } } $data[$attribute->getAttributeCode()] = $value; } } } if ($this->getType()->getHtmlEscape()) { foreach ($data as $key => $value) { $data[$key] = $this->escapeHtml($value); } } $formater->setVariables($data); $format = !is_null($format) ? $format : $this->getFormat($address); return $formater->filter($format); }
/** * Filter the string as template. * Rewrited for logging exceptions * * @param string $value * @return string */ public function filter($value) { try { $value = parent::filter($value); } catch (Exception $e) { $value = ''; Mage::logException($e); } return $value; }
/** * Retrieve processed template subject * * @param array $variables * @return string */ public function getProcessedTemplateSubject(array $variables) { $processor = new Varien_Filter_Template(); if (!$this->_preprocessFlag) { $variables['this'] = $this; } $processor->setVariables($variables); return $processor->filter($this->getTemplateSubject()); }
/** * Собирает секцию для конфиг файла * Каждый индекс имеет свою секцию * Секция состоит source (откуда-что брать) и index (куда это писать и как его индексировать) * Шаблон секции находиться в расширении etc/config/section.conf. * * @param string $name название (код индекса) * @param object $indexer Индексатор! индекса * * @return string готовая секция */ protected function _getSectionConfig($name, $indexer) { $sqlHost = Mage::getConfig()->getNode('global/resources/default_setup/connection/host'); $sqlPort = 3306; if (count(explode(':', $sqlHost)) == 2) { $arr = explode(':', $sqlHost); $sqlHost = $arr[0]; $sqlPort = $arr[1]; } $data = array('name' => $name, 'sql_host' => $sqlHost, 'sql_port' => $sqlPort, 'sql_user' => Mage::getConfig()->getNode('global/resources/default_setup/connection/username'), 'sql_pass' => Mage::getConfig()->getNode('global/resources/default_setup/connection/password'), 'sql_db' => Mage::getConfig()->getNode('global/resources/default_setup/connection/dbname'), 'sql_query_pre' => $this->_getSqlQueryPre($indexer), 'sql_query' => $this->_getSqlQuery($indexer), 'sql_query_delta' => $this->_getSqlQueryDelta($indexer), 'sql_attr_uint' => $indexer->getPrimaryKey(), 'min_word_len' => Mage::getStoreConfig(Mage_CatalogSearch_Model_Query::XML_PATH_MIN_QUERY_LENGTH), 'index_path' => $this->_basePath . DS . $name, 'delta_index_path' => $this->_basePath . DS . $name . '_delta'); foreach ($data as $key => $value) { $data[$key] = str_replace('#', '\\#', $value); } $formater = new Varien_Filter_Template(); $formater->setVariables($data); $config = $formater->filter(file_get_contents($this->getSphinxSectionCfgTpl())); return $config; }
protected function parse($str, $vars) { $processor = new Varien_Filter_Template(); $processor->setVariables($vars); return $processor->filter($str); }
/** * Init Plugin Version in AvaTax section comment * * @return \OnePica_AvaTax_Helper_Config */ protected function _initPluginVersion() { $taxSection = $this->getSection('tax'); if ($taxSection) { $pathComment = 'groups/avatax/comment'; $comment = $taxSection->descend($pathComment); if ($comment) { $comment = $comment[0]; $version = Mage::getConfig()->getNode('modules/OnePica_AvaTax/version'); if ($this->_getDataHelper()->isAvatax16()) { $version16 = Mage::getConfig()->getNode('default/tax/avatax/avatax16_extension_version'); $version = $version16 . ' (' . $version . ')'; } $processor = new Varien_Filter_Template(); $processor->setVariables(array('avatax_ver' => $version)); $precessedComment = $processor->filter($comment); $taxSection->setNode($pathComment, $precessedComment); } } return $this; }
/** * Get formatted return address * * @param string $formatCode * @param array $data - array of address data * @param int|null $storeId - Store Id * @return string */ public function getReturnAddress($formatCode = 'html', $data = array(), $storeId = null) { if (empty($data)) { $data = $this->_getAddressData($storeId); } $format = null; if (isset($data['countryId'])) { $countryModel = $this->_getCountryModel()->load($data['countryId']); $format = $countryModel->getFormat($formatCode); } if (!$format) { $path = sprintf('%s%s', Mage_Customer_Model_Address_Config::XML_PATH_ADDRESS_TEMPLATE, $formatCode); $format = Mage::getStoreConfig($path, $storeId); } $formater = new Varien_Filter_Template(); $formater->setVariables($data); return $formater->filter($format); }
/** * Filter the string as template. * Rewrited for logging exceptions * * @param string $value * @return string */ public function filter($value) { try { $value = Varien_Filter_Template::filter($value); } catch (Exception $e) { throw $e; //$value = ''; //Mage::logException($e); } return $value; }
/** * Check max amount after adding product to cart * * @param Mage_Sales_Model_Quote_Item $quoteItem */ public function checkProductmaxAmount($quoteItem) { $quoteStore = $quoteItem->getStore(); if ($this->isProductEnable($quoteStore)) { $maxAmount = $this->getCartMaxAmount($quoteStore); /* @var $quote Mage_Sales_Model_Quote */ $quote = $quoteItem->getQuote(); $grandTotal = $quote->getGrandTotal(); $_product = Mage::getModel('catalog/product')->load($quoteItem->getProduct()->getId()); $grandTotal += $_product->getFinalPrice($quoteItem->getQty()); if ($grandTotal > $maxAmount) { $formater = new Varien_Filter_Template(); $formater->setVariables(array('amount' => Mage::helper('core')->currency($maxAmount, true, false))); $format = $this->getProductMessage($quoteStore); // throw exception for "remove" product to cart Mage::throwException($formater->filter($format)); } } }