/** * Get HTML output for override hint UI * * @param \Magento\Config\Block\System\Config\Form $form * @param array $overridden * @return string */ public function formatOverriddenScopes(\Magento\Config\Block\System\Config\Form $form, array $overridden) { $title = __('This setting is overridden at a more specific scope. Click for details.'); $formatted = '<a class="overridden-hint-list-toggle" title="' . $title . '" href="#"><span>' . $title . '</span></a>' . '<ul class="overridden-hint-list">'; foreach ($overridden as $overriddenScope) { $scope = $overriddenScope['scope']; $scopeId = $overriddenScope['scope_id']; $scopeLabel = $scopeId; $url = '#'; $section = $form->getSectionCode(); switch ($scope) { case 'website': $url = $this->urlBuilder->getUrl('*/*/*', array('section' => $section, 'website' => $scopeId)); $scopeLabel = sprintf('website <a href="%s">%s</a>', $url, $this->storeManager->getWebsite($scopeId)->getName()); break; case 'store': $store = $this->storeManager->getStore($scopeId); $website = $store->getWebsite(); $url = $this->urlBuilder->getUrl('*/*/*', array('section' => $section, 'store' => $store->getId())); $scopeLabel = sprintf('store view <a href="%s">%s</a>', $url, $website->getName() . ' / ' . $store->getName()); break; } $formatted .= "<li class='{$scope}'>Overridden on {$scopeLabel}</li>"; } $formatted .= '</ul>'; return $formatted; }
/** * Get country selector html * * @param \Magento\Framework\Data\Form\Element\AbstractElement $element * @return string */ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) { $urlParams = ['section' => $this->getRequest()->getParam('section'), 'website' => $this->getRequest()->getParam('website'), 'store' => $this->getRequest()->getParam('store'), StructurePlugin::REQUEST_PARAM_COUNTRY => '__country__']; $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams)); $jsString = ' $("' . $element->getHtmlId() . '").observe("change", function () { location.href = \'' . $urlString . '\'.replace("__country__", this.value); }); '; if ($this->_defaultCountry) { $urlParams[self::REQUEST_PARAM_DEFAULT_COUNTRY] = '__default__'; $urlString = $this->_escaper->escapeJsQuote($this->_url->getUrl('*/*/*', $urlParams)); $jsParentCountry = $this->_escaper->escapeJsQuote($this->_defaultCountry); $jsString .= ' $("' . $element->getHtmlId() . '_inherit").observe("click", function () { if (this.checked) { location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\') .replace("__default__", "1"); } }); '; } return parent::_getElementHtml($element) . $this->_jsHelper->getScript('require([\'prototype\'], function(){document.observe("dom:loaded", function() {' . $jsString . '});});'); }
public function testGetUrlWithUrlInRoutePath() { $routePath = 'https://localhost/index.php/catalog/product/view/id/100/?foo=bar#anchor'; static::assertEquals($routePath, $this->_model->getUrl($routePath)); }