_prepareUrl make url from uri

@param string $sUri   standard uri
@param string $sTitle page title

@access protected

@return string
437999
protected function _prepareUrl($sUri, $sTitle)
    {
        $iLang = Registry::getLang()->getBaseLanguage();
        $sUrl = $this->_getShopUrl();
        $sUrl .= $sUri . '&amp;lang=' . $iLang;

        if (Registry::getUtils()->seoIsActive()) {
            $oEncoder = Registry::getSeoEncoder();
            $sUrl = $oEncoder->getDynamicUrl($sUrl, "rss/{$sTitle}/", $iLang);
        }

        return Registry::getUtilsUrl()->prepareUrlForNoSession($sUrl);
    }
1130499
public function url($uri,$param=[])
    {
        $list=Lists::get();
        if($this->get_index($uri,$list)===false){
            $url=$uri;
        }else{
            $url=$this->return_rule($list,$param);
        }
        return urldecode($url);
    }
166196
public static function prepareUrl($url)
    {
        // $url = urlencode($url);

        $replacement = [
            '&' => '&amp;',
            "'" => '&apos;',
            '"' => '&quot;',
            '>' => '&gt;',
            '<' => '&lt;',
        ];

        $url = str_replace(array_keys($replacement), array_values($replacement), $url);

        return $url;
    }
1004776
public function handlePageNotFoundError($sUrl = '')
    {
        $this->setHeader("HTTP/1.0 404 Not Found");
        $this->setHeader("Content-Type: text/html; charset=UTF-8");

        $sReturn = "Page not found.";
        try {
            $oView = oxNew(\OxidEsales\Eshop\Application\Controller\FrontendController::class);
            $oView->init();
            $oView->render();
            $oView->setClassName('oxUBase');
            $oView->addTplParam('sUrl', $sUrl);
            if ($sRet = \OxidEsales\Eshop\Core\Registry::getUtilsView()->getTemplateOutput('message/err_404.tpl', $oView)) {
                $sReturn = $sRet;
            }
        } catch (Exception $e) {
        }
        $this->showMessageAndExit($sReturn);
    }
443765
protected final String prepareUri(final URI uri) {
        if (compareRelative) {
            final String path = uri.getRawPath();
            final String query = uri.getRawQuery();
            final String fragment = uri.getRawFragment();
            if (query != null && fragment != null) {
                return path + "?" + query + "#" + fragment;
            } else if (query != null) {
                return path + "?" + query;
            } else if (fragment != null) {
                return path + "#" + fragment;
            } else {
                return path;
            }
        } else {
            return uri.toString();
        }
    }
215497
@Nullable
  public String encodeRedirectURL (@Nullable final String sUrl)
  {
    if (StringHelper.hasText (m_sEncodeRedirectUrlSuffix))
      return StringHelper.getNotNull (sUrl) + m_sEncodeRedirectUrlSuffix;
    return sUrl;
  }
493975
public function prepareUrlForNoSession($sUrl)
    {
        /** @var \OxidEsales\Eshop\Core\StrRegular $oStr */
        $oStr = getStr();

        // cleaning up session id..
        $sUrl = $oStr->preg_replace('/(\?|&(amp;)?)(force_)?(admin_)?sid=[a-z0-9\._]+&?(amp;)?/i', '\1', $sUrl);
        $sUrl = $oStr->preg_replace('/(&amp;|\?)$/', '', $sUrl);

        if (\OxidEsales\Eshop\Core\Registry::getUtils()->seoIsActive()) {
            return $sUrl;
        }

        if ($qpos = $oStr->strpos($sUrl, '?')) {
            if ($qpos == $oStr->strlen($sUrl) - 1) {
                $sSep = '';
            } else {
                $sSep = '&amp;';
            }
        } else {
            $sSep = '?';
        }

        if (!$oStr->preg_match('/[&?](amp;)?lang=[0-9]+/i', $sUrl)) {
            $sUrl .= "{$sSep}lang=" . \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
            $sSep = '&amp;';
        }

        $oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        if (!$oStr->preg_match('/[&?](amp;)?cur=[0-9]+/i', $sUrl)) {
            $iCur = (int) $oConfig->getShopCurrency();
            if ($iCur) {
                $sUrl .= "{$sSep}cur=" . $iCur;
            }
        }

        return $sUrl;
    }
