コード例 #1
0
ファイル: Viewfile.php プロジェクト: nblair/magescotch
 /**
  * Customer view file action
  *
  * @return void
  * @throws NotFoundException
  *
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function executeInternal()
 {
     $file = null;
     $plain = false;
     if ($this->getRequest()->getParam('file')) {
         // download file
         $file = $this->urlDecoder->decode($this->getRequest()->getParam('file'));
     } elseif ($this->getRequest()->getParam('image')) {
         // show plain image
         $file = $this->urlDecoder->decode($this->getRequest()->getParam('image'));
         $plain = true;
     } else {
         throw new NotFoundException(__('Page not found.'));
     }
     /** @var \Magento\Framework\Filesystem $filesystem */
     $filesystem = $this->_objectManager->get('Magento\\Framework\\Filesystem');
     $directory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
     $fileName = 'customer' . '/' . ltrim($file, '/');
     $path = $directory->getAbsolutePath($fileName);
     if (!$directory->isFile($fileName) && !$this->_objectManager->get('Magento\\MediaStorage\\Helper\\File\\Storage')->processStorageFile($path)) {
         throw new NotFoundException(__('Page not found.'));
     }
     if ($plain) {
         $extension = pathinfo($path, PATHINFO_EXTENSION);
         switch (strtolower($extension)) {
             case 'gif':
                 $contentType = 'image/gif';
                 break;
             case 'jpg':
                 $contentType = 'image/jpeg';
                 break;
             case 'png':
                 $contentType = 'image/png';
                 break;
             default:
                 $contentType = 'application/octet-stream';
                 break;
         }
         $stat = $directory->stat($path);
         $contentLength = $stat['size'];
         $contentModify = $stat['mtime'];
         /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
         $resultRaw = $this->resultRawFactory->create();
         $resultRaw->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Content-type', $contentType, true)->setHeader('Content-Length', $contentLength)->setHeader('Last-Modified', date('r', $contentModify));
         $resultRaw->setContents($directory->readFile($fileName));
         return $resultRaw;
     } else {
         $name = pathinfo($path, PATHINFO_BASENAME);
         $this->_fileFactory->create($name, ['type' => 'filename', 'value' => $fileName], DirectoryList::MEDIA);
     }
 }
コード例 #2
0
ファイル: Index.php プロジェクト: shabbirvividads/magento2
 /**
  * Compare index action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $items = $this->getRequest()->getParam('items');
     $beforeUrl = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED);
     if ($beforeUrl) {
         $this->_catalogSession->setBeforeCompareUrl($this->urlDecoder->decode($beforeUrl));
     }
     if ($items) {
         $items = explode(',', $items);
         /** @var \Magento\Catalog\Model\Product\Compare\ListCompare $list */
         $list = $this->_catalogProductCompareList;
         $list->addProducts($items);
         $resultRedirect = $this->resultRedirectFactory->create();
         return $resultRedirect->setPath('*/*/*');
     }
     return $this->resultPageFactory->create();
 }
コード例 #3
0
 /**
  * Confirm CAPTCHA
  *
  * @return void
  */
 public function execute()
 {
     $storeId = $this->_getStore()->getId();
     try {
         $this->_objectManager->create('Magento\\GoogleShopping\\Model\\Service')->getClient($storeId, $this->urlDecoder->decode($this->getRequest()->getParam('captcha_token')), $this->getRequest()->getParam('user_confirm'));
         $this->messageManager->addSuccess(__('Captcha has been confirmed.'));
     } catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
         $this->messageManager->addError(__('There was a Captcha confirmation error: %1', $e->getMessage()));
         $this->_redirectToCaptcha($e);
         return;
     } catch (\Zend_Gdata_App_Exception $e) {
         $this->messageManager->addError($this->_objectManager->get('Magento\\GoogleShopping\\Helper\\Data')->parseGdataExceptionMessage($e->getMessage()));
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         $this->messageManager->addError(__('Something went wrong during Captcha confirmation.'));
     }
     $this->_redirect('adminhtml/*/index', ['store' => $storeId]);
 }
コード例 #4
0
ファイル: Index.php プロジェクト: shabbirvividads/magento2
 /**
  * Manage Items page with two item grids: Magento products and Google Content items
  *
  * @return void
  */
 public function execute()
 {
     if (0 === (int) $this->getRequest()->getParam('store')) {
         $this->_redirect('adminhtml/*/', ['store' => $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getId(), '_current' => true]);
         return;
     }
     $this->_initAction();
     $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Google Content Items'));
     $contentBlock = $this->_view->getLayout()->createBlock('Magento\\GoogleShopping\\Block\\Adminhtml\\Items')->setStore($this->_getStore());
     if ($this->getRequest()->getParam('captcha_token') && $this->getRequest()->getParam('captcha_url')) {
         $contentBlock->setGcontentCaptchaToken($this->urlDecoder->decode($this->getRequest()->getParam('captcha_token')));
         $contentBlock->setGcontentCaptchaUrl($this->urlDecoder->decode($this->getRequest()->getParam('captcha_url')));
     }
     if (!$this->_objectManager->get('Magento\\GoogleShopping\\Model\\Config')->isValidDefaultCurrencyCode($this->_getStore()->getId())) {
         $_countryInfo = $this->_objectManager->get('Magento\\GoogleShopping\\Model\\Config')->getTargetCountryInfo($this->_getStore()->getId());
         $this->messageManager->addNotice(__("The store's currency should be set to %1 for %2 in system configuration. Otherwise item prices won't be correct in Google Content.", $_countryInfo['currency_name'], $_countryInfo['name']));
     }
     $this->_addBreadcrumb(__('Items'), __('Items'))->_addContent($contentBlock);
     $this->_view->renderLayout();
 }
