Methods summary
public
|
#
__construct( string $url = '.', string $path_to_root = null, $server_url = null )
Build a Url object. By default, builds an Url object representing the current path.
If the url is empty, no computation is done and an empty string will be returned
when asking for both relative and absolute form of the url.
Build a Url object. By default, builds an Url object representing the current path.
If the url is empty, no computation is done and an empty string will be returned
when asking for both relative and absolute form of the url.
Parameters
- $url
the url string relative to the current path,
to the website root if beginning with a "/" or an absolute url
- $path_to_root
- url context. default is PATH_TO_ROOT
- $server_url
|
public
boolean
|
#
is_relative( )
Returns
boolean true if the url is a relative one
|
public
string
|
#
relative( )
Returns the root relative url if defined, else the absolute one
Returns the root relative url if defined, else the absolute one
Returns
string the root relative url if defined, else the absolute one
|
public
string
|
#
rel( )
Returns the relative url if defined, else the absolute one
Returns the relative url if defined, else the absolute one
Returns
string the relative url if defined, else the absolute one
|
public
string
|
#
absolute( )
Returns the absolute url
Returns
string the absolute url
|
public
string
|
#
root_to_local( )
Returns the relative path from the website root to the current path if working on a relative url
Returns the relative path from the website root to the current path if working on a relative url
Returns
string the relative path from the website root to the current path if working on a relative url
|
public static
string
|
#
encode_rewrite( string $url )
Prepares a string for it to be used in an URL (with only a-z, 0-9 and - characters).
Prepares a string for it to be used in an URL (with only a-z, 0-9 and - characters).
Parameters
- $url
- $string String to encode.
Returns
string The encoded string.
|
public static
integer
|
#
check_url_validity( string $url )
Checks the status of an url.
Checks the status of an url.
Parameters
Returns
integer The status of the url.
|
public static
integer
|
#
get_url_file_size( string $url )
Retrieves the size of a file in url.
Retrieves the size of a file in url.
Parameters
Returns
integer The size of the url file.
|
public static
string
|
#
compress( string $url )
Compress a url by removing all "folder/.." occurrences
Compress a url by removing all "folder/.." occurrences
Parameters
Returns
string the compressed url
|
public static
string
|
#
get_absolute_root( )
Returns the absolute website root Url
Returns the absolute website root Url
Returns
string the absolute website root Url
|
public static
string
|
#
html_convert_root_relative2absolute( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )
Returns the HTML text with only absolutes urls
Returns the HTML text with only absolutes urls
Parameters
- $html_text
The HTML text in which we gonna search for
root relatives urls (only those beginning by '/') to convert into absolutes ones.
- $path_to_root
- Path to root of the page to which you want to fit the URL.
- $server_url
- Path from the site root of the page to which you want to fit the URL.
Returns
string The HTML text with only absolutes urls
|
public static
string
|
#
html_convert_absolute2root_relative( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )
Returns the HTML text with only relatives urls
Returns the HTML text with only relatives urls
Parameters
- $html_text
- The HTML text in which we gonna search for absolutes urls to convert into relatives ones.
- $path_to_root
- Path to root of the page to which you want to fit the URL.
- $server_url
- Path from the site root of the page to which you want to fit the URL.
Returns
string The HTML text with only absolutes urls
|
public static
string
|
#
html_convert_root_relative2relative( string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL )
Transforms the relative URL whose base is the site root (for instance /images/mypic.png) to the real relative path fited to the current page.
Transforms the relative URL whose base is the site root (for instance /images/mypic.png) to the real relative path fited to the current page.
Parameters
- $html_text
- The HTML text in which you want to replace the paths
- $path_to_root
- Path to root of the page to which you want to fit the URL.
- $server_url
- Path from the site root of the page to which you want to fit the URL.
Returns
string The transformed string
|
public static
string
|
#
get_relative( string $url, string $path_to_root = null, string $server_url = null )
Parameters
- $url
- the url to "relativize"
- $path_to_root
- Path to root of the page to which you want to fit the URL
- $server_url
- Path from the site root of the page to which you want to fit the URL.
Returns
string the relative url of the $url parameter
|
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 $forbid_js = true, boolean $forbid_js,… )
Returns the regex matching the requested url form
Returns the regex matching the requested url form
Parameters
- $protocol
- REGEX_MULTIPLICITY_OPTION for the protocol sub-regex
- $user
- REGEX_MULTIPLICITY_OPTION for the user:password@ sub-regex
- $domain
- REGEX_MULTIPLICITY_OPTION for the domain sub-regex
- $folders
- REGEX_MULTIPLICITY_OPTION for the folders sub-regex
- $file
- REGEX_MULTIPLICITY_OPTION for the file sub-regex
- $args
- REGEX_MULTIPLICITY_OPTION for the arguments sub-regex
- $forbid_js
- $anchor REGEX_MULTIPLICITY_OPTION for the anchor sub-regex
- $forbid_js,…
- true if you want to forbid javascript uses in urls
Returns
the regex matching the requested url form
See
RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL
REGEX_MULTIPLICITY_NEEDED
RegexHelper::REGEX_MULTIPLICITY_AT_LEAST_ONE
RegexHelper::REGEX_MULTIPLICITY_ALL
RegexHelper::REGEX_MULTIPLICITY_NOT_USED
|
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, $forbid_js = true )
Returns true if the url match the requested url form
Returns true if the url match the requested url form
Parameters
- $url
- $protocol REGEX_MULTIPLICITY_OPTION for the protocol sub-regex
- $protocol
- $user REGEX_MULTIPLICITY_OPTION for the user:password@ sub-regex
- $user
- $domain REGEX_MULTIPLICITY_OPTION for the domain sub-regex
- $domain
- $folders REGEX_MULTIPLICITY_OPTION for the folders sub-regex
- $folders
- $file REGEX_MULTIPLICITY_OPTION for the file sub-regex
- $file
- $args REGEX_MULTIPLICITY_OPTION for the arguments sub-regex
- $args
- $anchor REGEX_MULTIPLICITY_OPTION for the anchor sub-regex
- $anchor
- $forbid_js true if you want to forbid javascript uses in urls
- $forbid_js
Returns
true if the url match the requested url form
See
RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL
REGEX_MULTIPLICITY_NEEDED
RegexHelper::REGEX_MULTIPLICITY_AT_LEAST_ONE
RegexHelper::REGEX_MULTIPLICITY_ALL
RegexHelper::REGEX_MULTIPLICITY_NOT_USED
|
public static
string
|
#
to_rel( mixed $url )
Returns an url relative from the server root
Returns an url relative from the server root
Parameters
- $url
- the url representation. Could be a string or an Url object
Returns
string an url relative from the server root
|
public static
string
|
#
to_relative( mixed $url )
Returns an url relative from PHPBoost root
Returns an url relative from PHPBoost root
Parameters
- $url
- the url representation. Could be a string or an Url object
Returns
string an url relative from PHPBoost root
|
public static
string
|
#
to_absolute( mixed $url )
Returns an absolute url
Parameters
- $url
- the url representation. Could be a string or an Url object
Returns
string an absolute url
|
public static
|
#
is_current_url( string $check_url, boolean $real_url = false )
Returns true if $check_url is current url
Returns true if $check_url is current url
Parameters
- $check_url
- check url
- $real_url
- true if check real url or false for verificate $check_url is containing in current url
|