Ejemplo n.º 1
0
 /**
  * @magentoAppIsolation enabled
  * @dataProvider layoutDirectiveDataProvider
  *
  * @param string $currentArea
  * @param string $directiveParams
  * @param string $expectedOutput
  */
 public function testLayoutDirective($currentArea, $directiveParams, $expectedOutput)
 {
     $this->_emulateCurrentArea($currentArea);
     Mage::getConfig()->setOptions(array('design_dir' => dirname(__DIR__) . '/_files/design'));
     Mage::getDesign()->setDesignTheme('test/default/default');
     $actualOutput = $this->_model->layoutDirective(array('{{layout ' . $directiveParams . '}}', 'layout', ' ' . $directiveParams));
     $this->assertEquals($expectedOutput, trim($actualOutput));
 }
Ejemplo n.º 2
0
 public function testEscapehtmlDirective()
 {
     $this->_model->setVariables(array('first' => '<p><i>Hello</i> <b>world!</b></p>', 'second' => '<p>Hello <strong>world!</strong></p>'));
     $allowedTags = 'i,b';
     $expectedResults = array('first' => '&lt;p&gt;<i>Hello</i> <b>world!</b>&lt;/p&gt;', 'second' => '&lt;p&gt;Hello &lt;strong&gt;world!&lt;/strong&gt;&lt;/p&gt;');
     foreach ($expectedResults as $varName => $expectedResult) {
         $result = $this->_model->escapehtmlDirective(array('{{escapehtml var=$' . $varName . ' allowed_tags=' . $allowedTags . '}}', 'escapehtml', ' var=$' . $varName . ' allowed_tags=' . $allowedTags));
         $this->assertEquals($expectedResult, $result);
     }
 }
Ejemplo n.º 3
0
 public function parseTemplate($text, Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $text = $this->insertAttributes($text, $magentoProduct);
     $text = $this->insertImages($text, $magentoProduct);
     $text = $this->insertMediaGalleries($text, $magentoProduct);
     //  the CMS static block replacement i.e. {{media url=’image.jpg’}}
     $filter = new Mage_Core_Model_Email_Template_Filter();
     $text = $filter->filter($text);
     return $text;
 }
 public function parseTemplate($text, Mage_Catalog_Model_Product $product)
 {
     /** @var $magentoProduct Ess_M2ePro_Model_MagentoProduct */
     $magentoProduct = Mage::getModel('M2ePro/MagentoProduct')->setProduct($product);
     $text = $this->insertAttributes($text, $magentoProduct);
     $text = $this->insertImages($text, $magentoProduct);
     $text = $this->insertMediaGalleries($text, $magentoProduct);
     //  the CMS static block replacement i.e. {{media url=’image.jpg’}}
     $filter = new Mage_Core_Model_Email_Template_Filter();
     $text = $filter->filter($text);
     return $text;
 }
 public function parseTemplate($text, Ess_M2ePro_Model_Magento_Product $magentoProduct)
 {
     $text = $this->insertAttributes($text, $magentoProduct);
     $text = $this->insertImages($text, $magentoProduct);
     $text = $this->insertMediaGalleries($text, $magentoProduct);
     $design = Mage::getDesign();
     $oldArea = $design->getArea();
     $design->setArea('adminhtml');
     //  the CMS static block replacement i.e. {{media url=’image.jpg’}}
     $filter = new Mage_Core_Model_Email_Template_Filter();
     $filter->setVariables(array('product' => $magentoProduct->getProduct()));
     $text = $filter->filter($text);
     $design->setArea($oldArea);
     return $text;
 }
Ejemplo n.º 6
0
 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoConfigFixture default_store design/theme/full_name test/default
  * @magentoConfigFixture adminhtml/design/theme/full_name test/default
  * @dataProvider layoutDirectiveDataProvider
  *
  * @param string $currentArea
  * @param string $directiveParams
  * @param string $expectedOutput
  */
 public function testLayoutDirective($currentArea, $directiveParams, $expectedOutput)
 {
     /** @var $themeUtility Mage_Core_Utility_Theme */
     $themeUtility = Mage::getModel('Mage_Core_Utility_Theme', array(dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'design'));
     $themeUtility->registerThemes()->setDesignTheme('test/default', 'frontend')->setDesignTheme('test/default', 'adminhtml');
     $this->_emulateCurrentArea($currentArea);
     $actualOutput = $this->_model->layoutDirective(array('{{layout ' . $directiveParams . '}}', 'layout', ' ' . $directiveParams));
     $this->assertEquals($expectedOutput, trim($actualOutput));
 }
