Class Ismo_Core_Url

Description

This class makes handling URL:s easy.

Located in /Url.php (line 32)


	
			
Variable Summary
Method Summary
Ismo_Core_Url Ismo_Core_Url (string $url, [integer $internal = ISMO_CORE_QUERY_STYLE])
void addParameter (string $name, string $value, [boolean $preencoded = false])
void addPathParameter (string $name, string $value, [boolean $visible = true], [boolean $preencoded = false], [boolean $omitIfPossible = false])
void addPathParametersArray (array $params, [mixed $preencoded = false])
void addPathParametersAssoc (array $params, [mixed $preencoded = false])
void removeParameter (string $name)
void removePathParameter (string $name)
string toString ([boolean $escapeEntities = true])
void _addPathParameters (array $params, [mixed $visible = true], [mixed $preencoded = false])
string _getPathInfoString (boolean $escapeEntities)
string _getQueryString (boolean $escapeEntities)
Variables
mixed $_fragment (line 72)

The fragment.

  • access: private
array $_hiddenParameters (line 118)

The hidden path info parameters.

So that the created URL:s can be kept even more neat looking, it's possible to not have name-value attribute pairs as the path info parameters but instead not store the name part in the URL and refeer to the value part with the index of it. So this array just indicates if an attribute should be hidden, i.e. the name part shouldn't be shown or not.

  • access: private
mixed $_host (line 57)

The host name.

  • access: private
mixed $_pass (line 52)

The password to use.

  • access: private
mixed $_path (line 67)

The path.

  • access: private
array $_pathInfoParameters = array() (line 88)

The path info parameters.

This is used when one wants to get "cleaner" urls. Compare http://foo.bar/foo.php?id=5&sort=asc&start=50 with http://foo.bar/foo.php/id/5/sort/asc/start/50 and if you add logic to access the path info parameters by index it can be redused to: http://foo.bar/foo.php/5/asc/50 or something like that.

  • access: private
mixed $_port (line 62)

The port number to use.

  • access: private
array $_queryParameters (line 95)

The query parameters.

  • access: private
mixed $_schema (line 42)

The scheme; http, https etc.

  • access: private
integer $_sessionIndicator = false (line 103)

Indicator telling if the session parameter should be included in the generated URL or not.

  • access: private
boolean $_skipLastPathInfoParameter = false (line 130)

Indicates if the last path-info parameter should be omitted if possible.

This is used to avoid the default action name at the end of the URL:s if it's not needed.

  • access: private
mixed $_user (line 47)

The user name to use.

  • access: private
Methods
Constructor Ismo_Core_Url (line 264)

The constructor.

If it's an internal url the session identifier will automatically be added to the url if it's necessary (i.e. if cookies are disabled in the user's browser). If it's not an internal url no session identifier will be added. An internal url is identified by the value of the $internal parameter. If it's ISMO_CORE_QUERY_STYLE or ISMO_CORE_PATHINFO_STYLE it's considered an internal url. ISMO_CORE_QUERY_STYLE is the default value for that parameter.

Because this method can't know what is the script and what is additional path info data. The whole path is considered to be part of the path to the script. So additional path info parameters have to be added with the addPathParameter() method.

  • access: public
Ismo_Core_Url Ismo_Core_Url (string $url, [integer $internal = ISMO_CORE_QUERY_STYLE])
  • string $url: the url
  • integer $internal: whether this is an internal url or not. valid values are false if it's not an internal url and ISMO_CORE_QUERY_STYLE or ISMO_CORE_PATHINFO_STYLE if it's an internal url
addParameter (line 317)

Adds a query parameter to the url.

If a parameter with the same name has already been added it will be updated instead of added again.

Example:

  1. $url = new Ismo_Core_Url('http://foo/bar.php');
  2. $url->addParameter('sort', 'asc');
This results in a url like this, http://foo/bar.php?sort=asc

void addParameter (string $name, string $value, [boolean $preencoded = false])
  • string $name: the name
  • string $value: the value
  • boolean $preencoded: whether the value is urlencoded or not, default is not
addPathParameter (line 357)

Adds a path parameter to the url.

If a parameter with the same name has already been added it will be updated instead of added again.

Examples:

  1. $url = new Ismo_Core_Url('http://foo/bar.php');
  2. $url->addPathParameter('sort', 'asc');
This results in a url like this, http://foo/bar.php/sort/asc

  1. $url = new Ismo_Core_Url('http://foo/bar.php');
  2. $url->addPathParameter('sort', 'asc', false);
This results in a url like this, http://foo.bar.php/asc. I.e. the name of the parameter is hidden and to get the value of this parameter one has to use the getPathParameterByIndex() method.

void addPathParameter (string $name, string $value, [boolean $visible = true], [boolean $preencoded = false], [boolean $omitIfPossible = false])
  • string $name: the name
  • string $value: the value
  • boolean $visible: whether the name of the attribute should be shown in the url or not
  • boolean $preencoded: whether the value is urlencoded or not, default is not
  • boolean $omitIfPossible: whether this parameter should be left out if this is the last path parameter
addPathParametersArray (line 380)

Adds path parameters to the url, using an indexed array.

Note that you have to url encode params yourself, if needed.

void addPathParametersArray (array $params, [mixed $preencoded = false])
  • array $params: the params to add
addPathParametersAssoc (line 394)

Adds path parameters to the url, using an assoc. array.

Note that you have to url encode params yourself, if needed.

void addPathParametersAssoc (array $params, [mixed $preencoded = false])
  • array $params: the params to add
removeParameter (line 425)

Removes a parameter from the url.

void removeParameter (string $name)
  • string $name: the name
removePathParameter (line 443)

Removes a path info parameter from the url.

void removePathParameter (string $name)
  • string $name: the name
toString (line 465)

Returns the URL in a string format suitable to put in HTML.

The URL is always returned in a absolute format.

  • return: the url
  • access: public
string toString ([boolean $escapeEntities = true])
  • boolean $escapeEntities: whether characters that have equivalent HTML entities should be replaced with those entities or not. Defaults to true.
_addPathParameters (line 408)

Adds path parameters to the url.

Note that you have to url encode params yourself, if needed.

void _addPathParameters (array $params, [mixed $visible = true], [mixed $preencoded = false])
  • array $params: the params to add
_getPathInfoString (line 186)

Returns the path info parameters as a string.

  • return: the path parameters combined into a string
  • access: private
string _getPathInfoString (boolean $escapeEntities)
  • boolean $escapeEntities
_getQueryString (line 139)

Returns the query parameters as a string.

  • return: the query parameters combined into a string
  • access: private
string _getQueryString (boolean $escapeEntities)
  • boolean $escapeEntities

Documentation generated on Mon, 14 Jun 2004 11:59:39 +0200 by phpDocumentor 1.3.0RC3