Analyses $linkUri when generating a link to a route, in order to have the siteaccess part back in the URI.

@param string $linkUri

@return string The modified link URI
12798
public function analyseLink($linkUri)
    {
        // Joining slash between uriElements and actual linkUri must be present, except if $linkUri is empty or is just the slash root.
        $joiningSlash = empty($linkUri) || ($linkUri === '/') ? '' : '/';
        $linkUri = ltrim($linkUri, '/');
        // Removing query string to analyse as SiteAccess might be in it.
        $qsPos = strpos($linkUri, '?');
        $queryString = '';
        if ($qsPos !== false) {
            $queryString = substr($linkUri, $qsPos);
            $linkUri = substr($linkUri, 0, $qsPos);
        }

        return "/{$this->key}{$joiningSlash}{$linkUri}{$queryString}";
    }
956754
public function getCommonRootFolder( $actualUri, $uri )
	{
		$uriParts = array_reverse( explode( "/", $uri ) );
		$actualUriParts = array_reverse( explode( "/", $actualUri ) );

		$count = min( array( count( $uriParts ), count( $actualUriParts ) ) );

		for( $i = 0; $i < $count; $i++ )
		{
			if ( $uriParts[ $i ] != $actualUriParts[ $i ] ) break;
		}

		if ( $uriParts[ $i ] === '' && isset( $uriParts[ $i + 1 ] ) && preg_match_all( "/https?:/", $uriParts[ $i + 1 ] ) )
		{
			$i--;
		}

		return array(
			'actual' => implode( "/", array_reverse( array_slice( $actualUriParts, $i ) ) ),
			'uri'    => implode( "/", array_reverse( array_slice( $uriParts, $i ) ) )
		);
	}
866137
public static function buildUri($uri, array $replaceParams)
    {
        $encoded = array();
        foreach ($replaceParams as $index => $param) {
            $encoded[$index] = urlencode($param);
        }
        return strtr($uri, $encoded);
    }
354145
protected function getRewriteUri()
    {
        if ($this->uriSource === self::URI_SOURCE_SERVER_REQUEST_URI) {
            if (isset($_SERVER['REQUEST_URI'])) {
                $requestUri = explode('?', $_SERVER['REQUEST_URI']);
                if (!empty($requestUri[0])) {
                    return $requestUri[0];
                }
            }
        } else {
            if (isset($_GET['_url']) && !empty($_GET['_url'])) {
                return $_GET['_url'];
            }
        }

        return '/';
    }
1342932
public function uri($uri = null)
    {
        $page = $this->findPageByUri($uri);

        abort_if(!$page, '404');

        if ($page->private && !Auth::check()) {
            return redirect()->guest(route(app()->getLocale().'::login'));
        }

        if ($page->redirect && $page->subpages->count() > 0) {
            $childUri = $page->subpages->first()->uri();

            return redirect($childUri);
        }

        // get submenu
        $children = $this->repository->getSubMenu($page->uri);

        $templateDir = 'pages::'.config('typicms.template_dir', 'public').'.';
        $template = $page->template ?: 'default';

        if (!view()->exists($templateDir.$template)) {
            info('Template '.$template.' not found, switching to default template.');
            $template = 'default';
        }

        return response()->view($templateDir.$template, compact('children', 'page'));
    }
1264681
private function getWorkerRelativeUrl($uri)
    {
        $uri = new Uri($uri);
        $uri = $uri
            ->withHost($this->workerRelativeUrl->getHost())
            ->withScheme($this->workerRelativeUrl->getScheme())
            ->withPort($this->workerRelativeUrl->getPort());
        return (string) $uri;
    }
350399
public function findActivePageByUri($currentUri)
    {
        $foundPages = [];
        $siteUrl = url()->current();

        $pages = $this->getPages();

        foreach ($pages as $page) {
            $url = $page->getUrl();
            $len = strpos($url, $siteUrl);
            if ($len !== false) {
                $len += strlen($siteUrl);
            }

            $url = substr($url, $len);

            $len = strpos($currentUri, $siteUrl);
            if ($len !== false) {
                $len += strlen($siteUrl);
            }

            if (! empty($url)) {
                $uri = substr($currentUri, $len);
                $pos = strpos($uri, $url);

                if ($pos !== false) {
                    $foundPages[strlen(substr($uri, strlen($url)))] = $page;
                    $page->setStatus(true);
                }
            }
        }

        if (count($foundPages) > 0) {
            ksort($foundPages);
            $page = array_shift($foundPages);
            $this->navigation->setCurrentPage($page);
        }

        foreach ($this->getSections() as $section) {
            $section->findActivePageByUri($currentUri);
        }
    }
318184
public function setRouteURI($routeURI)
    {
        //Add group prefix if any
        $groupPrefix = implode('/', Router::$groupsProps['prefix']);
        if ($groupPrefix) {
            //Remove duplicate forward slashes in prefix
            $prefixed = trim(preg_replace('/\/+/', '/', $groupPrefix), '/');
            $routeURI = $prefixed . '/' . trim($routeURI, '/');
        }

        if ($routeURI) {
            $this->routeURI = $routeURI === '/' ? $routeURI : trim($routeURI, '/');
        }

        return $this;
    }