Ejemplo n.º 7
0
 public function storeDirective($construction)
 {
     $params = $this->_getIncludeParameters($construction[2]);
     $params['_absolute'] = $this->_useAbsoluteLinks;
     $path = $params['url'];
     unset($params['url']);
     if (!self::$_urlInstance) {
         self::$_urlInstance = Mage::getModel('core/url');
     }
     $url = self::$_urlInstance->getUrl($path, $params);
     return $url;
 }
Ejemplo n.º 8
0
 public function storeDirective($construction)
 {
     // Get the bridge URLs
     $bridge = Mage::getSingleton('magebridge/core');
     $joomla_url = $bridge->getMageBridgeUrl();
     $joomla_sef_url = $bridge->getMageBridgeSefUrl();
     // Remove the .html suffix from the URL
     if (preg_match('/\\.html$/', $joomla_sef_url)) {
         $url_suffix = true;
         $joomla_sef_url = preg_replace('/\\.html$/', '', $joomla_sef_url);
     } else {
         $url_suffix = false;
     }
     // Call the parent function
     $url = parent::storeDirective($construction);
     $store_code = Mage::app()->getStore(Mage::getDesign()->getStore())->getCode();
     $url = str_replace($joomla_url, $joomla_sef_url, $url);
     $url = preg_replace('/___store=' . $store_code . '/', '', $url);
     $url = preg_replace('/SID=([a-zA-Z0-9]+)/', '', $url);
     $url = preg_replace('/\\?$/', '', $url);
     $url = preg_replace('/\\&$/', '', $url);
     // Return the URL
     return $url;
 }
Ejemplo n.º 9
0
 /**
  * Retrieve store URL directive
  * Support url and direct_url properties
  *
  * @param array $construction
  * @return string
  */
 public function storeDirective($construction)
 {
     $params = $this->_getIncludeParameters($construction[2]);
     if (!isset($params['_query'])) {
         $params['_query'] = array();
     }
     foreach ($params as $k => $v) {
         if (strpos($k, '_query_') === 0) {
             $params['_query'][substr($k, 7)] = $v;
             unset($params[$k]);
         }
     }
     $params['_absolute'] = $this->_useAbsoluteLinks;
     if ($this->_useSessionInUrl === false) {
         $params['_nosid'] = true;
     }
     if (isset($params['direct_url'])) {
         $path = '';
         $params['_direct'] = $params['direct_url'];
         unset($params['direct_url']);
     } else {
         $path = $params['url'];
         unset($params['url']);
     }
     if (!self::$_urlInstance) {
         self::$_urlInstance = Mage::getModel('core/url')->setStore(Mage::app()->getStore(Mage::getDesign()->getStore())->getId());
     }
     $_urlInstanceOldStore = null;
     if (!empty($path) && !Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL) && !Mage::app()->isSingleStoreMode()) {
         $params['_query']['___store'] = Mage::app()->getStore(Mage::getDesign()->getStore())->getCode();
     } elseif (!empty($path) && Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL) && !Mage::app()->isSingleStoreMode()) {
         $_urlInstanceOldStore = self::$_urlInstance->getStore();
         self::$_urlInstance->setStore(Mage::app()->getStore(Mage::getDesign()->getStore())->getCode());
     }
     $url = self::$_urlInstance->getUrl($path, $params);
     if (null == !$_urlInstanceOldStore) {
         self::$_urlInstance->setStore($_urlInstanceOldStore);
     }
     return $url;
 }
 /**
  * Filter the string as template.
  * Rewritten 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;
 }
Ejemplo n.º 11
0
 /**
  * Return variable value for var construction
  *
  * @param string $value   raw parameters
  * @param string $default default value
  *
  * @return string
  */
 public function getVariable($value, $default = '{no_value_defined}')
 {
     return parent::_getVariable($value, $default);
 }
Ejemplo n.º 12
0
 /**
  * @param Bronto_Api_Delivery_Row $delivery
  *
  * @return Bronto_Api_Delivery_Row
  */
 public function filter($delivery)
 {
     if (!$delivery instanceof Bronto_Api_Delivery_Row) {
         return parent::filter($delivery);
     }
     $this->_filteredObjects = array();
     $this->_delivery = $delivery;
     $this->_processAvailable();
     $this->_processQueryParams();
     foreach ($this->_variables as $var => $value) {
         //
         // Handle strings
         if (is_string($value)) {
             $key = $this->_camelize($var);
             if (in_array($key, $this->_processedAvailable)) {
                 $this->setField($key, $value);
             } else {
                 // Sanitize the best we can...
                 $key = preg_replace('/[^\\w_]$/', '', $key);
                 $key = $this->_camelize($key);
                 $this->setField($key, $value);
             }
         }
         if (is_object($value)) {
             $eventSuffix = 'unknown';
             // Handle properties that can be get()'ed
             foreach ($this->_processedAvailable as $keyValue) {
                 $method = str_replace($var, '', $keyValue);
                 $object = str_replace($method, '', $keyValue);
                 if ($object == $var) {
                     try {
                         $method = "get{$method}";
                         $this->setField($keyValue, $value->{$method}());
                     } catch (Exception $e) {
                         // Ignore
                     }
                 }
             }
             // Coupon
             if ($value instanceof Mage_SalesRule_Model_Coupon) {
                 $this->_filterCoupon($value);
                 $eventSuffix = 'coupon';
             }
             // Store
             if ($value instanceof Mage_Core_Model_Store) {
                 $this->_filterStore($value);
                 $eventSuffix = 'store';
             }
             // Admin User
             if ($value instanceof Mage_Admin_Model_User) {
                 $this->_filterAdmin($value);
                 $eventSuffix = 'admin';
             }
             // Subscriber
             if ($value instanceof Mage_Newsletter_Model_Subscriber) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getCustomerId());
                 }
                 $this->_filterSubscriber($value);
                 $eventSuffix = 'subscriber';
             }
             // Customer
             if ($value instanceof Mage_Customer_Model_Customer) {
                 /** @var Mage_Customer_Model_Customer _customer */
                 $this->_customer = $value;
                 $this->_filterCustomer($value);
                 $eventSuffix = 'customer';
             }
             // Shipment
             if ($value instanceof Mage_Sales_Model_Order_Shipment) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
                 }
                 $this->_filterShipment($value);
                 $eventSuffix = 'shipment';
             }
             // Invoice
             if ($value instanceof Mage_Sales_Model_Order_Invoice) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
                 }
                 $this->_filterInvoice($value);
                 $eventSuffix = 'invoice';
             }
             // Order
             if ($value instanceof Mage_Sales_Model_Order) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getCustomerId());
                 }
                 $this->_filterOrder($value);
                 $eventSuffix = 'order';
             }
             // Credit memo
             if ($value instanceof Mage_Sales_Model_Order_Creditmemo) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
                 }
                 $this->_filterCreditmemo($value);
                 $eventSuffix = 'creditmemo';
             }
             // Quote
             if ($value instanceof Mage_Sales_Model_Quote) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = $value->getCustomer();
                 }
                 $this->_filterQuote($value);
                 $eventSuffix = 'quote';
             }
             // Wishlist
             if ($value instanceof Mage_Wishlist_Model_Wishlist) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getCustomerId());
                 }
                 $this->_filterWishlist($value);
                 $eventSuffix = 'wishlist';
             }
             // Product
             if ($value instanceof Mage_Catalog_Model_Product) {
                 $this->_filterProduct($value);
                 $eventSuffix = 'product';
             }
             if ($value instanceof Mage_Sales_Model_Order_Address) {
                 if (!$this->_customer) {
                     /** @var Mage_Customer_Model_Customer _customer */
                     $this->_customer = Mage::getModel('customer/customer')->load($value->getOrder()->getCustomerId());
                 }
                 $this->_filterAddress($value);
                 $eventSuffix = 'address';
             }
             $this->_firePostFilterEvent($value, $eventSuffix);
         }
     }
     return $this->_delivery;
 }
Ejemplo n.º 13
0
 /**
  * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
  *
  * @return String                            containing HTML for credit memo items
  */
 protected function _filterCreditmemoItems(Mage_Sales_Model_Order_Creditmemo $creditmemo)
 {
     $html = parent::layoutDirective(array(2 => ' handle="sales_email_order_creditmemo_items" creditmemo=$creditmemo order=$order'));
     return $this->_applyInlineCssStyles($html);
 }