예제 #1
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     $readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' . __('Read Details') . '</a>' : '';
     $markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]) . '">' . __('Mark as Read') . '</a>' : '';
     $encodedUrl = $this->_urlHelper->getEncodedUrl();
     return sprintf('%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>', $readDetailsHtml, $markAsReadHtml, $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
 }
예제 #2
0
 /**
  * get data for post by javascript in format acceptable to $.mage.dataPost widget
  *
  * @param string $url
  * @param array $data
  * @return string
  */
 public function getPostData($url, array $data = [])
 {
     if (!isset($data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED])) {
         $data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl();
     }
     return json_encode(['action' => $url, 'data' => $data]);
 }
예제 #3
0
 /**
  * Set redirect url for store view based on request path info
  *
  * @param \Magento\Store\Block\Switcher $switcher
  * @param \Magento\Store\Model\Store $store
  * @param array $data
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeGetTargetStorePostData(\Magento\Store\Block\Switcher $switcher, \Magento\Store\Model\Store $store, $data = [])
 {
     $urlRewrite = $this->urlFinder->findOneByData([UrlRewrite::TARGET_PATH => $this->trimSlashInPath($this->request->getPathInfo()), UrlRewrite::STORE_ID => $store->getId()]);
     if ($urlRewrite) {
         $data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl($this->trimSlashInPath($this->urlBuilder->getUrl($urlRewrite->getRequestPath())));
     }
     return [$store, $data];
 }
예제 #4
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     $encodedUrl = $this->_urlHelper->getEncodedUrl();
     if (!$row->getIsRead()) {
         return sprintf('<a href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]), __('Mark as Read'), $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
     } else {
         return sprintf('<a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
     }
     return parent::render($row);
 }
예제 #5
0
 /**
  * Get post parameters
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return string
  */
 public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
 {
     $url = $this->getAddToCartUrl($product);
     return ['action' => $url, 'data' => ['product' => $product->getEntityId(), \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url)]];
 }
예제 #6
0
 public function testGetEncodedUrl()
 {
     $this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MS8,', $this->_helper->getEncodedUrl());
     $this->assertEquals('aHR0cDovL2V4YW1wbGUuY29tLw,,', $this->_helper->getEncodedUrl('http://example.com/'));
 }
예제 #7
0
 /**
  * Prepare current URL for referer
  *
  * @return string
  */
 public function getUrlForReferer()
 {
     return \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED . '/' . $this->_urlHelper->getEncodedUrl();
 }
예제 #8
0
 /**
  * Prepare current URL for referer
  *
  * @return string
  */
 public function getUrlForReferer()
 {
     return ActionInterface::PARAM_NAME_URL_ENCODED . '/' . $this->_urlHelper->getEncodedUrl();
 }