Class SGL_URL

Description

Url related functionality.

  • author: Demian Turner <demian@phpkitchen.com>
  • version: $Revision: 1.32 $
  • see: seagull/lib/SGL/tests/UrlTest.ndb.php

Located in /SGL/Url.php (line 54)


			
Variable Summary
 string $anchor
 mixed $aQueryData
 mixed $aRes
 mixed $aStrategies
 string $host
 string $password
 string $path
 integer $port
 string $protocol
 array $querystring
 string $url
 string $username
Method Summary
 static array toPartialArray (string $url,  $frontScriptName)
 SGL_URL __construct ([string $url = null], [bool $useBrackets = true], [SGL_UrlParserStrategy $parserStrategy = null], array 3)
 SGL_URL SGL_URL ([ $url = null], [ $useBrackets = true], [ $parserStrategy = null], [ $conf = null])
 void addSessionInfo ( &$url, string $url)
 string getBase ()
 string getFrontScriptName ()
 void getHostName ()
 void getManagerName ()
 void getModuleName ()
 void getPath ()
 array getQueryData ([boolean $strict = false])
 string getQueryString ()
 integer getStandardPort (string $scheme)
 void getStrategiesFingerprint ( $aStrats)
 true init ()
 void makeLink ([ $action = ''], [ $mgr = ''], [ $mod = ''], [ $aList = array()], [ $params = ''], [ $idx = 0], [ $output = ''])
 array parseQueryString (array $conf)
 array parseResourceUri (string $str)
 array querystringArrayToHash (array $aUriParts, [array $aParsedUri = array()])
 void removeSessionInfo ( &$aUrl, array $aUrl)
 void setProtocol (string $protocol, [integer $port = null])
 SGL_Url &singleton ()
 void toAbsolute ( &$url, string $url)
 string toString ()
Variables
string $anchor (line 127)

Anchor

mixed $aQueryData (line 118)
mixed $aRes = array() (line 121)
mixed $aStrategies = array() (line 120)
mixed $frontScriptName (line 119)
string $host (line 84)

Host

string $password (line 78)

Password

string $path (line 96)

Path

integer $port (line 90)

Port

string $protocol (line 66)

Protocol

array $querystring (line 117)

Query string.

The querystring is defined as everthing from the frontScriptName to the end of the URI, not including anchors, examples:

  • http://example.com/index.php/foo/bar/baz/fluux
  • > qs = foo/bar/baz/fluux
  • http://example.com/foo/bar/baz/fluux?sess=a&rand=123
  • > qs = foo/bar/baz/fluux?sess=a&rand=123
  • http://example.com/?sess=a&rand=123
  • > qs = sess=a&rand=123
  • http://example.com/2006/02/07/my_interesting_blog.html
  • > qs - 2006/02/07/my_interesting_blog.html

string $url (line 60)

Full url

bool $useBrackets (line 133)

Whether to use []

string $username (line 72)

Username

Methods
static toPartialArray (line 818)

Returns an array of all elements from the front controller script name onwards, including the frontScriptName.

  • return: An array of all significant parts of the URL, ie from the front controller script name onwards
  • access: public
array toPartialArray (string $url,  $frontScriptName)
  • string $url: Url to be parsed
  • $frontScriptName
Constructor __construct (line 164)

PHP5 Constructor

Parses the given url and stores the various parts Defaults are used in certain cases

  • todo: the main URL attributes always get set twice, this needs to be optimised
SGL_URL __construct ([string $url = null], [bool $useBrackets = true], [SGL_UrlParserStrategy $parserStrategy = null], array 3)
  • string $url: Optional URL
  • bool $useBrackets: Whether to use square brackets when multiple querystrings with the same name exist
  • array 3: An array of config elements, optional
  • SGL_UrlParserStrategy $parserStrategy: The strategy object to be used, optional
Constructor SGL_URL (line 140)

PHP4 Constructor

