Elgg  Version 1.10
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Http\Request Class Reference

Public Member Functions

 __construct (array $query=array(), array $request=array(), array $cookies=array(), array $files=array(), array $server=array())
 Create a request. More...
 
 get ($key, $default=null)
 Get a parameter from this request. More...
 
 getRequestUri ()
 Returns the requested URI. More...
 
 getUri ()
 Generates a normalized URI for the Request. More...
 
 getSchemeAndHttpHost ()
 Gets the scheme and HTTP host. More...
 
 getScheme ()
 Gets the request's scheme. More...
 
 getHttpHost ()
 Returns the HTTP host being requested. More...
 
 getHost ()
 Returns the host name. More...
 
 isSecure ()
 Is this request using SSL. More...
 
 getPort ()
 Returns the port on which the request is made. More...
 
 getBaseUrl ()
 Returns the root url from which this request is executed. More...
 
 getPathInfo ()
 Returns the path being requested relative to the executed script. More...
 
 getQueryString ()
 Gets the normalized query string for the Request. More...
 
 getUrlSegments ()
 Get URL segments from the path info. More...
 
 getFirstUrlSegment ()
 Get first URL segment from the path info. More...
 
 getClientIp ()
 Get the IP address of the client. More...
 
 isXmlHttpRequest ()
 Is this an ajax request. More...
 

Static Public Member Functions

static createFromGlobals ()
 Creates a request from PHP's globals. More...
 
static create ($uri, $method= 'GET', $parameters=array(), $cookies=array(), $files=array(), $server=array())
 Creates a Request based on a given URI and configuration. More...
 
static normalizeQueryString ($qs)
 Normalizes a query string. More...
 

Public Attributes

 $query
 
 $request
 
 $cookies
 
 $files
 
 $server
 
 $headers
 

Protected Member Functions

 initialize (array $query=array(), array $request=array(), array $cookies=array(), array $files=array(), array $server=array())
 Initialize the request. More...
 
 stripSlashesIfMagicQuotes ($data)
 Strip slashes if magic quotes is on. More...
 
 prepareHeaders ()
 Get the HTTP headers from server. More...
 
 prepareRequestUri ()
 Set the request URI. More...
 
 prepareBaseUrl ()
 Prepares the base URL. More...
 
 preparePathInfo ()
 Prepares the path info. More...
 

Protected Attributes

 $baseUrl = null
 
 $requestUri = null
 
 $pathInfo = null
 

Detailed Description

Definition at line 38 of file Request.php.

Constructor & Destructor Documentation

Elgg\Http\Request::__construct ( array  $query = array(),
array  $request = array(),
array  $cookies = array(),
array  $files = array(),
array  $server = array() 
)

Create a request.

Parameters
array$queryGET parameters
array$requestPOST parameters
array$cookiesCOOKIE parameters
array$filesFILES parameters
array$serverSERVER parameters

Definition at line 98 of file Request.php.

Member Function Documentation

static Elgg\Http\Request::create (   $uri,
  $method = 'GET',
  $parameters = array(),
  $cookies = array(),
  $files = array(),
  $server = array() 
)
static

Creates a Request based on a given URI and configuration.

The information contained in the URI always take precedence over the other information (server and parameters).

Parameters
string$uriThe URI
string$methodThe HTTP method
array$parametersThe query (GET) or request (POST) parameters
array$cookiesThe request cookies ($_COOKIE)
array$filesThe request files ($_FILES)
array$serverThe server parameters ($_SERVER)
Returns

Definition at line 151 of file Request.php.

static Elgg\Http\Request::createFromGlobals ( )
static

Creates a request from PHP's globals.

Returns

Definition at line 132 of file Request.php.

Elgg\Http\Request::get (   $key,
  $default = null 
)

Get a parameter from this request.

It is better to get parameters from the appropriate public property (query, request).

Parameters
string$keyThe key
mixed$defaultThe default value
Returns
mixed

Definition at line 280 of file Request.php.

Elgg\Http\Request::getBaseUrl ( )

Returns the root url from which this request is executed.

The base URL never ends with a /. If the URL directly calls the executed script (e.g. index.php), this is included.

Suppose Elgg is installed at http://localhost/mysite/ :

Returns
string The raw url (i.e. not urldecoded)

Definition at line 413 of file Request.php.

Elgg\Http\Request::getClientIp ( )

Get the IP address of the client.

Returns
string

Definition at line 495 of file Request.php.

Elgg\Http\Request::getFirstUrlSegment ( )

Get first URL segment from the path info.

See also
::getUrlSegments()
Returns
string

Definition at line 481 of file Request.php.

