Class

Url

Package: util Author: Loic Rouchon <loic.rouchon@phpboost.com> Desc: This class offers a simple way to transform an absolute or relative link to a relative one to the website root. It can also deals with absolute url and will convert only those from this site into relatives ones. Usage :
  • In content, get the url with the absolute() method. It will allow content include at multiple level
  • In forms, get the url with the relative() method. It's a faster way to display url
Located at util/Url.class.php
Methods summary
public
# __construct( string $url = '.', string $path_to_root = null, mixed $server_url = null )
public boolean
# is_relative( )
public string
# relative( )
public string
# rel( )
public string
# absolute( )
public string
# root_to_local( )
public static string
# encode_rewrite( string $url )
public static integer
# check_url_validity( string $url )
public static integer
# get_url_file_size( string $url )
public static string
# compress( string $url )
public static string
# get_absolute_root( )
public static string
# html_convert_root_relative2absolute( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )
public static string
# html_convert_absolute2root_relative( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )
public static string
# html_convert_root_relative2relative( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )
public static string
# get_relative( string $url, string $path_to_root = null, string $server_url = null )
public static the
# get_wellformness_regex( integer $protocol = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $user = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $domain = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $folders = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $file = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $args = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $anchor = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, boolean $forbid_js = true )
public static true
# check_wellformness( integer $url, integer $protocol = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $user = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $domain = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $folders = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $file = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, integer $args = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, boolean $anchor = RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, mixed $forbid_js = true )
public static string
# to_rel( mixed $url )
public static string
# to_relative( mixed $url )
public static string
# to_absolute( mixed $url )
public static
# is_current_url( string $check_url, boolean $real_url = false )
Constants summary
string FORBID_JS_REGEX '(?!javascript:)'
#
string PROTOCOL_REGEX '[a-z0-9-_]+(?::[a-z0-9-_]+)*://'
#
string USER_REGEX '[a-z0-9-_]+(?::[a-z0-9-_]+)?@'
#
string DOMAIN_REGEX '(?:[a-z0-9-_~]+\.)*[a-z0-9-_~]+(?::[0-9]{1,5})?/'
#
string FOLDERS_REGEX '/*(?:[A-Za-z0-9~_\.+@,-]+/+)*'
#
string FILE_REGEX '[A-Za-z0-9-+_,~:/\.\%!=]+'
#
string ARGS_REGEX '(?:\?(?!&)(?:(?:&amp;|&)?[A-Za-z0-9-+=,_~:;/\.\?\'\%\*!|]+(?:=[A-Za-z0-9-+=_~:;/\.\?\'\%\*!|]+)?)*)?'
#
string ANCHOR_REGEX '\#[A-Za-z0-9-+=,_~:;/\.\?\'\%\*!&|]*'
#
integer STATUS_OK 200
#
integer STATUS_FOUND 302
#