Example #1
0
 /**
  * @param PageConfig $subject
  * @param string $result
  * @return string
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterGetIncludes(PageConfig $subject, $result)
 {
     $pattern = '{{MEDIA_URL}}';
     if (strpos($result, $pattern) !== false) {
         $url = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
         $result = str_replace($pattern, $url, $result);
     }
     return $result;
 }
Example #2
0
 public function getCommentText($elementValue)
 {
     $url = "";
     if ($this->_urlInterface != null) {
         $url = $this->_urlInterface->getBaseUrl();
         $url = $url . 'signifyd/webhooks/index';
         $url = "<a href=\"" . $url . "\">{$url}</a>";
     } else {
         $url = "{{store url}}/signifyd/webhooks/index";
     }
     return "{$url} <br />Use this URL to setup your Magento <a href=\"https://app.signifyd.com/settings/notifications\">webhook</a> from the Signifyd console. You MUST setup the webhook to enable order workflows and syncing of guarantees back to Magento.";
 }
Example #3
0
 /**
  * Return element html code
  *
  * @return string
  */
 public function getElementHtml()
 {
     $html = '';
     if ((string) $this->getValue()) {
         $url = $this->_getUrl();
         if (!preg_match("/^http\\:\\/\\/|https\\:\\/\\//", $url)) {
             $url = $this->_urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $url;
         }
         $html = '<a href="' . $url . '"' . ' onclick="imagePreview(\'' . $this->getHtmlId() . '_image\'); return false;" ' . $this->_getUiId('link') . '>' . '<img src="' . $url . '" id="' . $this->getHtmlId() . '_image" title="' . $this->getValue() . '"' . ' alt="' . $this->getValue() . '" height="22" width="22" class="small-image-preview v-middle"  ' . $this->_getUiId() . ' />' . '</a> ';
     }
     $this->setClass('input-file');
     $html .= parent::getElementHtml();
     $html .= $this->_getDeleteCheckbox();
     return $html;
 }
Example #4
0
 /**
  * Add Link to Head
  *
  * @return void
  */
 protected function addHeadInclude()
 {
     $styleContent = '';
     foreach ($this->moduleList->getNames() as $moduleName) {
         $fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/styles.css';
         $fileName = $this->fixtureHelper->getPath($fileName);
         if (!$fileName) {
             continue;
         }
         $style = file_get_contents($fileName);
         $styleContent .= preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', $style);
     }
     if (empty($styleContent)) {
         return;
     }
     $mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
     file_put_contents("{$mediaDir}/styles.css", $styleContent);
     $linkTemplate = '<link  rel="stylesheet" type="text/css"  media="all" href="%sstyles.css" />';
     $baseUrl = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
     $linkText = sprintf($linkTemplate, $baseUrl);
     $miscScriptsNode = 'design/head/includes';
     $miscScripts = $this->scopeConfig->getValue($miscScriptsNode);
     if (!$miscScripts || strpos($miscScripts, $linkText) === false) {
         $this->configWriter->save($miscScriptsNode, $miscScripts . $linkText);
         $this->configCacheType->clean();
     }
 }
Example #5
0
 /**
  * Get a file context value object
  *
  * Same instance per set of parameters
  *
  * @param string $baseDirType
  * @param string $urlType
  * @param string $dirPath
  * @return \Magento\Framework\View\Asset\File\Context
  */
 private function getFileContext($baseDirType, $urlType, $dirPath)
 {
     $id = implode('|', array($baseDirType, $urlType, $dirPath));
     if (!isset($this->fileContext[$id])) {
         $url = $this->baseUrl->getBaseUrl(array('_type' => $urlType));
         $this->fileContext[$id] = new \Magento\Framework\View\Asset\File\Context($url, $baseDirType, $dirPath);
     }
     return $this->fileContext[$id];
 }
 /**
  * Get a file context value object
  *
  * Same instance per set of parameters
  *
  * @param string $baseDirType
  * @param string $urlType
  * @param string $dirPath
  * @return \Magento\Framework\View\Asset\File\Context
  */
 private function getFileContext($baseDirType, $urlType, $dirPath)
 {
     $id = implode('|', [$baseDirType, $urlType, $dirPath]);
     if (!isset($this->fileContext[$id])) {
         $url = $this->baseUrl->getBaseUrl(['_type' => $urlType]);
         $this->fileContext[$id] = $this->contextFactory->create(['baseUrl' => $url, 'baseDirType' => $baseDirType, 'contextPath' => $dirPath]);
     }
     return $this->fileContext[$id];
 }
