Jelix 1.7.18

jUrl extends jUrlBase
in package

Object that contains url data, and which provides static method helpers.

Tags
subpackage

core_url

author

Laurent Jouanneau (for the original code from Copix and enhancement for jelix)

author

Gerald Croes (for the original code from Copix)

contributor

Loic Mathaud

contributor

Thibault Piront (nuKs)

Table of Contents

JURL  = 2
JURLACTION  = 3
STRING  = 0
XMLSTRING  = 1
$params  : mixed
parameters.
$pathInfo  : string
path info part of the url.
$scriptName  : string
script name including its path.
__construct()  : mixed
constructor.
__toString()  : mixed
magic method for echo and others.
appendToUrlString()  : string
Adds parameters to the given url.
clearParam()  : mixed
Clear parameters.
delParam()  : mixed
delete a parameter.
escape()  : string
escape and simplier a string to be a part of an url path remove or replace not allowed characters etc.
get()  : mixed
Gets the url corresponding to an action, in the given format.
getCurrentUrl()  : string
returns the current Url.
getFull()  : string
Gets the absolute url corresponding to an action, in the given format with the domainName in defaultConfig or current.
getParam()  : string
get a parameter value.
getPath()  : string
get the path part of the url (scriptName + pathinfo).
getQuery()  : string
get the query part of the url.
getRootUrl()  : string
get the root url for a given ressource type. Root URLs are stored in config file.
getRootUrlRessourceValue()  : string
get the config value of an item in [rootUrls] section of config.
isUrlFromApp()  : bool
tells if the given url is for the current application or if it matches given authorized domains.
parse()  : jUrlAction
Parse a url.
setParam()  : mixed
add or change the value of a parameter.
toString()  : string
converts the url to a string.
unescape()  : string
perform the opposit of escape.

Constants

Properties

$pathInfo

path info part of the url.

public string $pathInfo = ''

$scriptName

script name including its path.

public string $scriptName

Methods

__construct()

constructor.

public __construct([string $scriptname = '' ][, array<string|int, mixed> $params = array() ][, string $pathInfo = '' ]) : mixed
Parameters
$scriptname : string = ''

script name

$params : array<string|int, mixed> = array()

parameters

$pathInfo : string = ''

path info contents

Return values
mixed

__toString()

magic method for echo and others.

public __toString() : mixed

..

Return values
mixed

appendToUrlString()

Adds parameters to the given url.

public static appendToUrlString(string $url[, array<string|int, mixed> $params = array() ][, bool $forxml = false ]) : string
Parameters
$url : string

an URL

$params : array<string|int, mixed> = array()

some parameters to append to the url

$forxml : bool = false

if true, escape some characters to include the url into an html/xml document

Return values
string

the url

clearParam()

Clear parameters.

public clearParam() : mixed
Return values
mixed

delParam()

delete a parameter.

public delParam(string $name) : mixed
Parameters
$name : string

parameter name

Return values
mixed

escape()

escape and simplier a string to be a part of an url path remove or replace not allowed characters etc.

public static escape(string $str[, bool $highlevel = false ]) : string

.

Parameters
$str : string

the string to escape

$highlevel : bool = false

false : just to a urlencode. true, replace some characters

Return values
string

escaped string

get()

Gets the url corresponding to an action, in the given format.

public static get(string $actSel[, array<string|int, mixed> $params = array() ], int $what) : mixed
Parameters
$actSel : string

action selector. You can use # instead of the module or the action name, to specify the current url.

$params : array<string|int, mixed> = array()

associative array with the parameters

$what : int

the format you want : one of the jUrl const, STRING XMLSTRING JURL JURLACTION

Return values
mixed

a value, depending of the $what parameter

getCurrentUrl()

returns the current Url.

public static getCurrentUrl([bool $forxml = false ][, mixed $full = false ]) : string

The URL is the URL for the frontend HTTP server, if your app is behind a proxy.

Parameters
$forxml : bool = false

if true, escape some characters to include the url into an html/xml document

$full : mixed = false
Return values
string

the url

getFull()

Gets the absolute url corresponding to an action, in the given format with the domainName in defaultConfig or current.

public static getFull(string $actSel[, array<string|int, mixed> $params = array() ], int $what[, string $domainName = null ]) : string
Parameters
$actSel : string

action selector. You can use # instead of the module or the action name, to specify the current url.

$params : array<string|int, mixed> = array()

associative array with the parameters

$what : int

the format you want : only jUrl::STRING or jUrl::XMLSTRING

$domainName : string = null

Customized domain name

Tags
throws
jException
Return values
string

the url string

getParam()

get a parameter value.

public getParam(string $name[, string $defaultValue = null ]) : string
Parameters
$name : string

parameter name

$defaultValue : string = null

the default value returned if the parameter doesn't exists

Return values
string

the value

getPath()

get the path part of the url (scriptName + pathinfo).

public getPath() : string
Tags
since
1.0.4
Return values
string

getQuery()

get the query part of the url.

public getQuery([bool $forxml = false ]) : string
Parameters
$forxml : bool = false

true: some characters will be escaped

Tags
since
1.0.4
Return values
string

getRootUrl()

get the root url for a given ressource type. Root URLs are stored in config file.

public static getRootUrl(string $ressourceType) : string
Parameters
$ressourceType : string

Name of the ressource

Return values
string

the root URL corresponding to this ressource, or basePath if unknown

getRootUrlRessourceValue()

get the config value of an item in [rootUrls] section of config.

public static getRootUrlRessourceValue(string $ressourceType) : string
Parameters
$ressourceType : string

Name of the ressource

Return values
string

the config value of this value, null if it does not exist

isUrlFromApp()

tells if the given url is for the current application or if it matches given authorized domains.

public static isUrlFromApp(string $url[, array<string|int, string> $authorizedDomains = array() ]) : bool
Parameters
$url : string
$authorizedDomains : array<string|int, string> = array()
Return values
bool

parse()

Parse a url.

public static parse(string $scriptNamePath, string $pathinfo, array<string|int, mixed> $params) : jUrlAction
Parameters
$scriptNamePath : string

/path/index.php

$pathinfo : string

the path info of the url

$params : array<string|int, mixed>

url parameter ($_REQUEST)

Return values
jUrlAction

setParam()

add or change the value of a parameter.

public setParam(string $name, string $value) : mixed
Parameters
$name : string

parameter name

$value : string

parameter value

Return values
mixed

toString()

converts the url to a string.

public toString([bool $forxml = false ]) : string
Parameters
$forxml : bool = false

true: some characters will be escaped

Return values
string

unescape()

perform the opposit of escape.

public static unescape(string $str) : string
Parameters
$str : string

the string to escape

Return values
string

Search results