contenido\classes\class.request.php

Show: PublicProtectedPrivateinherited
Table of Contents

\Request

Package: Default
Request class
Author
Andreas Kummer, w3concepts AG  
Copyright
Copyright © 2008, w3concepts AG  
Version
$Id: request.class.php 2289 2008-09-29 13:46:08Z atelierq $  

Constants

>VConstant  POST = 'POST'
>VConstant  GET = 'GET'
>VConstant  COOKIE = 'COOKIE'
>VConstant  TYPE_INTEGER = 1
>VConstant  TYPE_FLOAT = 2
>VConstant  TYPE_STRING = 4
>VConstant  TYPE_ARRAY = 8
>VConstant  TRANS_STRIP_HTML = 1
>VConstant  TRANS_STRIP_PHP = 2
>VConstant  DATE_PATTERN_ISO = '/^\\d{4}\\-\\d{2}\\-\\d{2}$/'
>VConstant  DATE_PATTERN_DE = '/^\\d{2}\\.\\d{2}\\.(?:\\d{2}|\\d{4})$/'
>VConstant  DATETIME_PATTERN = '/^\\d{4}\\-\\d{2}\\-\\d{2}\\s\\d{2}\\:\\d{2}$/'
>VConstant  DATETIME_PATTERN_DE = '/^\\d{2}\\.\\d{2}\\.(?:\\d{2}|\\d{4})\\s\\d{2}.\\d{2}$/'
>VConstant  HEXDEC_HASH = '/^[\\da-f]*$/'

Properties

>VPropertyprivate$COOKIE
Details
Type
n/a
>VPropertyprivate$COOKIEcleared
Details
Type
n/a
>VPropertyprivate$GET
Details
Type
n/a
>VPropertyprivate$GETcleared
Details
Type
n/a
>VPropertyprivate$POST
Details
Type
n/a
>VPropertyprivate$POSTcleared
Details
Type
n/a
>VPropertyprivate$bHasValidationErrors
Details
Type
n/a

Methods

methodprivate__construct() : void

Constructor.

Details
Access
private  
methodpubliccookie(String $sName,  $bWithErrors = false) : Mixed
static

Returns the COOKIE value of the specified parameter.

Null if it does not exist or if it is not valid.

Parameters
NameTypeDescription
$sNameString

sName Name of the parameter.

$bWithErrors
Returns
TypeDescription
MixedValue of the parameter or null.
Details
Access
public  
Static
 
methodpublicfinish() : Object

Replaces all error objects with null.

Must be called after registering the required parameters.

Returns
TypeDescription
ObjectReference to the current instance.
methodpublicget(String $sName,  $bWithErrors = false) : Mixed
static

Returns the GET value of the specified parameter.

Null if it does not exist or if it is not valid.

Parameters
NameTypeDescription
$sNameString

sName Name of the parameter.

$bWithErrors
Returns
TypeDescription
MixedValue of the parameter or null.
Details
Access
public  
Static
 
methodpublicgetInstance() : Object
static

Factory.

Returns
TypeDescription
ObjectReference to the current single instance of the class.
Details
Access
public  
Static
 
methodprivategetVar(String $sRequestType, String $sName,  $bWithErrors = false) : Mixed

Returns the parameter specified by sName and the request type sRequestType.

The method throws an exception if the specified paramter has not yet been registered.

Parameters
NameTypeDescription
$sRequestTypeString

sRequestType Request type (GET, POST or COOKIE).

$sNameString

sName Name of the parameter.

$bWithErrors
Returns
TypeDescription
MixedValue of the specified parameter.
Details
Access
private  
methodprivatehasError(\Reference $mItem, Mixed $mKey) : Void
static

Callback function to check whether a validation error occured or not.

Parameters
NameTypeDescription
$mItem\Reference

mItem Reference to the current item.

$mKeyMixed

mKey Current key.

Returns
TypeDescription
Void
Details
Access
private  
Static
 
methodpublichasValidationErrors(String $sRequestType, Array $aParams) : Boolean
static

Returns true, if one of the specified parameters has given a validation error.

Parameters
NameTypeDescription
$sRequestTypeString

sRequestType Request type.

$aParamsArray

aParams Array of parameters to be checked.

Returns
TypeDescription
BooleanTrue if no validation errors occured. False otherwise.
methodprivateisFloat(Mixed $mValue) : Boolean
static

Checks whether or not the given value is a double value.

Parameters
NameTypeDescription
$mValueMixed

mValue Value to be checked.

Returns
TypeDescription
BooleanTrue if the value is a float or integer value.
Details
Access
private  
Static
 
methodprivateisInteger(Mixed $mValue) : Boolean
static

Checks whether or not the given value is a integer value.

Parameters
NameTypeDescription
$mValueMixed

mValue Value to be checked.

Returns
TypeDescription
BooleanTrue if the value is a integer value.
Details
Access
private  
Static
 
methodprivateisRegistered( $sName,  $sRequestType) : void

Parameters
NameTypeDescription
$sName
$sRequestType
methodpublicpost(String $sName,  $bWithErrors = false) : Mixed
static

Returns the POST value of the specified parameter.

Null if it does not exist or if it is not valid.

Parameters
NameTypeDescription
$sNameString

