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 51)


	
			
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 124)

Anchor

mixed $aQueryData (line 115)
mixed $aRes = array() (line 118)
mixed $aStrategies = array() (line 117)
mixed $frontScriptName (line 116)
string $host (line 81)

Host

string $password (line 75)

Password

string $path (line 93)

Path

integer $port (line 87)

Port

string $protocol (line 63)

Protocol

array $querystring (line 114)

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 57)

Full url

bool $useBrackets (line 130)

Whether to use []

string $username (line 69)

Username

Methods
static toPartialArray (line 815)

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 161)

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 137)

PHP4 Constructor

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

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 676)

Returns hostname + path with final slashes removed if present.

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

Returns the front controller script name.

string getFrontScriptName ()
getHostName (line 635)
void getHostName ()
getManagerName (line 367)
void getManagerName ()
getModuleName (line 372)
void getModuleName ()
getPath (line 640)
void getPath ()
getQueryData (line 383)

Returns querystring data as an array.

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

Returns querystring portion of url.

string getQueryString ()
getStandardPort (line 564)

Returns the standard port number for a protocol.

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

Attempts to parse URI elements.

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

Build array of strategies and executes parsers.

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

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 463)

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 791)

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

void removeSessionInfo ( &$aUrl, array $aUrl)
  • array $aUrl
  • &$aUrl
removeStrategies (line 799)
void removeStrategies ()
resolveServerVars (line 596)

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

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

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 356)

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

SGL_Url &singleton ()
toAbsolute (line 662)

Ensures URL is fully qualified.

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

Returns the full URI as a string.

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

Documentation generated on Wed, 23 Jan 2008 17:04:48 +0000 by phpDocumentor 1.4.1