Converts absolute URL to relative URL needed by {@see add_to_log()}

@param moodle_url $url absolute URL
@return string
972355
protected function log_convert_url(moodle_url $fullurl) {
        static $baseurl;

        if (!isset($baseurl)) {
            $baseurl = new moodle_url('/mod/workshop/');
            $baseurl = $baseurl->out();
        }

        return substr($fullurl->out(), strlen($baseurl));
    }
502252
protected function parseUrl($url = "")
    {
        $parsed = ($url) ? parse_url($url) : parse_url($this->_env['REQUEST_URI']);
        
        if (preg_match('/[a-zA-Z0-9_]+\.php/i', $parsed['path'], $matches)) {
            $parsed['path'] = preg_replace("/$matches[0]/", '/', $parsed['path']);
        }
        
        return $parsed;
    }
3552
public function add_url_params(moodle_url $url) {
        if (empty($this->type)) {
            return $url;
        }

        $url->param('gpr_type', $this->type);

        if (!empty($this->plugin)) {
            $url->param('gpr_plugin', $this->plugin);
        }

        if (!empty($this->courseid)) {
            $url->param('gpr_courseid' ,$this->courseid);
        }

        if (!empty($this->userid)) {
            $url->param('gpr_userid', $this->userid);
        }

        if (!empty($this->groupid)) {
            $url->param('gpr_groupid', $this->groupid);
        }

        if (!empty($this->page)) {
            $url->param('gpr_page', $this->page);
        }

        return $url;
    }
908086
public static function getRootUrl($url)
  {
    $url_parts = self::splitURL($url);
    $root_url = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"];
    
    return self::normalizeURL($root_url);
  }
150499
private function buildUrlWithoutHost($url, array $parameters)
    {
        return $this
            ->urlGeneratorInterface
            ->generate(
                $url,
                $parameters,
                UrlGeneratorInterface::ABSOLUTE_URL
            );
    }
1052478
public function getAbsolute($url)
    {
        $url = trim($url);

        if (empty($url)) {
            return '';
        }

        if (preg_match('|^\w+:[^/]|', $url)) {
            return $url;
        }

        if (preg_match('|^\w+://|', $url)) {
            return self::validUrlOrEmpty($url);
        }

        if (strpos($url, '://') === 0) {
            return self::validUrlOrEmpty($this->getScheme().$url);
        }

        if (strpos($url, '//') === 0) {
            return self::validUrlOrEmpty($this->getScheme().":$url");
        }

        if ($url[0] === '/') {
            return self::validUrlOrEmpty($this->getScheme().'://'.$this->getHost().$url);
        }

        return self::validUrlOrEmpty($this->getScheme().'://'.$this->getHost().$this->getDirectories().$url);
    }
1351740
final public function get_url() {
        global $PAGE;
        $params = array(
            $this->get_varsearch()    => $this->get_search()
        );
        return ($this->url !== null) ? new moodle_url($this->url, $params) : new moodle_url($PAGE->url, $params);
    }
129354
public static function refineDashInUrl($url)
    {
        $url = preg_replace('/[-]+/', '-', $url);
        if ($url[0] == '-') {
            $url = substr($url, 1);
        }
        if ($url[strlen($url) - 1] == '-') {
            $url = substr($url, 0, strlen($url) - 1);
        }

        return $url;
    }
1063323
public static function absoluteURLs($html)
    {
        $html = str_replace('$CurrentPageURL', Controller::curr()->getRequest()->getURL(), $html);
        return HTTP::urlRewriter($html, function ($url) {
            //no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":")
            if (preg_match('/^\w+:/', $url)) {
                return $url;
            }
            return Director::absoluteURL($url, true);
        });
    }
883187
public static function convertUtfUrl($url)
    {
        $parts = (array) parse_url($url);

        if (isset($parts['host'])) {
            if (function_exists('idn_to_ascii')) {
                $parts['host'] = idn_to_ascii($parts['host']);
            }
        }

        if (isset($parts['path'])) {
            $parts['path'] = implode('/', array_map('urlencode', explode('/', $parts['path'])));
        }

        if (isset($parts['query'])) {
            parse_str($parts['query'], $query);

            $parts['query'] = http_build_query($query);
        }

        return self::buildUrl($parts);
    }
310326
public function baseUrl($url = null)
    {
        if (!is_null($url) && true !== $url) {
            $this->baseUrl = $url;
            return $this;
        } elseif (!$this->baseUrl) {
            $str           = $this->url();
            $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str;
        }
        return true === $url ? $this->domain() . $this->baseUrl : $this->baseUrl;
    }
379221
protected function _removeRelative($url) {
        $components = parse_url($url);
        $relative = $this->_relative();
        $path = trim($components['path'], '/');
        if ($relative && strpos($path, $relative) === 0) {
            $path = trim(substr($path, strlen($relative)), '/');
        }
        return '/'.$path;
    }
304716
public function url($url)
    {
        if (\is_string($url)) {
            if ('/' == $url[0]) {
                return $this->getPathToRoot().ltrim($url, '/');
            } elseif (\is_string($url)) {
                return $url;
            }
        } elseif ($url instanceof ClassDefinition) {
            return $this->url(Documentation::classUrl($url));
        } elseif ($url instanceof CompilerFile) {
            return $this->url(Documentation::classUrl($url->getClassDefinition()));
        }

        return '';
    }
1127440
public static function getPathFromURL($url)
	{
		$path = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
		$path = str_replace(self::getDomainFromURL($url), '', $path);
		
		if($path == '') return '/';
		
		return $path;
	}
166982
public static function getUrl($url = false)
    {
        $url = false !== $url ? $url : self::$_url;
        return $url;
    }
1001236
public function getMainUrl($url)
    {
        $social  = $this->getSocialNetworkFromDomain($url);
        foreach ($this->getDefinitions() as $domain => $name) {

            if ($name == $social) {

                return $domain;
            }
        }
        return $url;
    }
528963
public function getUrl($url)
    {
        if (!$url || starts_with($url, ['#', '//', 'mailto:', 'tel:', 'http'])) {
            return $url;
        }

        // Get URL root
        $root = $this->app->getSetting('url');

        $url = trim($root, '/') . '/' . trim($url, '/');

        // Force trailing slash
        if ($this->app->getSetting('url_trailing_slash', false)
            && ! strrchr(basename($url), '.')
        ) {
            $url = "{$url}/";
        }

        return $url;
    }