726350
public function parseStdUrl($sUrl)
    {
        $oStr = getStr();
        $aRet = [];
        $sUrl = $oStr->html_entity_decode($sUrl);

        if (($iPos = strpos($sUrl, '?')) !== false) {
            parse_str($oStr->substr($sUrl, $iPos + 1), $aRet);
        }

        return $aRet;
    }
1103223
protected function prepareUrlForKey($urlKey, array $replacements = [])
    {
        $url = $this->getUrlForKey($urlKey);
        foreach ($replacements as $parameter => $value) {
            $url = $this->prepareUrlSingle($parameter, $value, $url);
        }

        return $url;
    }
707992
protected function maintenanceMode($force = false, $sTitle = '', $sBody = '')
    {
        if ($force || file_exists(NAILS_APP_PATH . '.MAINTENANCE')) {

            /**
             * We're in maintenance mode. This can happen very early so we need to
             * make sure that we've loaded everything we need to load as we're
             * exiting whether we like it or not
             */

            $oInput = Factory::service('Input');
            $oUri   = Factory::service('Uri');

            try {

                //  Load the encryption service. Set the package path so it is loaded correctly
                //  (this runs early, before the paths are added)
                $this->load->add_package_path(NAILS_COMMON_PATH);
                Factory::service('encrypt');

                $whitelistIp   = (array) appSetting('maintenance_mode_whitelist', 'site');
                $isWhiteListed = isIpInRange($oInput->ipAddress(), $whitelistIp);

                //  Customisations
                $sMaintenanceTitle = $sTitle ? $sTitle : appSetting('maintenance_mode_title', 'site');
                $sMaintenanceBody  = $sBody ? $sBody : appSetting('maintenance_mode_body', 'site');

            } catch (\Exception $e) {

                //  No database, or it failed, defaults
                $isWhiteListed     = false;
                $sMaintenanceTitle = $sTitle;
                $sMaintenanceBody  = $sBody;
            }

            // --------------------------------------------------------------------------

            if (!$isWhiteListed) {

                if (!$oInput::isCli()) {

                    header($oInput->server('SERVER_PROTOCOL') . ' 503 Service Temporarily Unavailable');
                    header('Status: 503 Service Temporarily Unavailable');
                    header('Retry-After: 7200');

                    // --------------------------------------------------------------------------

                    //  If the request is an AJAX request, or the URL is on the API then spit back JSON
                    if ($oInput::isAjax() || $oUri->segment(1) == 'api') {

                        header('Cache-Control: no-store, no-cache, must-revalidate');
                        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
                        header('Content-Type: application/json');
                        header('Pragma: no-cache');

                        $_out = ['status' => 503, 'error' => 'Down for Maintenance'];

                        echo json_encode($_out);

                    } else {
                        //  Otherwise, render some HTML
                        if (file_exists(NAILS_APP_PATH . 'application/views/errors/html/maintenance.php')) {
                            //  Look for an app override
                            require NAILS_APP_PATH . 'application/views/errors/html/maintenance.php';
                        } else {
                            //  Fall back to the Nails maintenance page
                            require NAILS_COMMON_PATH . 'views/errors/html/maintenance.php';
                        }
                    }

                } else {
                    if (file_exists(NAILS_APP_PATH . 'application/views/errors/cli/maintenance.php')) {
                        //  Look for an app override
                        require NAILS_APP_PATH . 'application/views/errors/cli/maintenance.php';
                    } else {
                        //  Fall back to the Nails maintenance page
                        require NAILS_COMMON_PATH . 'views/errors/cli/maintenance.php';
                    }
                }
                exit(0);
            }
        }
    }
