Returns short link

@param string $fullLink

@return string
499967
public static function getShortLink ($fullLink)
        {
            $prefix = 'http://' . SITE_SERVER_NAME . '/';

            $rsShortLink = \CBXShortUri::GetList (
                [],
                [
                    'URI' => $fullLink,
                ]
            );

            if ($shortLink = $rsShortLink->Fetch ())
            {
                return $prefix . $shortLink['SHORT_URI'];
            }

            $shortLink = \CBXShortUri::GenerateShortUri ();

            $id = \CBXShortUri::Add (
                [
                    'URI'       => $fullLink,
                    'SHORT_URI' => $shortLink,
                    'STATUS'    => '301',
                ]
            );

            if ($id)
            {
                return $prefix . $shortLink;
            }
        }
142463
public function activeLink($link)
    {
        $pathinfo = $this->getPathInfo();
        if (($pathinfo and '/' . $pathinfo === $link) or (!$pathinfo and $link === '/')) {
            return ' active'; //the white space is nedded
        }

        return '';
    }
252314
protected function LinkWithSearch($link) {
        // Whitelist to avoid side effects
        $params=array(
                    'q'=>(array)$this->request->getVar('q'),
                    'tag'=>$this->request->getVar('tag'),
                    'creator'=>$this->request->getVar('creator'),
                    'ParentID'=>$this->request->getVar('ParentID')
                );
        
        $link=Controller::join_links(
                                    $link,
                                    (array_filter(array_values($params)) ? '?'.http_build_query($params):null)
                                );
        
        $this->extend('updateLinkWithSearch', $link);
        return $link;
    }
62719
public static function getLinkData( $link )
    {
        $root = str_replace('\\', '/', TL_ROOT) . '/';
        $sym = substr( str_replace('\\', '/', $link), strlen($root) );
        $target = str_replace('\\', '/', readlink( $link ) );
        
        if( substr($target, 0, strlen($root)) === $root ) {         // absolute path
            $target = substr($target, strlen($root));
            $depth = count(explode('/', $sym)) - 1;
        }
        else {                                                      // relative path
            $depth = 0;
            while( substr($target, 0, 3) === '../' ) {
                $target = substr($target, 3);
                $depth++;
            }
        }

        return array( 'link'=>$sym, 'target'=>trim($target, '/'), 'depth'=>$depth );        
    }
797568
public static function shortUrl($url, $key = '2270845191') {
	    $r = file_get_contents("http://api.t.sina.com.cn/short_url/shorten.json?source={$key}&url_long={$url}");

	    if($r) {
	        $items = json_decode($r);
	        return $items[0]->url_short;
	    }

	    return '';
	}
1132170
public static function get($link, $args = null)
    {
        $base_url = self::base();

        $gen_link = $link;
        if ($args == null) {
            $gen_link = $base_url.$link;
        } elseif (!is_array($args)) {
            $gen_link = $base_url.'/'.str_replace('$1', $args, $link);
        } else {
            for ($i = 0; isset($args[$i]); ++$i) {
                $gen_link = str_replace('$'.($i + 1), $args[$i], $gen_link);
            }
            $gen_link = $base_url.$gen_link;
        }

        return $gen_link;
    }
627459
public function toString(bool $full = false)
    {
        if (count($this->message) == 0) {
            return null;
        }

        if ($full) {
            return implode(PHP_EOL, $this->message);
        } else {
            return $this->message[0];
        }
    }
958029
public static function expandShortUrl($shortURL)
    {
        if (empty($shortURL)) {
            return false;
        }

        $headers = get_headers($shortURL, 1);
        if (isset($headers['Location'])) {
            return $headers['Location'];
        }

        $data = self::curl($shortURL);

        preg_match_all('/<[\s]*meta[\s]*http-equiv="?'.'([^>"]*)"?[\s]*'.'content="?([^>"]*)"?[\s]*[\/]?[\s]*>/si', $data, $match);

        if (isset($match) && is_array($match) && count($match) == 3) {
            $originals = $match[0];
            $names = $match[1];
            $values = $match[2];
            if ((isset($originals) && isset($names) && isset($values)) && count($originals) == count($names) && count($names) == count($values)) {
                $metaTags = [];
                for ($i = 0, $limit = count($names); $i < $limit; $i++) {
                    $metaTags[$names[$i]] = ['html' => htmlentities($originals[$i]), 'value' => $values[$i]];
                }
            }
        }

        if (isset($metaTags['refresh']['value']) && !empty($metaTags['refresh']['value'])) {
            $returnData = explode('=', $metaTags['refresh']['value']);
            if (isset($returnData[1]) && !empty($returnData[1])) {
                return $returnData[1];
            }
        }

        return false;
    }
