示例#1
0
 /**
  * Redirect user to Google Captcha challenge
  *
  * @param \Zend_Gdata_App_CaptchaRequiredException $e
  * @return void
  */
 protected function _redirectToCaptcha($e)
 {
     $redirectUrl = $this->getUrl('*/*/index', ['store' => $this->_getStore()->getId(), 'captcha_token' => $this->urlEncoder->encode($e->getCaptchaToken()), 'captcha_url' => $this->urlEncoder->encode($e->getCaptchaUrl())]);
     if ($this->getRequest()->isAjax()) {
         $this->getResponse()->representJson($this->_objectManager->get('Magento\\Core\\Helper\\Data')->jsonEncode(['redirect' => $redirectUrl]));
     } else {
         $this->_redirect($redirectUrl);
     }
 }
示例#2
0
 protected function setUp()
 {
     $this->_fixtureCustomerId = 1;
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_customerSession = $this->_objectManager->create('Magento\\Customer\\Model\\Session');
     $this->urlEncoder = $this->_objectManager->create('Magento\\Framework\\Url\\EncoderInterface');
     $this->_contextHelper = $this->_objectManager->create('Magento\\Framework\\App\\Helper\\Context');
     $request = $this->_contextHelper->getRequest();
     $request->setParam('data', $this->urlEncoder->encode($this->_fixtureCustomerId));
     $this->_wishlistHelper = $this->_objectManager->create('Magento\\Wishlist\\Helper\\Rss', ['context' => $this->_contextHelper, 'customerSession' => $this->_customerSession]);
     $this->_customerSession->loginById($this->_fixtureCustomerId);
 }
示例#3
0
文件: Items.php 项目: opexsw/magento2
 /**
  * Redirect user to Google Captcha challenge
  *
  * @param \Zend_Gdata_App_CaptchaRequiredException $e
  * @return \Magento\Framework\Controller\ResultInterface
  */
 protected function _redirectToCaptcha($e)
 {
     $redirectUrl = $this->getUrl('*/*/index', ['store' => $this->_getStore()->getId(), 'captcha_token' => $this->urlEncoder->encode($e->getCaptchaToken()), 'captcha_url' => $this->urlEncoder->encode($e->getCaptchaUrl())]);
     if ($this->getRequest()->isAjax()) {
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
         return $resultJson->setData(['redirect' => $redirectUrl]);
     } else {
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
         return $resultRedirect->setUrl($redirectUrl);
     }
 }
示例#4
0
 /**
  * Retrieve parameters of customer login url
  *
  * @return array
  */
 public function getLoginUrlParams()
 {
     $params = [];
     $referer = $this->request->getParam(self::REFERER_QUERY_PARAM_NAME);
     if (!$referer && !$this->scopeConfig->isSetFlag(self::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, ScopeInterface::SCOPE_STORE) && !$this->customerSession->getNoReferer()) {
         $referer = $this->urlBuilder->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
         $referer = $this->urlEncoder->encode($referer);
     }
     if ($referer) {
         $params = [self::REFERER_QUERY_PARAM_NAME => $referer];
     }
     return $params;
 }
示例#5
0
 /**
  * @return string
  */
 protected function getLinkParams()
 {
     $params = [];
     $wishlistId = $this->wishlistHelper->getWishlist()->getId();
     $customer = $this->wishlistHelper->getCustomer();
     if ($customer) {
         $key = $customer->getId() . ',' . $customer->getEmail();
         $params = ['type' => 'wishlist', 'data' => $this->urlEncoder->encode($key), '_secure' => false];
     }
     if ($wishlistId) {
         $params['wishlist_id'] = $wishlistId;
     }
     return $params;
 }
示例#6
0
 /**
  * Return tree node full path based on current path
  *
  * @return string
  */
 public function getTreeCurrentPath()
 {
     $treePath = '/root';
     $path = $this->_storageHelper->getSession()->getCurrentPath();
     if ($path) {
         $path = str_replace($this->_storageHelper->getStorageRoot(), '', $path);
         $relative = '';
         foreach (explode('/', $path) as $dirName) {
             if ($dirName) {
                 $relative .= '/' . $dirName;
                 $treePath .= '/' . $this->urlEncoder->encode($relative);
             }
         }
     }
     return $treePath;
 }
