XOOPS  2.6.0
Xoops\Core\HttpRequest Class Reference

Public Member Functions

 addDetector ($name, $options)
 
 clientAcceptsType ($mediaType)
 
 getAcceptedLanguages ()
 
 getAcceptMediaTypes ()
 
 getClientIp ($considerProxy=false)
 
 getDomain ()
 
 getEnv ($name, $default=null)
 
 getHeader ($name=null)
 
 getHost ()
 
 getReferer ()
 
 getScheme ()
 
 getScriptName ()
 
 getSubdomains ()
 
 getUrl ()
 
 is ($type)
 

Static Public Member Functions

static getFiles ($name)
 
static getInstance ()
 
static getUri ()
 

Protected Member Functions

 detectByEnv ($detect)
 
 detectByParam ($detect)
 

Protected Attributes

 $detectors
 
 $params
 

Private Member Functions

 __construct ()
 

Detailed Description

WARNING: THIS IS A PLACEHOLDER ONLY. IMPLEMENTATION AND DETAILS WILL CHANGE.

This provides some of the functionality that was in the Xoops_Request classes. The majority of use for the class was the 'asXyz()' methods, and all such uses should move to Xoops::getXyz() methods.

These are methods which reveal some aspects of the HTTP request environment. This will eventually be reworked to depend on a full HTTP messasge library (anticipating an official PSR-7 implementation.)

For now, this is a reduced version of a Cake derivative.

Author
trabis lusop.nosp@m.oema.nosp@m.s@gma.nosp@m.il.c.nosp@m.om
Kazumi Ono onoka.nosp@m.zu@g.nosp@m.mail..nosp@m.com

Definition at line 38 of file HttpRequest.php.

Constructor & Destructor Documentation

Xoops\Core\HttpRequest::__construct ( )
private

__construct

Definition at line 152 of file HttpRequest.php.

References Xoops\Core\HttpRequest\$params, and Xoops\Core\HttpRequest\getEnv().

Here is the call graph for this function:

Member Function Documentation

Xoops\Core\HttpRequest::addDetector (   $name,
  $options 
)

Add a new detector to the list of detectors that a request can use. There are several different formats and types of detectors that can be set.

Environment value comparison

An environment value comparison, compares a value fetched from env() to a known value the environment value is equality checked against the provided value. e.g `addDetector('post', array('env' => 'REQUEST_METHOD', 'value' => 'POST'))`

Pattern value comparison

Pattern value comparison allows you to compare a value fetched from env() to a regular expression. e.g `addDetector('iphone', array('env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i'));`

Option based comparison

Option based comparisons use a list of options to create a regular expression. Subsequent calls to add an already defined options detector will merge the options. e.g `addDetector('mobile', array('env' => 'HTTP_USER_AGENT', 'options' => array('Fennec')));`

Callback detectors

Callback detectors allow you to provide a 'callback' type to handle the check. The callback will receive the request object as its only parameter. e.g `addDetector('custom', array('callback' => array('SomeClass', 'somemethod')));`

Request parameter detectors

Allows for custom detectors on the request parameters. e.g `addDetector('post', array('param' => 'requested', 'value' => 1)`

Parameters
string$nameThe name of the detector.
array$optionsThe options for the detector definition. See above.
Returns
void

Definition at line 542 of file HttpRequest.php.

References $name, $options, and Xoops_Utils\arrayRecursiveMerge().

Here is the call graph for this function:

Xoops\Core\HttpRequest::clientAcceptsType (   $mediaType)

Determine if a client accepts a given media type

Parameters
string$mediaTypeThe content type to check for.
Returns
boolean true if client accepts the media type, otherwise false

Definition at line 558 of file HttpRequest.php.

References $type, and Xoops\Core\HttpRequest\getAcceptMediaTypes().

Here is the call graph for this function:

Xoops\Core\HttpRequest::detectByEnv (   $detect)
protected

detectByEnv - perform detection on detectors with an 'env' component

Parameters
array$detecta detectors array entry to test against
Returns
boolean true if detect is matched, false if not

Definition at line 484 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getEnv().

Referenced by Xoops\Core\HttpRequest\is().

Here is the call graph for this function:

Here is the caller graph for this function:

Xoops\Core\HttpRequest::detectByParam (   $detect)
protected

detectByParam - perform detection on detectors with an 'param' component. To match an entry with the name in the 'param' key of the $detect rule must exist in the $params property and be equal to the 'value' entry specified in the $detect array.

Parameters
array$detecta detectors array entry to test against. Param entries are of the form array('param' => name, 'value' => value)
Returns
boolean true if detect is matched, false if not

Definition at line 508 of file HttpRequest.php.

References $name.

Referenced by Xoops\Core\HttpRequest\is().

Here is the caller graph for this function:

Xoops\Core\HttpRequest::getAcceptedLanguages ( )

getAcceptedLanguages returns the http-accept-language header as an array of language codes arranged by specified preference

Returns
array associtive array of preference (numeric weight >0 <=1.0 ) keyed by language code, and sorted by preference

Definition at line 610 of file HttpRequest.php.

References $l, and Xoops\Core\HttpRequest\getHeader().

Here is the call graph for this function:

Xoops\Core\HttpRequest::getAcceptMediaTypes ( )

getAcceptMediaTypes returns the http-accept header as an array of media types arranged by specified preference

Returns
array associtive array of preference (numeric weight >0 <=1.0 ) keyed by media types, and sorted by preference