678260
protected function _uri_string($uri)
	{
		if ($this->item('enable_query_strings') == FALSE)
		{
			if (is_array($uri))
			{
				$uri = implode('/', $uri);
			}
			$uri = trim($uri, '/');
		}
		else
		{
			if (is_array($uri))
			{
				$i = 0;
				$str = '';
				foreach ($uri as $key => $val)
				{
					$prefix = ($i == 0) ? '' : '&';
					$str .= $prefix.$key.'='.$val;
					$i++;
				}
				$uri = $str;
			}
		}
	    return $uri;
	}
273721
function site_url($uri = '')
	{
		if ($uri == '')
		{
			return $this->slash_item('base_url').$this->item('index_page');
		}

		if ($this->item('enable_query_strings') == FALSE)
		{
			$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
			return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
		}
		else
		{
			return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
		}
	}
149320
public function toBrandCoreCdn(string $uri = ''): string
    {
        if ($this->App->Parent) { // Looking for the root core.
            return $this->App->Parent->Utils->§BrandUrl->toBrandCoreCdn($uri);
        }
        return $this->toBrandCdn($uri);
    }
1058112
public function getUri($uri) {
        $curieSeperator = ':';

        if (preg_match('/http(s*)\:\/\//', $uri) == false) {
            if (strpos($uri, $curieSeperator) !== false) {
                list($prefix, $action) = explode($curieSeperator, $uri);
                
                if(isset($this->WAMP->prefixes[$prefix]) === true){
                  return $this->WAMP->prefixes[$prefix] . '#' . $action;
                }
            }
        }

        return $uri;
    }
1188939
protected function getActualUri( $uri )
	{
		foreach ( $this->rewriteURIs as $prefix => $rewriteUri )
		{
			if ( strpos( $uri, $prefix ) !== 0 ) continue;
			$actualUri =  str_replace( $prefix, $rewriteUri, $uri );
			$actualUri = XBRL::normalizePath( $this->getFirstFolderName() . "/" . XBRL_TaxonomyPackage::metaFolderName . "/" . $actualUri );
			return $actualUri;
		}

		return $uri;
	}
712860
static public function getBaseUrl($uri='')
	{
		$baseUrl  = static::getRootUrl();
		$baseUrl .= isset($_SERVER['SCRIPT_NAME']) ? dirname($_SERVER['SCRIPT_NAME']) : dirname(getenv('SCRIPT_NAME'));
		
		return rtrim(str_replace('\\', '/', $baseUrl), '/');
	}
1214990
private function toAbsoluteURI($uri)
    {
        list($pathBase, $scheme, $prePath) = $this->getPathInfo($this->configuration->getOriginalURL());

        // If this is already an absolute URI, return it.
        if (preg_match('/^[a-zA-Z][a-zA-Z0-9\+\-\.]*:/', $uri)) {
            return $uri;
        }

        // Scheme-rooted relative URI.
        if (substr($uri, 0, 2) === '//') {
            return $scheme . '://' . substr($uri, 2);
        }

        // Prepath-rooted relative URI.
        if (substr($uri, 0, 1) === '/') {
            return $prePath . $uri;
        }

        // Dotslash relative URI.
        if (strpos($uri, './') === 0) {
            return $pathBase . substr($uri, 2);
        }
        // Ignore hash URIs:
        if (substr($uri, 0, 1) === '#') {
            return $uri;
        }

        // Standard relative URI; add entire path. pathBase already includes a
        // trailing "/".
        return $pathBase . $uri;
    }
274673
public static function link($linkParams = null)
	{
		if($linkParams === null){

			$link_params = null;
		}

		elseif(is_array($linkParams)){

			$link_params = join(Registry::getConfig()['url_component_separator'], $linkParams);
		
		}

		else{

			$params = func_get_args();
			$link_params = join(Registry::getConfig()['url_component_separator'], $params);
		}

		//get the server name from global $_SERVER[] array()
		$base  = $_SERVER['SERVER_NAME']; 

		$url = Registry::getUrl();

		//check if there is a uri string
		if ( ! empty($url) ) 
		{
			//prepend installation folder to server name
			$base .= substr($_SERVER['REQUEST_URI'], 0,  strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));

		}
		//there is no query string, 
		else
		{
			//prepend installation folder to server name
			$base .= substr($_SERVER['REQUEST_URI'], 0);

		}

    	//use https if its defined in the $_SERVER global variable
    	$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";

		//compose the url string
		return $protocol . '://' . $base . $link_params;

	}
760446
public function &findPageByUri($uri)
    {
        foreach ($this->getPages() as $page) {
            if ($page->getUrl() == $uri) {
                return $page;
            }
        }

        foreach ($this->getSections() as $section) {
            $found = $section->findPageByUri($uri);
            if (! is_null($found)) {
                return $found;
            }
        }

        return;
    }