Elgg\Http\Request::getHost ( )

Returns the host name.

Returns
string
Exceptions

Definition at line 361 of file Request.php.

Elgg\Http\Request::getHttpHost ( )

Returns the HTTP host being requested.

The port name will be appended to the host if it's non-standard.

Returns
string

Definition at line 343 of file Request.php.

Elgg\Http\Request::getPathInfo ( )

Returns the path being requested relative to the executed script.

The path info always starts with a /, does not contain the query string, and does not include the path to the Elgg installation.

Suppose Elgg is installed at http://localhost/mysite/ :

Returns
string The raw path (i.e. not urldecoded)

Definition at line 436 of file Request.php.

Elgg\Http\Request::getPort ( )

Returns the port on which the request is made.

Returns
string

Definition at line 396 of file Request.php.

Elgg\Http\Request::getQueryString ( )

Gets the normalized query string for the Request.

It builds a normalized query string, where keys/value pairs are alphabetized and have consistent escaping.

Returns
string|null A normalized query string for the Request

Definition at line 452 of file Request.php.

Elgg\Http\Request::getRequestUri ( )

Returns the requested URI.

Returns
string The raw URI (i.e. not urldecoded)

Definition at line 295 of file Request.php.

Elgg\Http\Request::getScheme ( )

Gets the request's scheme.

Returns
string

Definition at line 332 of file Request.php.

Elgg\Http\Request::getSchemeAndHttpHost ( )

Gets the scheme and HTTP host.

Includes port if non-standard.

Returns
string The scheme and HTTP host

Definition at line 323 of file Request.php.

Elgg\Http\Request::getUri ( )

Generates a normalized URI for the Request.

Returns
string

Definition at line 308 of file Request.php.

Elgg\Http\Request::getUrlSegments ( )

Get URL segments from the path info.

See also
::getPathInfo()
Returns
array

Definition at line 465 of file Request.php.

Elgg\Http\Request::initialize ( array  $query = array(),
array  $request = array(),
array  $cookies = array(),
array  $files = array(),
array  $server = array() 
)
protected

Initialize the request.

Parameters
array$queryGET parameters
array$requestPOST parameters
array$cookiesCOOKIE parameters
array$filesFILES parameters
array$serverSERVER parameters
Returns
void

Definition at line 113 of file Request.php.

Elgg\Http\Request::isSecure ( )

Is this request using SSL.

Returns
bool

Definition at line 387 of file Request.php.

Elgg\Http\Request::isXmlHttpRequest ( )

Is this an ajax request.

Returns
bool

Definition at line 516 of file Request.php.

static Elgg\Http\Request::normalizeQueryString (   $qs)
static

Normalizes a query string.

It builds a normalized query string, where keys/value pairs are alphabetized, have consistent escaping and unneeded delimiters are removed.

Parameters
string$qsQuery string
Returns
string A normalized query string for the Request

Definition at line 235 of file Request.php.

Elgg\Http\Request::prepareBaseUrl ( )
protected

Prepares the base URL.

Returns
string

Definition at line 575 of file Request.php.

Elgg\Http\Request::prepareHeaders ( )
protected

Get the HTTP headers from server.

Returns
array

Definition at line 540 of file Request.php.

Elgg\Http\Request::preparePathInfo ( )
protected

Prepares the path info.

Returns
string path info

Definition at line 640 of file Request.php.

Elgg\Http\Request::prepareRequestUri ( )
protected

Set the request URI.

The Symfony Request object handles proxies and IIS rewrites. We are not yet.

Returns
string

Definition at line 566 of file Request.php.

Elgg\Http\Request::stripSlashesIfMagicQuotes (   $data)
protected

Strip slashes if magic quotes is on.

Parameters
mixed$dataData to strip slashes from
Returns
mixed

Definition at line 527 of file Request.php.

Member Data Documentation

Elgg\Http\Request::$baseUrl = null
protected

Definition at line 77 of file Request.php.

Elgg\Http\Request::$cookies

Definition at line 54 of file Request.php.

Elgg\Http\Request::$files

Definition at line 60 of file Request.php.

Elgg\Http\Request::$headers

Definition at line 72 of file Request.php.

Elgg\Http\Request::$pathInfo = null
protected

Definition at line 87 of file Request.php.

Elgg\Http\Request::$query

Definition at line 42 of file Request.php.

Elgg\Http\Request::$request

Definition at line 48 of file Request.php.

Elgg\Http\Request::$requestUri = null
protected

Definition at line 82 of file Request.php.

Elgg\Http\Request::$server

Definition at line 66 of file Request.php.


The documentation for this class was generated from the following file: