Summary
- File
- Package hierarchy Util
- Class hierarchy \Url
__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.
string | $url | the url string relative to the current path, to the website root if beginning with a "/" or an absolute url |
string | $path_to_root | url context. default is PATH_TO_ROOT |
$server_url |
None found |
is_relative() : boolean
true if the url is a relative one
None found |
relative() : string
Returns the root relative url if defined, else the absolute one
the root relative url if defined, else the absolute one
None found |
rel() : string
Returns the relative url if defined, else the absolute one
the relative url if defined, else the absolute one
None found |
absolute() : string
Returns the absolute url
the absolute url
None found |
root_to_local() : string
Returns the relative path from the website root to the current path if working on a relative url
the relative path from the website root to the current path if working on a relative url
None found |
encode_rewrite( $url) : string
Prepares a string for it to be used in an URL (with only a-z, 0-9 and - characters).
$url |
The encoded string.
None found |
check_url_validity(string $url) : integer
Checks the status of an url.
string | $url | Url to check. |
The status of the url.
None found |
get_url_file_size(string $url) : integer
Retrieves the size of a file in url.
string | $url | Url to check. |
The size of the url file.
None found |
compress(string $url) : string
Compress a url by removing all "folder/.
." occurrences
string | $url | the url to compress |
the compressed url
None found |
get_absolute_root() : string
Returns the absolute website root Url
the absolute website root Url
None found |
html_convert_root_relative2absolute(string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL) : string
Returns the HTML text with only absolutes urls
string | $html_text | The HTML text in which we gonna search for root relatives urls (only those beginning by '/') to convert into absolutes ones. |
string | $path_to_root | Path to root of the page to which you want to fit the URL. |
string | $server_url | Path from the site root of the page to which you want to fit the URL. |
The HTML text with only absolutes urls
None found |
html_convert_absolute2root_relative(string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL) : string
Returns the HTML text with only relatives urls
string | $html_text | The HTML text in which we gonna search for absolutes urls to convert into relatives ones. |
string | $path_to_root | Path to root of the page to which you want to fit the URL. |
string | $server_url | Path from the site root of the page to which you want to fit the URL. |
The HTML text with only absolutes urls
None found |
html_convert_root_relative2relative(string $html_text, string $path_to_root = PATH_TO_ROOT, string $server_url = SERVER_URL) : string
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.
string | $html_text | The HTML text in which you want to replace the paths |
string | $path_to_root | Path to root of the page to which you want to fit the URL. |
string | $server_url | Path from the site root of the page to which you want to fit the URL. |
The transformed string
None found |
get_relative(string $url, string $path_to_root = null, string $server_url = null) : string
string | $url | the url to "relativize" |
string | $path_to_root | Path to root of the page to which you want to fit the URL |
string | $server_url | Path from the site root of the page to which you want to fit the URL. |
the relative url of the $url parameter
None found |
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, boolean $forbid_js = true) : \the
Returns the regex matching the requested url form
integer | $protocol | REGEX_MULTIPLICITY_OPTION for the protocol sub-regex |
integer | $user | REGEX_MULTIPLICITY_OPTION for the user:password@ sub-regex |
integer | $domain | REGEX_MULTIPLICITY_OPTION for the domain sub-regex |
integer | $folders | REGEX_MULTIPLICITY_OPTION for the folders sub-regex |
integer | $file | REGEX_MULTIPLICITY_OPTION for the file sub-regex |
integer | $args | REGEX_MULTIPLICITY_OPTION for the arguments sub-regex |
boolean | $forbid_js | true if you want to forbid javascript uses in urls |
regex matching the requested url form
None found |
check_wellformness( $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, integer $anchor = \RegexHelper::REGEX_MULTIPLICITY_OPTIONNAL, boolean $forbid_js = true) : true
Returns true if the url match the requested url form
$url | ||
integer | $protocol | REGEX_MULTIPLICITY_OPTION for the protocol sub-regex |
integer | $user | REGEX_MULTIPLICITY_OPTION for the user:password@ sub-regex |
integer | $domain | REGEX_MULTIPLICITY_OPTION for the domain sub-regex |
integer | $folders | REGEX_MULTIPLICITY_OPTION for the folders sub-regex |
integer | $file | REGEX_MULTIPLICITY_OPTION for the file sub-regex |
integer | $args | REGEX_MULTIPLICITY_OPTION for the arguments sub-regex |
integer | $anchor | REGEX_MULTIPLICITY_OPTION for the anchor sub-regex |
boolean | $forbid_js | true if you want to forbid javascript uses in urls |
if the url match the requested url form
None found |
to_rel(mixed $url) : string
Returns an url relative from the server root
mixed | $url | the url representation. Could be a string or an Url object |
an url relative from the server root
None found |
to_relative(mixed $url) : string
Returns an url relative from PHPBoost root
mixed | $url | the url representation. Could be a string or an Url object |
an url relative from PHPBoost root
None found |
to_absolute(mixed $url) : string
Returns an absolute url
mixed | $url | the url representation. Could be a string or an Url object |
an absolute url
None found |
is_current_url(string $check_url, boolean $real_url = false)
Returns true if $check_url is current url
string | $check_url | check url |
boolean | $real_url | true if check real url or false for verificate $check_url is containing in current url |
None found |
convert_url_to_absolute(array<mixed,string> $url_params) : string
replace a relative url by the corresponding absolute one
array<mixed,string> | $url_params | Array containing the attributes containing the url and the url |
the replaced url
None found |
convert_url_to_root_relative(array<mixed,string> $url_params) : string
replace an absolute url by the corresponding root relative one if possible
array<mixed,string> | $url_params | Array containing the attributes containing the url and the url |
the replaced url
None found |
convert_url_to_relative(array<mixed,string> $url_params) : string
replace an absolute url by the corresponding relative one if possible
array<mixed,string> | $url_params | Array containing the attributes containing the url and the url |
the replaced url
None found |
build_html_match_regex( $only_match_relative = false)
$only_match_relative |
None found |
FORBID_JS_REGEX = '(?!javascript:)'
None found |
PROTOCOL_REGEX = '[a-z0-9-_]+(?::[a-z0-9-_]+)*://'
None found |
USER_REGEX = '[a-z0-9-_]+(?::[a-z0-9-_]+)?@'
None found |
DOMAIN_REGEX = '(?:[a-z0-9-_~]+\.)*[a-z0-9-_~]+(?::[0-9]{1,5})?/'
None found |
FOLDERS_REGEX = '/*(?:[A-Za-z0-9~_\.+@,-]+/+)*'
None found |
FILE_REGEX = '[A-Za-z0-9-+_,~:/\.\%!=]+'
None found |
ARGS_REGEX = '(/([\w/_\.#-]*(\?)?(\S+)?[^\.\s])?)?'
None found |
STATUS_OK = 200
None found |
STATUS_FOUND = 302
None found |