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 $_fragment
 mixed $_host
 mixed $_password
 mixed $_path
 mixed $_port
 mixed $_request
 mixed $_scheme
 mixed $_target
 mixed $_username
 mixed $_x
 mixed $_y
Method Summary
 SimpleUrl SimpleUrl (string $url)
 void addRequestParameter (string $key, string $value)
 void addRequestParameters (hash $parameters)
 string asString ()
 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])
 boolean/string getTarget ()
 string getTld ()
 string getUsername ()
 integer getX ()
 integer getY ()
 void makeAbsolute (string/SimpleUrl $base)
 string normalisePath (string $path)
 void setCoordinates ([integer $x = false], [integer $y = false])
 void setTarget (string $frame)
 array _chompCoordinates (string &$url)
 string _chompHost (string &$url)
 array _chompLogin (string &$url)
 string _chompPath (string &$url)
 string _chompRequest (string &$url)
 string _chompScheme (string &$url)
 string/boolean _getIdentity ()
 boolean _isRelativePath (string $path)
Variables
mixed $_fragment (line 145)
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 $_target (line 148)
mixed $_username (line 139)
mixed $_x (line 146)
mixed $_y (line 147)
Methods
Constructor SimpleUrl (line 155)

Constructor. Parses URL into sections.

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

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

Adds additional parameters to the request.

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

Renders the URL back into a string.

  • return: URL in canonical form.
  • access: public
string asString ()
clearRequest (line 495)

Clears down all parameters.

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

Encodes parameters as HTTP request parameters.

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

Gets the path to the page.

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

Accessor for current request parameters

in URL string form

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

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

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

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

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

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

Accessor for password.

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

Accessor for path.

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

Accessor for port number.

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

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

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.
getTarget (line 522)

Gets the frame target if present. Although not strictly part of the URL specification it acts as similarily to the browser.

  • return: Frame name or false if none.
  • access: public
boolean/string getTarget ()
getTld (line 348)

Accessor for top level domain.

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

Accessor for user name.

  • return: Username preceding host.
  • access: public
string getUsername ()
getX (line 413)

Accessor for horizontal image coordinate.

  • return: X value.
  • access: public
integer getX ()
getY (line 422)

Accessor for vertical image coordinate.

  • return: Y value.
  • access: public
integer getY ()
makeAbsolute (line 565)

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

Replaces . and .. sections of the path.

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

Sets image coordinates. Set to flase to clear them.

  • access: public
void setCoordinates ([integer $x = false], [integer $y = false])
  • integer $x: Horizontal position.
  • integer $y: Vertical position.
setTarget (line 531)

Attaches a frame target.

  • access: public
void setTarget (string $frame)
  • string $frame: Name of frame.
_chompCoordinates (line 178)

Extracts the X, Y coordinate pair from an image map.

  • return: X, Y as a pair of integers.
  • access: private
array _chompCoordinates (string &$url)
  • string $url: URL so far. The coordinates will be removed.
_chompHost (line 239)

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

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

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

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

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.
_getIdentity (line 603)

Extracts the username and password for use in rendering a URL.

  • return: Form of username:password@ or false.
  • access: private
string/boolean _getIdentity ()
_isRelativePath (line 593)

Simple test to see if a path part is relative.

  • return: True if starts with a "/".
  • access: private
boolean _isRelativePath (string $path)
  • string $path: Path to test.
_parseRequest (line 293)

Breaks the request down into an object.

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

Documentation generated on Fri, 11 Feb 2005 18:14:28 +0000 by phpDocumentor 1.3.0RC3