SGL_URL SGL_URL ([ $url = null], [ $useBrackets = true], [ $parserStrategy = null], [ $conf = null])
  • $url
  • $useBrackets
  • $parserStrategy
  • $conf
addSessionInfo (line 774)

Checks to see if cookies are enabled, if not, session id is added to URL.

PHP's magic querystring functionality is negated in SimpleNav::getTabsByRid(), in other words, the ?PHPSESSID=aeff023230323 is stripped out

void addSessionInfo ( &$url, string $url)
  • string $url
  • &$url
getBase (line 679)

Returns hostname + path with final slashes removed if present.

  • return: The base url
  • todo: make logic more generic
string getBase ()
getFrontScriptName (line 653)

Returns the front controller script name.

string getFrontScriptName ()
getHostName (line 638)
void getHostName ()
getManagerName (line 370)
void getManagerName ()
getModuleName (line 375)
void getModuleName ()
getPath (line 643)
void getPath ()
getQueryData (line 386)

Returns querystring data as an array.

array getQueryData ([boolean $strict = false])
  • boolean $strict: If strict is true, managerName and moduleName are removed
getQueryString (line 424)

Returns querystring portion of url.

string getQueryString ()
getStandardPort (line 567)

Returns the standard port number for a protocol.

integer getStandardPort (string $scheme)
  • string $scheme: The protocol to lookup
getStrategiesFingerprint (line 507)
void getStrategiesFingerprint ( $aStrats)
  • $aStrats
init (line 197)

Attempts to parse URI elements.

  • return: on success, PEAR_Error on failure
true init ()
makeLink (line 550)
void makeLink ([ $action = ''], [ $mgr = ''], [ $mod = ''], [ $aList = array()], [ $params = ''], [ $idx = 0], [ $output = ''])
  • $action
  • $mgr
  • $mod
  • $aList
  • $params
  • $idx
  • $output
parseQueryString (line 435)

Build array of strategies and executes parsers.

array parseQueryString (array $conf)
  • array $conf
parseResourceUri (line 718)

Parse string stored in resource_uri field in section table.

This will always contain URL elements after the frontScriptName (index.php), never a FQDN, and never simplified names, ie section table must specify module name and manager name explicitly, even if they are the same, ie user/user

  • return: A hash containing URL info
  • todo: this method is VERY similar to parseQueryString and should be consolidated
array parseResourceUri (string $str)
  • string $str
querystringArrayToHash (line 466)

Parses an array of querystring param names and values and returns a key/value hash.

  • return: A hash of k/v pairs
array querystringArrayToHash (array $aUriParts, [array $aParsedUri = array()])
  • array $aUriParts: The list of candidate values.
  • array $aParsedUri: The list of existing valid value, to avoid overwriting
removeSessionInfo (line 794)

Removes the session name and session value elements from an array.

void removeSessionInfo ( &$aUrl, array $aUrl)
  • array $aUrl
  • &$aUrl
removeStrategies (line 802)
void removeStrategies ()
resolveServerVars (line 599)

Resolves PHP_SELF var depending on implementation, ie apache, iis, cgi, etc.

  • abstract:
void resolveServerVars ()
setProtocol (line 588)

Forces the URL to a particular protocol.

void setProtocol (string $protocol, [integer $port = null])
  • string $protocol: Protocol to force the URL to
  • integer $port: Optional port (standard port is used by default)
singleton (line 359)

SGL_Url singletons are currently only used for output URLs, so the output format is taken from $conf.

SGL_Url &singleton ()
toAbsolute (line 665)

Ensures URL is fully qualified.

  • access: public
void toAbsolute ( &$url, string $url)
  • string $url: The relative URL string
  • &$url
toString (line 523)

Returns the full URI as a string.

  • return: Full URI
  • access: public
string toString ()

Documentation generated on Tue, 23 Feb 2010 18:14:33 +0000 by phpDocumentor 1.4.3