示例#7
0
 /**
  * Get files collection
  *
  * @return array
  */
 public function getFilesCollection()
 {
     $paths = $this->mediaWriteDirectory->search('.*', $this->_helper->getCurrentPath());
     $files = [];
     $requestParams = $this->_helper->getRequestParams();
     $storageType = $this->_helper->getStorageType();
     foreach ($paths as $path) {
         if (!$this->mediaWriteDirectory->isFile($path)) {
             continue;
         }
         $fileName = pathinfo($path, PATHINFO_BASENAME);
         $file = ['text' => $fileName, 'id' => $this->urlEncoder->encode($fileName)];
         if (self::TYPE_IMAGE == $storageType) {
             $requestParams['file'] = $fileName;
             $file['thumbnailParams'] = $requestParams;
             $size = @getimagesize($path);
             if (is_array($size)) {
                 $file['width'] = $size[0];
                 $file['height'] = $size[1];
             }
         }
         $files[] = $file;
     }
     return $files;
 }
 /**
  * Get add to wishlist params
  *
  * @param Product $product
  * @return string
  */
 public function getAddToWishlistParams($product)
 {
     $continueUrl = $this->urlEncoder->encode($this->getUrl('customer/account'));
     $urlParamName = Action::PARAM_NAME_URL_ENCODED;
     $continueUrlParams = [$urlParamName => $continueUrl];
     return $this->_wishlistHelper->getAddParams($product, $continueUrlParams);
 }
示例#9
0
 /**
  * Initialize review form
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite());
     if (!$this->getAllowWriteReviewFlag()) {
         $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form');
         $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam]));
     }
     $this->setTemplate('form.phtml');
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
 {
     $output = '';
     if ($this->_value) {
         switch ($format) {
             case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_JSON:
                 $output = ['value' => $this->_value, 'url_key' => $this->urlEncoder->encode($this->_value)];
                 break;
         }
     }
     return $output;
 }
示例#11
0
 /**
  * Retrieve url for direct adding product to cart
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param array $additional
  * @return string
  */
 public function getAddToCartUrl($product, $additional = [])
 {
     if ($this->hasCustomAddToCartUrl()) {
         return $this->getCustomAddToCartUrl();
     }
     if ($this->getRequest()->getParam('wishlist_next')) {
         $additional['wishlist_next'] = 1;
     }
     $addUrlKey = \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED;
     $addUrlValue = $this->_urlBuilder->getUrl('*/*/*', ['_use_rewrite' => true, '_current' => true]);
     $additional[$addUrlKey] = $this->urlEncoder->encode($addUrlValue);
     return $this->_cartHelper->getAddUrl($product, $additional);
 }
示例#12
0
 /**
  * Return formated attribute value from entity model
  *
  * @param string $format
  * @return string|array
  */
 public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
 {
     $output = '';
     $value = $this->getEntity()->getData($this->getAttribute()->getAttributeCode());
     if ($value) {
         switch ($format) {
             case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON:
                 $output = ['value' => $value, 'url_key' => $this->urlEncoder->encode($value)];
                 break;
         }
     }
     return $output;
 }
示例#13
0
文件: Form.php 项目: opexsw/magento2
 /**
  * Initialize review form
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $data = $this->_reviewSession->getFormData(true);
     $data = new \Magento\Framework\Object((array) $data);
     // add logged in customer name as nickname
     if (!$data->getNickname()) {
         $customer = $this->_customerSession->getCustomerDataObject();
         if ($customer && $customer->getId()) {
             $data->setNickname($customer->getFirstname());
         }
     }
     $this->setAllowWriteReviewFlag($this->httpContext->getValue(Context::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite());
     if (!$this->getAllowWriteReviewFlag()) {
         $queryParam = $this->urlEncoder->encode($this->getUrl('*/*/*', ['_current' => true]) . '#review-form');
         $this->setLoginLink($this->getUrl('customer/account/login/', [Url::REFERER_QUERY_PARAM_NAME => $queryParam]));
     }
     $this->setTemplate('form.phtml')->assign('data', $data);
 }
示例#14
0
 /**
  * Get url to download CSS file
  *
  * @param string $fileId
  * @param int $themeId
  * @return string
  */
 public function getDownloadUrl($fileId, $themeId)
 {
     return $this->getUrl('adminhtml/system_design_theme/downloadCss', ['theme_id' => $themeId, 'file' => $this->urlEncoder->encode($fileId)]);
 }
示例#15
0
 /**
  * Return encoded current URL for after auth redirection
  * @return string
  */
 public function getLoginUrl()
 {
     $referer = $this->urlEncoder->encode($this->_urlBuilder->getCurrentUrl());
     return $this->getUrl('facebookfree/index/index', array('referer' => $referer));
 }
示例#16
0
 /**
  * Return Preview/Download URL
  *
  * @return string
  */
 protected function _getPreviewUrl()
 {
     return $this->_adminhtmlData->getUrl('customer/index/viewfile', ['file' => $this->urlEncoder->encode($this->getValue())]);
 }
示例#17
0
 /**
  * @param array $params
  * @return string
  */
 public function getPagerEncodedUrl($params = [])
 {
     return $this->urlEncoder->encode($this->getPagerUrl($params));
 }
示例#18
0
 /**
  * Encode list of widget types into query param
  *
  * @param string[]|string $widgets List of widgets
  * @return string Query param value
  */
 public function encodeWidgetsToQuery($widgets)
 {
     $widgets = is_array($widgets) ? $widgets : [$widgets];
     $param = implode(',', $widgets);
     return $this->urlEncoder->encode($param);
 }