1293430
public function getShortContent($maxlength = 50, $attr = 'content')
    {
        $content = $this->{$attr};
        if (strlen($content) > $maxlength) {
            return substr($content, 0, $maxlength).'...';
        }

        return $content;
    }
903277
public function cleanLink($link)
	{
		$link = strtolower(preg_replace(
					array('#[\\s-]+#', '#[^A-Za-z0-9/ -]+#'),
					array('-', ''),
				    $this->cleanString(urldecode($link))
		));

		$link = preg_replace('/\/+/', '/', $link);
		$link = preg_replace('/-+/', '-', $link);
		
		return $link;
	}
445819
public function getFullUrl($prefix = TRUE)
    {
        if ($this->_fullUrl === FALSE) $this->fillPath();
		
        if ($prefix) {
			if (
				(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
				(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || 
				(!empty($_SERVER['HTTP_HTTPS']) && $_SERVER['HTTP_HTTPS'] !== 'off') || 
				(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)
			)		
				$schema = 'https:/';
				else $schema = 'http:/';
			return $schema.$this->_fullUrl;
		}
        return $this->_fullUrl;
    }
1134093
public function getFullUrl(): string
    {
        $queryString = $this->getQueryString();

        return sprintf(
            '%s%s%s',
            static::getBaseUri(),
            $this->getEndpoint(),
            ($queryString) ? '/?'.$queryString : ''
        );
    }
133855
public function fullName(bool $link = false): string
    {
        if ($this->parts->isEmpty()) {
            return '';
        }

        $full_name = $this->parts->implode(I18N::$list_separator);

        if ($link) {
            return '<a dir="auto" href="' . e($this->url()) . '">' . e($full_name) . '</a>';
        }

        return '<span dir="auto">' . e($full_name) . '</span>';
    }
533519
public static function getRssLink($link = '')
    {
        while (stristr($link, 'http') != $link) {
            $link = substr($link, 1);
        }
        $link = esc_url(strip_tags($link));

        return $link;
    }
893260
function short($action,$module,$bundle){

		if(is_array($this->get('routes'))){
			foreach($this->get('routes') as $r){ //precalculate short links
				if($bundle == $r['bundle'] && $module ==$r['default_module'] && $action==$r['default_action'] && !empty($r['short'])){

					return $r['short'];
				}
			}

			return "/".$bundle."/".$module."/".$action;
		}
		return "/".$bundle."/".$module."/".$action;
	}
617527
public function getMimeType($fullPath)
	{
		$dynamicPath = $this->getDynamicPath($fullPath, false);
		$meta = $this->metadata($dynamicPath);
		$mime_type = $meta['content-type'];

		// try to define mime type based on file extension if default "octet-stream" is obtained
		if((end(explode('/', $mime_type)) === 'octet-stream')) {
			$mime_type = mime_type_by_extension($this->get['path']);
		}
		return $mime_type;
	}
160760
static public function get_by_link($link, $cache = true) {
		$current = Multisites::inst()->getCurrentSiteId();
		
		if(trim($link, '/')) {
			$link = trim(Director::makeRelative($link), '/');
		} else {
			$link = RootURLController::get_homepage_link();
		}
		
		$parts = Convert::raw2sql(preg_split('|/+|', $link));
		
		// Grab the initial root level page to traverse down from.
		$URLSegment = array_shift($parts);
		
		$sitetree   = DataObject::get_one (
			SiteTree::class, "\"URLSegment\" = '$URLSegment' AND \"ParentID\" = " . $current, $cache
		);
		
		if (!$sitetree) {
			return false;
		}
		
		/// Fall back on a unique URLSegment for b/c.
		if(!$sitetree && self::nested_urls() && $page = DataObject::get(SiteTree::class, "\"URLSegment\" = '$URLSegment'")->First()) {
			return $page;
		}

		// Check if we have any more URL parts to parse.
		if(!count($parts)) return $sitetree;

		// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
		foreach($parts as $segment) {
			$next = DataObject::get_one (
				SiteTree::class, "\"URLSegment\" = '$segment' AND \"ParentID\" = $sitetree->ID", $cache
			);
			
			if(!$next) {
				return false;
			}

			$sitetree->destroy();
			$sitetree = $next;
		}

		return $sitetree;
	}