コード例 #5
0
 /**
  * Delete file
  *
  * @param string $file
  * @return \Magento\Theme\Model\Wysiwyg\Storage
  */
 public function deleteFile($file)
 {
     $file = $this->urlDecoder->decode($file);
     $path = $this->mediaWriteDirectory->getRelativePath($this->_helper->getCurrentPath());
     $filePath = $this->mediaWriteDirectory->getRelativePath($path . '/' . $file);
     $thumbnailPath = $this->_helper->getThumbnailDirectory($filePath) . '/' . $file;
     if (0 === strpos($filePath, $path) && 0 === strpos($filePath, $this->_helper->getStorageRoot())) {
         $this->mediaWriteDirectory->delete($filePath);
         $this->mediaWriteDirectory->delete($thumbnailPath);
     }
     return $this;
 }
コード例 #6
0
 /**
  * Template directives callback
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $directive = $this->getRequest()->getParam('___directive');
     $directive = $this->urlDecoder->decode($directive);
     $imagePath = $this->_objectManager->create('Stepzerosolutions\\Tbslider\\Model\\Template\\Filter')->filter($directive);
     /** @var \Magento\Framework\Image\Adapter\AdapterInterface $image */
     $image = $this->_objectManager->get('Magento\\Framework\\Image\\AdapterFactory')->create();
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     try {
         $image->open($imagePath);
         $resultRaw->setHeader('Content-Type', $image->getMimeType());
         $resultRaw->setContents($image->getImage());
     } catch (\Exception $e) {
         $imagePath = $this->_objectManager->get('Stepzerosolutions\\Tbslider\\Model\\Wysiwyg\\Config')->getSkinImagePlaceholderPath();
         $image->open($imagePath);
         $resultRaw->setHeader('Content-Type', $image->getMimeType());
         $resultRaw->setContents($image->getImage());
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
     }
     return $resultRaw;
 }
コード例 #7
0
ファイル: Index.php プロジェクト: opexsw/magento2
 /**
  * Manage Items page with two item grids: Magento products and Google Content items
  *
  * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     if (0 === (int) $this->getRequest()->getParam('store')) {
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
         return $resultRedirect->setPath('adminhtml/*/', ['store' => $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getId(), '_current' => true]);
     }
     /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
     $resultPage = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
     $resultPage->setActiveMenu('Magento_GoogleShopping::catalog_googleshopping_items')->addBreadcrumb(__('Catalog'), __('Catalog'))->addBreadcrumb(__('Google Content'), __('Google Content'));
     $resultPage->getConfig()->getTitle()->prepend(__('Google Content Items'));
     $contentBlock = $resultPage->getLayout()->createBlock('Magento\\GoogleShopping\\Block\\Adminhtml\\Items')->setStore($this->_getStore());
     if ($this->getRequest()->getParam('captcha_token') && $this->getRequest()->getParam('captcha_url')) {
         $contentBlock->setGcontentCaptchaToken($this->urlDecoder->decode($this->getRequest()->getParam('captcha_token')));
         $contentBlock->setGcontentCaptchaUrl($this->urlDecoder->decode($this->getRequest()->getParam('captcha_url')));
     }
     if (!$this->_objectManager->get('Magento\\GoogleShopping\\Model\\Config')->isValidDefaultCurrencyCode($this->_getStore()->getId())) {
         $_countryInfo = $this->_objectManager->get('Magento\\GoogleShopping\\Model\\Config')->getTargetCountryInfo($this->_getStore()->getId());
         $this->messageManager->addNotice(__("The store's currency should be set to %1 for %2 in system configuration." . " Otherwise item prices won't be correct in Google Content.", $_countryInfo['currency_name'], $_countryInfo['name']));
     }
     return $resultPage->addBreadcrumb(__('Items'), __('Items'))->addContent($contentBlock);
 }
コード例 #8
0
 /**
  * Prepare redirect URL for logged in customer
  *
  * Redirect customer to the last page visited after logging in.
  *
  * @return void
  */
 protected function processLoggedCustomer()
 {
     // Set default redirect URL for logged in customer
     $this->applyRedirect($this->customerUrl->getAccountUrl());
     if (!$this->scopeConfig->isSetFlag(CustomerUrl::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, ScopeInterface::SCOPE_STORE)) {
         $referer = $this->request->getParam(CustomerUrl::REFERER_QUERY_PARAM_NAME);
         if ($referer) {
             $referer = $this->urlDecoder->decode($referer);
             if ($this->url->isOwnOriginUrl()) {
                 $this->applyRedirect($referer);
             }
         }
     } elseif ($this->session->getAfterAuthUrl()) {
         $this->applyRedirect($this->session->getAfterAuthUrl(true));
     }
 }
コード例 #9
0
ファイル: Config.php プロジェクト: pradeep-wagento/magento2
 /**
  * Decode URL query param and return list of widgets
  *
  * @param string $queryParam Query param value to decode
  * @return string[] Array of widget types
  */
 public function decodeWidgetsFromQuery($queryParam)
 {
     $param = $this->urlDecoder->decode($queryParam);
     return preg_split('/\\s*\\,\\s*/', $param, 0, PREG_SPLIT_NO_EMPTY);
 }