sName Name of the parameter.

$bWithErrors
Returns
TypeDescription
MixedValue of the parameter or null.
Details
Access
public  
Static
 
methodpublicregister(String $sRequestType, String $sName, Integer $iType, Float $iMin = null, Float $iMax = null, String $sRegex = null,  $iTransformation = null) : Object

Registers a request variable with the request class.

Parameters
NameTypeDescription
$sRequestTypeString

sRequestType Either POST, GET or COOKIE.

$sNameString

sName Parameter name.

$iTypeInteger

iType Parameter type (either integer, float or string).

$iMinFloat

iMin Minimum length (string) or minimum value (float, integer).

$iMaxFloat

iMax Maximum length (string) or maximum value (float, integer).

$sRegexString

sRegex Regex pattern the value is checked against.

$iTransformation
Returns
TypeDescription
ObjectReference to the current instance to enable method chaining.
Details
Access
public  
methodpublicrequest(String $sName,  $bWithErrors = false) : Mixed
static

Returns the REQUEST value of the specified parameter.

Null if it does not exist or if it is not valid.

Parameters
NameTypeDescription
$sNameString

sName Name of the parameter.

$bWithErrors
Returns
TypeDescription
MixedValue of the parameter or null.
Details
Access
private  
Static
 
methodprivatesetErrorsToNull(\Reference $mItem, Mixed $mKey) : Void
static

Callback function to clear the resulting arrays from ValidationError objects.

Parameters
NameTypeDescription
$mItem\Reference

mItem Reference to the item of the array to be cleared.

$mKeyMixed

mKey Key of the current item to be processed.

Returns
TypeDescription
Void
Details
Access
private  
Static
 
methodprivatesetValidationError(Boolean $bValidationError) : Void

Sets the member bValidationError to the given value.

Parameters
NameTypeDescription
$bValidationErrorBoolean

bValidationError True, if a validation error occured.

Returns
TypeDescription
Void
methodprivatetransform(String $sValue, Integer $iRules) : String
static

Transforms the value according to the given rules.

Parameters
NameTypeDescription
$sValueString

sValue Value to be transformed.

$iRulesInteger

iRules Sum of the transformation rules to be applied.

Returns
TypeDescription
StringTransformed value.
Details
Access
private  
Static
 
methodprivatevalidateArray(\Reference $mItem, Mixed $mKey, Array $aParams) : Void
static

Callback function for validating items of arrays.

Parameters
NameTypeDescription
$mItem\Reference

mItem Reference to the item of the array to be validated.

$mKeyMixed

mKey Key of the current item to be processed.

$aParamsArray

aParams Parameter array to be used in the validation process.

Returns
TypeDescription
Void
Details
Access
private  
Static
 
methodprivatevalidateValue(Mixed $mValue, Integer $iType, Integer $iMin, Integer $iMax, Integer $sRegex,  $iTransformation) : Mixed
static

Validates the value against type, range, pattern, optionally after a transformation process.

Parameters
NameTypeDescription
$mValueMixed

mValue Value to be validated.

$iTypeInteger

iType Type (integer, float or string).

$iMinInteger

iMin Minimum value (integer and float) or minimum length (string).

$iMaxInteger

iMax Maximum value (integer and float) or maximum length (string).

$sRegexInteger

iTransformation Sum of transformations to be applied.

$iTransformation
Returns
TypeDescription
MixedEither the transformed and validated value or null.
Details
Access
private  
Static
 

\ValidationError

Package: Default

Constants

>VConstant  NOT_INTEGER = 1
>VConstant  NOT_FLOAT = 2
>VConstant  NOT_SCALAR = 3
>VConstant  TOO_LONG = 4
>VConstant  TOO_SHORT = 5
>VConstant  TOO_BIG = 6
>VConstant  TOO_SMALL = 7
>VConstant  WRONG_PATTERN = 8

Properties

>VPropertyprivate$iType
Details
Type
n/a
>VPropertyprivate$mTransValue
Details
Type
n/a
>VPropertyprivate$sMessage
Details
Type
n/a

Methods

methodprivate__construct(Integer $iType, String $sMessage, Mixed $mTransValue) : void

Constructor.

Parameters
NameTypeDescription
$iTypeInteger

iType Error type (see constants).

$sMessageString

sMessage Error message.

$mTransValueMixed

mTransValue Original and eventually transformed value.

Details
Access
private  
methodpublicgetError() : Integer

Returns the error type.

Returns
TypeDescription
IntegerError type.
Details
Access
public  
methodpublicgetMessage() : String

Returns the error message.

Returns
TypeDescription
StringError message.
Details
Access
public  
methodpublicgetValue() : Mixed

Returns the eventually transformed value.

Returns
TypeDescription
MixedTransformed value.
Details
Access
public  
methodpublicset(Integer $iType, Mixed $mTransValue, String $sMessage = '') : Object
static

Returns an object reference of the given type.

Parameters
NameTypeDescription
$iTypeInteger

iType Error type.

$mTransValueMixed

mTransValue Original and eventually transformed value.

$sMessageString

sMessage Error message.

Returns
TypeDescription
ObjectNew validation error object.
Details
Access
public  
Static
 
Documentation was generated by phpDocumentor 2.0.0a12.