382500
public function getModuleUrl($sModule, $sFile = '')
    {
        $c = $this->getConfig();
        $shopUrl = null;
        if ($this->isAdmin()) {
            if ($c->isSsl()) {
                // From admin and with SSL we try to use sAdminSSLURL config directive
                $shopUrl = $c->getConfigParam('sAdminSSLURL');
                if ($shopUrl) {
                    // but we don't need the admin directory
                    $adminDir = '/'.$c->getConfigParam('sAdminDir');
                    $shopUrl = substr($shopUrl, 0, -strlen($adminDir));
                } else {
                    // if no sAdminSSLURL directive were defined we use sSSLShopURL config directive instead
                    $shopUrl = $c->getConfigParam('sSSLShopURL');
                }
            }
            // From admin and with no config usefull directive, we use the sShopURL directive
            if (!$shopUrl) {
                $shopUrl = $c->getConfigParam('sShopURL');
            }
        }
        // We are either in front, or in admin with no $sShopURL defined
        if (!$shopUrl) {
            $shopUrl = $c->getCurrentShopUrl();
        }
        $shopUrl = rtrim($shopUrl, '/');

        $sUrl = str_replace(
            rtrim($c->getConfigParam('sShopDir'), '/'),
            $shopUrl,
            $this->getModulePath($sModule, $sFile)
        );

        return $sUrl;
    }
866609
public function route($str_url = NULL)
    {
        $this->str_url = (NULL === $str_url ? $_SERVER['REQUEST_URI'] : $str_url);
        $this->arr_url = parse_url($this->str_url);
        if (!$this->arr_url || !isset($this->arr_url['path'])) {
            throw new Routing('URL parse error (parse_url): ' . $this->str_url);
        }
        if (!$this->routeStatic()) {
            if (!(bool)preg_match_all("#/(?<controller>[\w\-]+)#", $this->arr_url['path'], $arr_matches)) {
                throw new Routing('URL parse error (preg_match): ' . $this->str_url);
            }
            $this->setup(implode("\t", $arr_matches['controller']));
        }
        return $this;
    }
684394
public function createAbsoluteUrl($uri)
    {
        if (!isset($uri)) {
            return null;
        }

        $uri = strval($uri);
        if ($this->isRelativeUri($uri)) {
            $parts = parse_url($uri);
            $path  = isset($parts['path']) ? $parts['path'] : '';
            $query = isset($parts['query']) ? $parts['query'] : '';
            $hash  = isset($parts['fragment']) ? $parts['fragment'] : '';

            return $this->baseUrl()->withPath($path)->withQuery($query)->withFragment($hash);
        }

        return $uri;
    }
469970
public function has($sTitle = null)
	{
		if (null === $sTitle) {
			return !empty($this->aTitles);
		}

		return isset($this->aTitles[$sTitle]);
	}
1091628
public function prepUrl($url)
	{
        if (empty($url)) {
            return '';
        }

        return parse_url($url, PHP_URL_SCHEME) === null ? 'http://' . $url : $url;
	}
1049919
public function site_url($sUrl = '', $bForceSecure = false)
    {
        //  If an explicit URL is passed in, then leave it be
        if (preg_match('/^(http|https|ftp|mailto)\:/', $sUrl)) {
            return $sUrl;
        }

        $sUrl = parent::site_url($sUrl);

        //  If the URL begins with a slash then attempt to guess the host using $_SERVER
        if (preg_match('/^\//', $sUrl) && !empty($_SERVER['HTTP_HOST'])) {
            $sProtocol = !empty($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'http';
            $sUrl      = $sProtocol . '://' . $_SERVER['HTTP_HOST'] . $sUrl;
        }

        if ($bForceSecure || Functions::isPageSecure()) {
            $sUrl = preg_replace('#^' . BASE_URL . '#', SECURE_BASE_URL, $sUrl);
        }

        return $sUrl;
    }
624536
private function buildURL(string $restUrl): string
    {
        // Jira return absolute self links, so its more easy to work with get with absolute urls in such cases
        if ((\mb_strpos($restUrl, 'http://') !== 0) && (\mb_strpos($restUrl, 'https://') !== 0)) {
            return $this->tenant->getBaseUrl().$restUrl;
        }

        return $restUrl;
    }