Class SimpleUrl

Description

URL parser to replace parse_url() PHP function which got broken in PHP 4.3.0. Adds some browser specific functionality such as expandomatic expansion.

Guesses a bit trying to separate the host from the path.

Located in /libraries/pear/simpletest/url.php (line 137)


	
			
Variable Summary
 mixed $_host
 mixed $_password
 mixed $_path
 mixed $_port
 mixed $_request
 mixed $_scheme
 mixed $_username
Method Summary
 SimpleUrl SimpleUrl (string $url)
 void addRequestParameter (string $key, string $value)
 void addRequestParameters (hash $parameters)
 void clearRequest ()
 string encodeRequest (hash $parameters)
 string getBasePath ()
 string getEncodedRequest ()
 string getFragment ()
 string getHost ([string $default = false])
 Page getPage ()
 string getPassword ()
 string getPath ()
 integer getPort ()
 array getRequest ()
 string getScheme ([string $default = false])
 string getTld ()
 string getUsername ()
 void makeAbsolute (string/SimpleUrl $base)
 string normalisePath (string $path)
 string _chompHost (string &$url)
 array _chompLogin (string &$url)
 string _chompPath (string &$url)
 string _chompRequest (string &$url)
 string _chompScheme (string &$url)
Variables
mixed $_host (line 141)
mixed $_password (line 140)
mixed $_path (line 143)
mixed $_port (line 142)
mixed $_request (line 144)
mixed $_scheme (line 138)
mixed $_username (line 139)
Methods
Constructor SimpleUrl (line 151)

Constructor. Parses URL into sections.

  • access: public
SimpleUrl SimpleUrl (string $url)
  • string $url: Incoming URL.
addRequestParameter (line 437)

Adds an additional parameter to the request.

  • access: public
void addRequestParameter (string $key, string $value)
  • string $key: Name of parameter.
  • string $value: Value as string.
addRequestParameters (line 446)

Adds additional parameters to the request.

  • access: public
void addRequestParameters (hash $parameters)
  • hash $parameters: Hash of additional parameters.
clearRequest (line 456)

Clears down all parameters.

  • access: public
void clearRequest ()
encodeRequest (line 409)

Encodes parameters as HTTP request parameters.

  • return: Encoded request.
  • static:
  • access: public
string encodeRequest (hash $parameters)
  • hash $parameters: Request as hash.
getBasePath (line 371)

Gets the path to the page.

  • return: Path less the page.
  • access: public
string getBasePath ()
getEncodedRequest (line 393)

Accessor for current request parameters

in URL string form

  • return: Form is string "?a=1&b=2", etc.
  • access: public
string getEncodedRequest ()
getFragment (line 383)

Accessor for fragment at end of URL after the "#".

  • return: Part after "#".
  • access: public
string getFragment ()
getHost (line 318)

Accessor for hostname and port.

  • return: Hostname only.
  • access: public
string getHost ([string $default = false])
  • string $default: Value to use if not present.
getPage (line 359)

Accessor for page if any. This may be a directory name if ambiguious.

  • return: name.
  • access: public
Page getPage ()
getPassword (line 308)

Accessor for password.

  • return: Password preceding host.
  • access: public
string getPassword ()
getPath (line 346)

Accessor for path.

  • return: Full path including leading slash if implied.
  • access: public
string getPath ()
getPort (line 337)

Accessor for port number.

  • return: TCP/IP port number.
  • access: public
integer getPort ()
getRequest (line 427)

Accessor for current request parameters as an object.

  • return: Hash of name and value pairs. The values will be lists for repeated items.
  • access: public
array getRequest ()
getScheme (line 290)

Accessor for protocol part.

  • return: Scheme name, e.g "http".
  • access: public
string getScheme ([string $default = false])
  • string $default: Value to use if not present.
getTld (line 327)

Accessor for top level domain.

  • return: Last part of host.
  • access: public
string getTld ()
getUsername (line 299)

Accessor for user name.

  • return: Username preceding host.
  • access: public
string getUsername ()
makeAbsolute (line 467)

Replaces unknown sections to turn a relative URL into an absolute one. The base URL can be either a string or a SimpleUrl object.

  • access: public
void makeAbsolute (string/SimpleUrl $base)
  • string/SimpleUrl $base: Base URL.
normalisePath (line 493)

Replaces . and .. sections of the path.

  • return: Path with dots removed if possible.
  • access: public
string normalisePath (string $path)
  • string $path: Unoptimised path.
_chompHost (line 218)

Extracts the host part of an incoming URL.

Includes the port number part. Will extract the host if it starts with // or it has a top level domain or it has at least two dots.

  • return: Host part guess or false.
  • access: private
string _chompHost (string &$url)
  • string $url: URL so far. The host will be removed.
_chompLogin (line 190)

Extracts the username and password from the incoming URL. The // prefix will be reattached to the URL after the doublet is extracted.

  • return: Two item list of username and password. Will urldecode() them.
  • access: private
array _chompLogin (string &$url)
  • string $url: URL so far. The username and password are removed.
_chompPath (line 243)

Extracts the path information from the incoming URL. Strips this path from the URL.

  • return: Path part or '/'.
  • access: private
string _chompPath (string &$url)
  • string $url: URL so far. The host will be removed.
_chompRequest (line 258)

Strips off the request data.

  • return: Raw request part.
  • access: private
string _chompRequest (string &$url)
  • string $url: URL so far. The request will be removed.
_chompScheme (line 172)

Extracts the scheme part of an incoming URL.

  • return: Scheme part or false.
  • access: private
string _chompScheme (string &$url)
  • string $url: URL so far. The scheme will be removed.
_parseRequest (line 272)

Breaks the request down into an object.

  • return: Parsed data.
  • access: private
SimpleQueryString _parseRequest (string $raw)
  • string $raw: Raw request.

Documentation generated on Fri, 3 Dec 2004 12:28:00 +0000 by phpDocumentor 1.3.0RC3