Definition at line 581 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getHeader().

Referenced by Xoops\Core\HttpRequest\clientAcceptsType().

Here is the call graph for this function:

Here is the caller graph for this function:

Xoops\Core\HttpRequest::getClientIp (   $considerProxy = false)

Get the Client IP address, optionally attempting to peek behind any proxies to get a real routable address.

Parameters
boolean$considerProxytrue to enable proxy tests
Returns
string

Definition at line 290 of file HttpRequest.php.

References $_SERVER, and $keys.

Xoops\Core\HttpRequest::getDomain ( )

Get the domain name and include $tldLength segments of the tld.

Returns
string Domain name without subdomains

Definition at line 263 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getHost(), and Xoops\getInstance().

Here is the call graph for this function:

Xoops\Core\HttpRequest::getEnv (   $name,
  $default = null 
)

Gets an environment variable from available sources, and provides emulation for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on IIS, or SCRIPT_NAME in CGI mode). Also exposes some additional custom environment information. Note : code modifications for XOOPS

Parameters
string$nameEnvironment variable name.
mixed$defaultdefault value
Returns
string|boolean Environment variable setting. todo 28.

Definition at line 354 of file HttpRequest.php.

References $_SERVER, $name, and Xoops\getInstance().

Referenced by Xoops\Core\HttpRequest\__construct(), Xoops\Core\HttpRequest\detectByEnv(), Xoops\Core\HttpRequest\getHeader(), Xoops\Core\HttpRequest\getHost(), Xoops\Core\HttpRequest\getReferer(), Xoops\Core\HttpRequest\getScheme(), Xoops\Core\HttpRequest\getScriptName(), and Xoops\Core\HttpRequest\getUrl().

Here is the call graph for this function:

Here is the caller graph for this function:

static Xoops\Core\HttpRequest::getFiles (   $name)
static
Parameters
string$namename of file
Returns
array

Definition at line 425 of file HttpRequest.php.

References $base, $code, and $name.

Xoops\Core\HttpRequest::getHeader (   $name = null)
Parameters
null | string$nameheader name
Returns
null|string

Definition at line 186 of file HttpRequest.php.

References $name, $res, and Xoops\Core\HttpRequest\getEnv().

Referenced by Xoops\Core\HttpRequest\getAcceptedLanguages(), and Xoops\Core\HttpRequest\getAcceptMediaTypes().

Here is the call graph for this function:

Here is the caller graph for this function:

Xoops\Core\HttpRequest::getHost ( )
Returns
string

Definition at line 219 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getEnv().

Referenced by Xoops\Core\HttpRequest\getDomain(), Xoops\Core\HttpRequest\getSubdomains(), and Xoops\Core\HttpRequest\getUrl().

Here is the call graph for this function:

Here is the caller graph for this function:

static Xoops\Core\HttpRequest::getInstance ( )
static
Returns
HttpRequest

Definition at line 171 of file HttpRequest.php.

Referenced by Xoops\Core\Session\Manager\__construct(), Xoops\Core\Session\Fingerprint\takePrint(), and Xoops\Core\Session\RememberMe\writeUserCookie().

Here is the caller graph for this function:

Xoops\Core\HttpRequest::getReferer ( )
Returns
string

Definition at line 243 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getEnv().

Here is the call graph for this function:

Xoops\Core\HttpRequest::getScheme ( )
Returns
string

Definition at line 211 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getEnv().

Referenced by Xoops\Core\HttpRequest\getUrl().

Here is the call graph for this function:

Here is the caller graph for this function:

Xoops\Core\HttpRequest::getScriptName ( )
Returns
string

Definition at line 251 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getEnv().

Here is the call graph for this function:

Xoops\Core\HttpRequest::getSubdomains ( )

Get the subdomains for a host.

Returns
string subdomain portion of host name

Definition at line 275 of file HttpRequest.php.

References Xoops\Core\HttpRequest\getHost(), and Xoops\getInstance().

Here is the call graph for this function:

static Xoops\Core\HttpRequest::getUri ( )
static
Returns
null|string

Definition at line 227 of file HttpRequest.php.

References $_SERVER.

Referenced by Xoops\Core\HttpRequest\getUrl().

Here is the caller graph for this function:

Xoops\Core\HttpRequest::getUrl ( )

Return current url

Returns
string

Definition at line 329 of file HttpRequest.php.

References $url, Xoops\Core\HttpRequest\getEnv(), Xoops\Core\HttpRequest\getHost(), Xoops\Core\HttpRequest\getScheme(), and Xoops\Core\HttpRequest\getUri().

Here is the call graph for this function:

Xoops\Core\HttpRequest::is (   $type)

Check whether or not a Request is a certain type. Uses the built in detection rules as well as additional rules defined with HttpRequest::addDetector(). Any detector can be called as is($type) or is$Type().

Parameters
string$typeThe type of request you want to check.
Returns
boolean Whether or not the request is the type you are checking.

Definition at line 460 of file HttpRequest.php.

References $type, Xoops\Core\HttpRequest\detectByEnv(), and Xoops\Core\HttpRequest\detectByParam().

Here is the call graph for this function:

Member Data Documentation

Xoops\Core\HttpRequest::$detectors
protected

Definition at line 53 of file HttpRequest.php.

Xoops\Core\HttpRequest::$params
protected

Definition at line 43 of file HttpRequest.php.

Referenced by Xoops\Core\HttpRequest\__construct().


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