当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Filter_LocalizedToNormalized::filter方法代码示例

本文整理汇总了PHP中Zend_Filter_LocalizedToNormalized::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_LocalizedToNormalized::filter方法的具体用法?PHP Zend_Filter_LocalizedToNormalized::filter怎么用?PHP Zend_Filter_LocalizedToNormalized::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Filter_LocalizedToNormalized的用法示例。


在下文中一共展示了Zend_Filter_LocalizedToNormalized::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _processLocalizedQty

 /**
  * Processes localized qty (entered by user at frontend) into internal php format
  *
  * @param string $qty
  * @return float|int|null
  */
 protected function _processLocalizedQty($qty)
 {
     if (!$this->_localFilter) {
         $this->_localFilter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
     }
     $qty = $this->_localFilter->filter($qty);
     if ($qty < 0) {
         $qty = null;
     }
     return $qty;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:17,代码来源:SearchController.php

示例2: process

 /**
  * Process localized quantity to internal format
  *
  * @param float $qty
  * @return array|string
  */
 public function process($qty)
 {
     if (!$this->localFilter) {
         $this->localFilter = new \Zend_Filter_LocalizedToNormalized(array('locale' => $this->localeResolver->getLocaleCode()));
     }
     $qty = $this->localFilter->filter((double) $qty);
     if ($qty < 0) {
         $qty = null;
     }
     return $qty;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:LocaleQuantityProcessor.php

示例3: _updateShoppingCart

 /**
  * Update customer's shopping cart
  *
  * @return void
  */
 protected function _updateShoppingCart()
 {
     try {
         $cartData = $this->getRequest()->getParam('cart');
         if (is_array($cartData)) {
             $filter = new \Zend_Filter_LocalizedToNormalized(array('locale' => $this->_objectManager->get('Magento\\Framework\\Locale\\ResolverInterface')->getLocaleCode()));
             foreach ($cartData as $index => $data) {
                 if (isset($data['qty'])) {
                     $cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
                 }
             }
             if (!$this->cart->getCustomerSession()->getCustomerId() && $this->cart->getQuote()->getCustomerId()) {
                 $this->cart->getQuote()->setCustomerId(null);
             }
             $cartData = $this->cart->suggestItemsQty($cartData);
             $this->cart->updateItems($cartData)->save();
         }
         $this->_checkoutSession->setCartWasUpdated(true);
     } catch (\Magento\Framework\Model\Exception $e) {
         $this->messageManager->addError($this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($e->getMessage()));
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We cannot update the shopping cart.'));
         $this->_objectManager->get('Magento\\Framework\\Logger')->logException($e);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:30,代码来源:UpdatePost.php

示例4: updateItemOptionsAction

 /**
  * Update product configuration for a cart item
  */
 public function updateItemOptionsAction()
 {
     $cart = $this->_getCart();
     $id = (int) $this->getRequest()->getParam('id');
     $params = $this->getRequest()->getParams();
     if (!isset($params['options'])) {
         $params['options'] = array();
     }
     try {
         if (isset($params['qty'])) {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             $params['qty'] = $filter->filter($params['qty']);
         }
         $quoteItem = $cart->getQuote()->getItemById($id);
         if (!$quoteItem) {
             Mage::throwException($this->__('Quote item is not found.'));
         }
         $item = $cart->updateItem($id, new Varien_Object($params));
         if (is_string($item)) {
             Mage::throwException($item);
         }
         if ($item->getHasError()) {
             Mage::throwException($item->getMessage());
         }
         $related = $this->getRequest()->getParam('related_product');
         if (!empty($related)) {
             $cart->addProductsByIds(explode(',', $related));
         }
         $cart->save();
         $this->_getSession()->setCartWasUpdated(true);
         $this->getLayout()->getUpdate()->addHandle('ajaxcart');
         $this->loadLayout();
         Mage::dispatchEvent('checkout_cart_update_item_complete', array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse()));
         if (!$this->_getSession()->getNoCartRedirect(true)) {
             if (!$cart->getQuote()->getHasError()) {
                 $message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->htmlEscape($item->getProduct()->getName()));
                 $this->_getSession()->addSuccess($message);
             }
             $this->_goBack();
         }
     } catch (Mage_Core_Exception $e) {
         $_response = Mage::getModel('ajaxcart/response');
         $_response->setError(true);
         $messages = array_unique(explode("\n", $e->getMessage()));
         $json_messages = array();
         foreach ($messages as $message) {
             $json_messages[] = Mage::helper('core')->escapeHtml($message);
         }
         $_response->setMessages($json_messages);
         $url = $this->_getSession()->getRedirectUrl(true);
         $_response->send();
     } catch (Exception $e) {
         $this->_getSession()->addException($e, $this->__('Cannot update the item.'));
         Mage::logException($e);
         $_response = Mage::getModel('ajaxcart/response');
         $_response->setError(true);
         $_response->setMessage($this->__('Cannot update the item.'));
         $_response->send();
     }
 }
开发者ID:Madhurabhat,项目名称:test,代码行数:63,代码来源:CartController.php

示例5: execute

 /**
  * Update product configuration for a cart item
  *
  * @return void
  */
 public function execute()
 {
     $id = (int) $this->getRequest()->getParam('id');
     $params = $this->getRequest()->getParams();
     if (!isset($params['options'])) {
         $params['options'] = array();
     }
     try {
         if (isset($params['qty'])) {
             $filter = new \Zend_Filter_LocalizedToNormalized(array('locale' => $this->_objectManager->get('Magento\\Framework\\Locale\\ResolverInterface')->getLocaleCode()));
             $params['qty'] = $filter->filter($params['qty']);
         }
         $quoteItem = $this->cart->getQuote()->getItemById($id);
         if (!$quoteItem) {
             throw new \Magento\Framework\Model\Exception(__("We can't find the quote item."));
         }
         $item = $this->cart->updateItem($id, new \Magento\Framework\Object($params));
         if (is_string($item)) {
             throw new \Magento\Framework\Model\Exception($item);
         }
         if ($item->getHasError()) {
             throw new \Magento\Framework\Model\Exception($item->getMessage());
         }
         $related = $this->getRequest()->getParam('related_product');
         if (!empty($related)) {
             $this->cart->addProductsByIds(explode(',', $related));
         }
         $this->cart->save();
         $this->_checkoutSession->setCartWasUpdated(true);
         $this->_eventManager->dispatch('checkout_cart_update_item_complete', array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse()));
         if (!$this->_checkoutSession->getNoCartRedirect(true)) {
             if (!$this->cart->getQuote()->getHasError()) {
                 $message = __('%1 was updated in your shopping cart.', $this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($item->getProduct()->getName()));
                 $this->messageManager->addSuccess($message);
             }
             $this->_goBack();
         }
     } catch (\Magento\Framework\Model\Exception $e) {
         if ($this->_checkoutSession->getUseNotice(true)) {
             $this->messageManager->addNotice($e->getMessage());
         } else {
             $messages = array_unique(explode("\n", $e->getMessage()));
             foreach ($messages as $message) {
                 $this->messageManager->addError($message);
             }
         }
         $url = $this->_checkoutSession->getRedirectUrl(true);
         if ($url) {
             $this->getResponse()->setRedirect($url);
         } else {
             $cartUrl = $this->_objectManager->get('Magento\\Checkout\\Helper\\Cart')->getCartUrl();
             $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($cartUrl));
         }
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We cannot update the item.'));
         $this->_objectManager->get('Magento\\Framework\\Logger')->logException($e);
         $this->_goBack();
     }
     $this->_redirect('*/*');
 }
开发者ID:aiesh,项目名称:magento2,代码行数:65,代码来源:UpdateItemOptions.php

示例6: _updateShoppingCart

 protected function _updateShoppingCart()
 {
     try {
         $cartData = $this->getRequest()->getParam('cart');
         if (is_array($cartData)) {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             foreach ($cartData as $index => $data) {
                 if (isset($data['qty'])) {
                     $cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
                 }
             }
             $cart = $this->_getCart();
             if (!$cart->getCustomerSession()->getCustomer()->getId() && $cart->getQuote()->getCustomerId()) {
                 $cart->getQuote()->setCustomerId(null);
             }
             $cartData = $cart->suggestItemsQty($cartData);
             $cart->updateItems($cartData)->save();
         }
         $this->_getSession()->setCartWasUpdated(true);
     } catch (Mage_Core_Exception $e) {
         $this->_getSession()->addError(Mage::helper('core')->escapeHtml($e->getMessage()));
     } catch (Exception $e) {
         $this->_getSession()->addException($e, $this->__('Cannot update shopping cart.'));
         Mage::logException($e);
     }
 }
开发者ID:novayadi85,项目名称:navicet,代码行数:26,代码来源:IndexController.php

示例7: _convertDate

 /**
  * Convert date from localized to internal format
  *
  * @param string $date
  * @param string $locale
  * @return string
  */
 protected function _convertDate($date, $locale)
 {
     $filterInput = new Zend_Filter_LocalizedToNormalized(array('date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
     $filterInternal = new Zend_Filter_NormalizedToLocalized(array('date_format' => Varien_Date::DATE_INTERNAL_FORMAT));
     $date = $filterInput->filter($date);
     $date = $filterInternal->filter($date);
     return $date;
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:15,代码来源:Date.php

示例8: outputFilter

 /**
  * Returns the result of filtering $value
  *
  * @param string $value
  * @return string
  */
 public function outputFilter($value)
 {
     $filterInput = new Zend_Filter_LocalizedToNormalized(array('date_format' => Varien_Date::DATE_INTERNAL_FORMAT, 'locale' => $this->_locale));
     $filterInternal = new Zend_Filter_NormalizedToLocalized(array('date_format' => $this->_dateFormat, 'locale' => $this->_locale));
     $value = $filterInput->filter($value);
     $value = $filterInternal->filter($value);
     return $value;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:14,代码来源:Date.php

示例9: outputFilter

 /**
  * Returns the result of filtering $value
  *
  * @param string $value
  * @return string
  */
 public function outputFilter($value)
 {
     $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => DateTime::DATE_INTERNAL_FORMAT, 'locale' => $this->localeResolver->getLocale()]);
     $filterInternal = new \Zend_Filter_NormalizedToLocalized(['date_format' => $this->_dateFormat, 'locale' => $this->localeResolver->getLocale()]);
     $value = $filterInput->filter($value);
     $value = $filterInternal->filter($value);
     return $value;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Date.php

示例10: _set

 public function _set($fieldName, $value, $load = true)
 {
     if (strstr($fieldName, 'week_')) {
         $zendFilter = new Zend_Filter_LocalizedToNormalized();
         $value = $zendFilter->filter($value);
     }
     parent::_set($fieldName, $value, $load);
 }
开发者ID:jaspermeijaard,项目名称:home-booking-system,代码行数:8,代码来源:Percentage.php

示例11: filterDateValue

 public function filterDateValue($value)
 {
     $filterInput = new Zend_Filter_LocalizedToNormalized(array('date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)));
     $filterInternal = new Zend_Filter_NormalizedToLocalized(array('date_format' => Varien_Date::DATE_INTERNAL_FORMAT));
     $value = $filterInput->filter($value);
     $value = $filterInternal->filter($value);
     return $value;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:8,代码来源:Editor.php

示例12: updateItemOptionsAction

 public function updateItemOptionsAction()
 {
     if (!$this->getRequest()->isXmlHttpRequest()) {
         return parent::updateItemOptionsAction();
     }
     $message = '';
     $cart = $this->_getCart();
     $id = (int) $this->getRequest()->getParam('id');
     $params = $this->getRequest()->getParams();
     if (!isset($params['options'])) {
         $params['options'] = array();
     }
     try {
         if (isset($params['qty'])) {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             $params['qty'] = $filter->filter($params['qty']);
         }
         $quoteItem = $cart->getQuote()->getItemById($id);
         if (!$quoteItem) {
             //Mage::throwException($this->__('Quote item is not found.'));
             return;
         }
         $item = $cart->updateItem($id, new Varien_Object($params));
         if (is_string($item)) {
             //Mage::throwException($item);
             return;
         }
         if ($item->getHasError()) {
             //Mage::throwException($item->getMessage());
             return;
         }
         $related = $this->getRequest()->getParam('related_product');
         if (!empty($related)) {
             $cart->addProductsByIds(explode(',', $related));
         }
         $cart->save();
         $this->_getSession()->setCartWasUpdated(true);
         Mage::dispatchEvent('checkout_cart_update_item_complete', array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse()));
         if (!$cart->getQuote()->getHasError()) {
             $message = $this->__('<span><strong>%s</strong> was added to your shopping cart.</span><br /><p><a class="simple-button" href="%s">Continue Shopping</a><span> or </span><a class="button" href="%s">Checkout</a></p>', Mage::helper('core')->escapeHtml($item->getProduct()->getName()), 'javascript:weltpixel.lightbox.close()', Mage::helper('checkout/url')->getCheckoutUrl());
         }
     } catch (Mage_Core_Exception $e) {
         $message = Mage::helper('core')->escapeHtml($e->getMessage());
     } catch (Exception $e) {
         $message = $this->__('Cannot update the item.');
         Mage::logException($e);
     }
     $this->loadLayout();
     $body = array('message' => $message, 'blocks' => array());
     if ($this->getLayout()->getBlock('cart_sidebar')) {
         $body['blocks']['cart_sidebar'] = array('class' => Mage::helper('weltpixel_quickview')->isMageEnterprise() ? 'top-cart' : 'block-cart', 'content' => preg_replace('/\\/uenc\\/[^\\/]*/', '', $this->getLayout()->getBlock('cart_sidebar')->toHtml()));
     }
     if ($this->getLayout()->getBlock('quick_access')) {
         $body['blocks']['quick_access'] = array('id' => 'quick-access', 'content' => preg_replace('/\\/uenc\\/[^\\/]*/', '', $this->getLayout()->getBlock('quick_access')->toHtml()));
     }
     $this->getResponse()->setHeader('Content-Type', 'application/json', true)->setBody(Mage::helper('core')->jsonEncode($body));
 }
开发者ID:aayushKhandpur,项目名称:aayush-renting,代码行数:57,代码来源:CartController.php

示例13: save

 public function save()
 {
     $price = trim(str_replace(array(Core_Model_Language::getCurrencySymbol(), ' '), '', $this->getData('price')));
     $filter = new Zend_Filter_LocalizedToNormalized();
     $filter->setOptions(array('locale' => Zend_Registry::get('Zend_Locale')));
     $this->setData('price', $filter->filter($price));
     parent::save();
     return $this;
 }
开发者ID:bklein01,项目名称:SiberianCMS,代码行数:9,代码来源:Option.php

示例14: addAction

 /**
  * Add product to shopping cart action
  * Overides the addAction() function from Mage_Checkout_CartController.
  */
 public function addAction()
 {
     $cart = $this->_getCart();
     $params = $this->getRequest()->getParams();
     try {
         if (isset($params['qty'])) {
             $filter = new Zend_Filter_LocalizedToNormalized(array('locale' => Mage::app()->getLocale()->getLocaleCode()));
             $params['qty'] = $filter->filter($params['qty']);
         }
         $product = $this->_initProduct();
         $related = $this->getRequest()->getParam('related_product');
         /**
          * Check product availability
          */
         if (!$product) {
             $this->_goBack();
             return;
         }
         $cart->addProduct($product, $params);
         if (!empty($related)) {
             $cart->addProductsByIds(explode(',', $related));
         }
         $cart->save();
         $this->_getSession()->setCartWasUpdated(true);
         /**
          * @todo remove wishlist observer processAddToCart
          */
         Mage::dispatchEvent('checkout_cart_add_product_complete', array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse()));
         if (!$this->_getSession()->getNoCartRedirect(true)) {
             //Remove the added to cart message by calling the isDisplayMsg() function with && logic operator
             if (!$cart->getQuote()->getHasError() && $this->isDisplayMsg()) {
                 $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
                 $this->_getSession()->addSuccess($message);
             }
             $this->_goBack();
         }
     } catch (Mage_Core_Exception $e) {
         if ($this->_getSession()->getUseNotice(true)) {
             $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
         } else {
             $messages = array_unique(explode("\n", $e->getMessage()));
             foreach ($messages as $message) {
                 $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
             }
         }
         $url = $this->_getSession()->getRedirectUrl(true);
         if ($url) {
             $this->getResponse()->setRedirect($url);
         } else {
             $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
         }
     } catch (Exception $e) {
         $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
         Mage::logException($e);
         $this->_goBack();
     }
 }
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:61,代码来源:CartController.php

示例15: execute

 /**
  * Add product to shopping cart action
  *
  * @return void
  */
 public function execute()
 {
     $params = $this->getRequest()->getParams();
     try {
         if (isset($params['qty'])) {
             $filter = new \Zend_Filter_LocalizedToNormalized(array('locale' => $this->_objectManager->get('Magento\\Framework\\Locale\\ResolverInterface')->getLocaleCode()));
             $params['qty'] = $filter->filter($params['qty']);
         }
         $product = $this->_initProduct();
         $related = $this->getRequest()->getParam('related_product');
         /**
          * Check product availability
          */
         if (!$product) {
             $this->_goBack();
             return;
         }
         $this->cart->addProduct($product, $params);
         if (!empty($related)) {
             $this->cart->addProductsByIds(explode(',', $related));
         }
         $this->cart->save();
         $this->_checkoutSession->setCartWasUpdated(true);
         /**
          * @todo remove wishlist observer processAddToCart
          */
         $this->_eventManager->dispatch('checkout_cart_add_product_complete', array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse()));
         if (!$this->_checkoutSession->getNoCartRedirect(true)) {
             if (!$this->cart->getQuote()->getHasError()) {
                 $message = __('You added %1 to your shopping cart.', $this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($product->getName()));
                 $this->messageManager->addSuccess($message);
             }
             $this->_goBack();
         }
     } catch (\Magento\Framework\Model\Exception $e) {
         if ($this->_checkoutSession->getUseNotice(true)) {
             $this->messageManager->addNotice($this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($e->getMessage()));
         } else {
             $messages = array_unique(explode("\n", $e->getMessage()));
             foreach ($messages as $message) {
                 $this->messageManager->addError($this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($message));
             }
         }
         $url = $this->_checkoutSession->getRedirectUrl(true);
         if ($url) {
             $this->getResponse()->setRedirect($url);
         } else {
             $cartUrl = $this->_objectManager->get('Magento\\Checkout\\Helper\\Cart')->getCartUrl();
             $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($cartUrl));
         }
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We cannot add this item to your shopping cart'));
         $this->_objectManager->get('Magento\\Framework\\Logger')->logException($e);
         $this->_goBack();
     }
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:61,代码来源:Add.php


注:本文中的Zend_Filter_LocalizedToNormalized::filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。