Example #7
0
 /**
  * @return \Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\Result\Redirect|null
  */
 public function aroundExecute()
 {
     $query = $this->request->getParam('q', false);
     if (!$query) {
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
         $resultRedirect->setUrl($this->url->getBaseUrl());
         return $resultRedirect;
     }
     if ($this->bxHelperData->isAutocompleteEnabled()) {
         $responseData = $this->p13nHelper->autocomplete($query, $this->autocompleteHelper);
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
         $resultJson->setData($responseData);
         return $resultJson;
     }
     return null;
 }
Example #8
0
 /**
  * Check that url type is restored to default after call getBaseUrl with type specified in params
  */
 public function testGetBaseUrlWithTypeRestoring()
 {
     /**
      * Get base URL with default type
      */
     $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
     /**
      * Set specified type
      */
     $webUrl = $this->_model->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_WEB]);
     $this->assertEquals('http://localhost/', $webUrl, 'Incorrect web url');
     $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
     /**
      * Get url with type specified in params
      */
     $mediaUrl = $this->_model->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
     $this->assertEquals('http://localhost/pub/media/', $mediaUrl, 'Incorrect media url');
     $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
 }
Example #9
0
 /**
  * Retrieve store media url
  *
  * @param string $fileName
  * @return mixed
  */
 protected function getStoreMediaUrl($fileName)
 {
     $fieldConfig = $this->getFieldConfig();
     $baseUrl = '';
     $urlType = ['_type' => UrlInterface::URL_TYPE_MEDIA];
     if (isset($fieldConfig['base_url'])) {
         $baseUrl = $fieldConfig['base_url'];
         $urlType = ['_type' => empty($baseUrl['type']) ? 'link' : (string) $baseUrl['type']];
         $baseUrl = $baseUrl['value'] . '/';
     }
     return $this->urlBuilder->getBaseUrl($urlType) . $baseUrl . $fileName;
 }
 /**
  * Retrieve environment information of magento
  * And installed extensions provided by CedCommerce
  *
  * @return array
  */
 public function getEnvironmentInformation()
 {
     $info = array();
     $info['plateform'] = 'Magento2.x';
     $info['domain_name'] = $this->urlBuilder->getBaseUrl();
     $info['magento_edition'] = 'default';
     if (method_exists('Mage', 'getEdition')) {
         $info['magento_edition'] = $this->productMetadata->getEdition();
     }
     $info['magento_version'] = $this->productMetadata->getVersion();
     $info['php_version'] = phpversion();
     $info['feed_types'] = $this->_backendConfig->getValue(\Ced\DevTool\Model\Feed::XML_FEED_TYPES);
     $info['admin_name'] = $this->_backendConfig->getValue('trans_email/ident_general/name');
     if (strlen($info['admin_name']) == 0) {
         $info['admin_name'] = $this->_backendConfig->getValue('trans_email/ident_sales/name');
     }
     $info['admin_email'] = $this->_backendConfig->getValue('trans_email/ident_general/email');
     if (strlen($info['admin_email']) == 0) {
         $info['admin_email'] = $this->_backendConfig->getValue('trans_email/ident_sales/email');
     }
     $info['installed_extensions_by_cedcommerce'] = $this->getCedCommerceExtensions(true);
     return $info;
 }
 public function buildContext()
 {
     return array_merge([self::APP_CONTEXT => 'php', self::APP_NAME => 'Magento Webstore', self::DATA_CENTER => 'external', self::HOST => $this->url->getBaseUrl(), self::LOG_TYPE => 'system', self::RESOURCE => $this->moduleName], $this->getOptionalContext());
 }
Example #12
0
 /**
  * get images base url
  *
  * @return string
  */
 public function getBaseUrl()
 {
     return $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $this->subDir . '/image';
 }
Example #13
0
 /**
  * get images base url
  *
  * @return string
  */
 public function getBaseUrl()
 {
     return $this->urlBuilder->getBaseUrl() . '../pub/' . UrlInterface::URL_TYPE_MEDIA . '/' . $this->subDir . '/image';
 }
Example #14
0
 /**
  * Generate minified file and fill the properties to reference that file
  *
  * @return void
  */
 protected function fillPropertiesByMinifyingAsset()
 {
     $path = $this->originalAsset->getPath();
     $this->context = new \Magento\Framework\View\Asset\File\Context($this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_STATIC]), DirectoryList::STATIC_VIEW, self::CACHE_VIEW_REL . '/minified');
     $this->filePath = md5($path) . '_' . $this->composeMinifiedName(basename($path));
     $this->path = $this->context->getPath() . '/' . $this->filePath;
     $this->minify();
     $this->file = $this->staticViewDir->getAbsolutePath($this->path);
     $this->url = $this->context->getBaseUrl() . $this->path;
 }
 /**
  * {@inheritdoc}
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
 {
     return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
 }
Example #16
0
 /**
  * Retrieve current secure url
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return string
  */
 protected function _getCurrentSecureUrl($request)
 {
     return $this->_url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
 }