contenido\classes\class.request.php
\Request
- Author
- Andreas Kummer, w3concepts AG
- Copyright
- Copyright © 2008, w3concepts AG
- Version
- $Id: request.class.php 2289 2008-09-29 13:46:08Z atelierq $
Constants
Properties
Methods


cookie(String $sName, $bWithErrors = false) : Mixed
Returns the COOKIE value of the specified parameter.
Null if it does not exist or if it is not valid.
Name | Type | Description |
---|---|---|
$sName | String | sName Name of the parameter. |
$bWithErrors |
Type | Description |
---|---|
Mixed | Value of the parameter or null. |
- Access
- public
- Static


finish() : Object
Replaces all error objects with null.
Must be called after registering the required parameters.
Type | Description |
---|---|
Object | Reference to the current instance. |


get(String $sName, $bWithErrors = false) : Mixed
Returns the GET value of the specified parameter.
Null if it does not exist or if it is not valid.
Name | Type | Description |
---|---|---|
$sName | String | sName Name of the parameter. |
$bWithErrors |
Type | Description |
---|---|
Mixed | Value of the parameter or null. |
- Access
- public
- Static


getInstance() : Object
Factory.
Type | Description |
---|---|
Object | Reference to the current single instance of the class. |
- Access
- public
- Static


getVar(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.
Name | Type | Description |
---|---|---|
$sRequestType | String | sRequestType Request type (GET, POST or COOKIE). |
$sName | String | sName Name of the parameter. |
$bWithErrors |
Type | Description |
---|---|
Mixed | Value of the specified parameter. |
- Access
- private


hasError(\Reference $mItem, Mixed $mKey) : Void
Callback function to check whether a validation error occured or not.
Name | Type | Description |
---|---|---|
$mItem | \Reference | mItem Reference to the current item. |
$mKey | Mixed | mKey Current key. |
Type | Description |
---|---|
Void |
- Access
- private
- Static


hasValidationErrors(String $sRequestType, Array $aParams) : Boolean
Returns true, if one of the specified parameters has given a validation error.
Name | Type | Description |
---|---|---|
$sRequestType | String | sRequestType Request type. |
$aParams | Array | aParams Array of parameters to be checked. |
Type | Description |
---|---|
Boolean | True if no validation errors occured. False otherwise. |


isFloat(Mixed $mValue) : Boolean
Checks whether or not the given value is a double value.
Name | Type | Description |
---|---|---|
$mValue | Mixed | mValue Value to be checked. |
Type | Description |
---|---|
Boolean | True if the value is a float or integer value. |
- Access
- private
- Static


isInteger(Mixed $mValue) : Boolean
Checks whether or not the given value is a integer value.
Name | Type | Description |
---|---|---|
$mValue | Mixed | mValue Value to be checked. |
Type | Description |
---|---|
Boolean | True if the value is a integer value. |
- Access
- private
- Static


post(String $sName, $bWithErrors = false) : Mixed
Returns the POST value of the specified parameter.
Null if it does not exist or if it is not valid.
Name | Type | Description |
---|---|---|
$sName | String | sName Name of the parameter. |
$bWithErrors |
Type | Description |
---|---|
Mixed | Value of the parameter or null. |
- Access
- public
- Static


register(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.
Name | Type | Description |
---|---|---|
$sRequestType | String | sRequestType Either POST, GET or COOKIE. |
$sName | String | sName Parameter name. |
$iType | Integer | iType Parameter type (either integer, float or string). |
$iMin | Float | iMin Minimum length (string) or minimum value (float, integer). |
$iMax | Float | iMax Maximum length (string) or maximum value (float, integer). |
$sRegex | String | sRegex Regex pattern the value is checked against. |
$iTransformation |
Type | Description |
---|---|
Object | Reference to the current instance to enable method chaining. |
- Access
- public


request(String $sName, $bWithErrors = false) : Mixed
Returns the REQUEST value of the specified parameter.
Null if it does not exist or if it is not valid.
Name | Type | Description |
---|---|---|
$sName | String | sName Name of the parameter. |
$bWithErrors |
Type | Description |
---|---|
Mixed | Value of the parameter or null. |
- Access
- private
- Static


setErrorsToNull(\Reference $mItem, Mixed $mKey) : Void
Callback function to clear the resulting arrays from ValidationError objects.
Name | Type | Description |
---|---|---|
$mItem | \Reference | mItem Reference to the item of the array to be cleared. |
$mKey | Mixed | mKey Key of the current item to be processed. |
Type | Description |
---|---|
Void |
- Access
- private
- Static


setValidationError(Boolean $bValidationError) : Void
Sets the member bValidationError to the given value.
Name | Type | Description |
---|---|---|
$bValidationError | Boolean | bValidationError True, if a validation error occured. |
Type | Description |
---|---|
Void |


transform(String $sValue, Integer $iRules) : String
Transforms the value according to the given rules.
Name | Type | Description |
---|---|---|
$sValue | String | sValue Value to be transformed. |
$iRules | Integer | iRules Sum of the transformation rules to be applied. |
Type | Description |
---|---|
String | Transformed value. |
- Access
- private
- Static


validateArray(\Reference $mItem, Mixed $mKey, Array $aParams) : Void
Callback function for validating items of arrays.
Name | Type | Description |
---|---|---|
$mItem | \Reference | mItem Reference to the item of the array to be validated. |
$mKey | Mixed | mKey Key of the current item to be processed. |
$aParams | Array | aParams Parameter array to be used in the validation process. |
Type | Description |
---|---|
Void |
- Access
- private
- Static


validateValue(Mixed $mValue, Integer $iType, Integer $iMin, Integer $iMax, Integer $sRegex, $iTransformation) : Mixed
Validates the value against type, range, pattern, optionally after a transformation process.
Name | Type | Description |
---|---|---|
$mValue | Mixed | mValue Value to be validated. |
$iType | Integer | iType Type (integer, float or string). |
$iMin | Integer | iMin Minimum value (integer and float) or minimum length (string). |
$iMax | Integer | iMax Maximum value (integer and float) or maximum length (string). |
$sRegex | Integer | iTransformation Sum of transformations to be applied. |
$iTransformation |
Type | Description |
---|---|
Mixed | Either the transformed and validated value or null. |
- Access
- private
- Static
\ValidationError
Constants
Properties
Methods


__construct(Integer $iType, String $sMessage, Mixed $mTransValue) : void
Constructor.
Name | Type | Description |
---|---|---|
$iType | Integer | iType Error type (see constants). |
$sMessage | String | sMessage Error message. |
$mTransValue | Mixed | mTransValue Original and eventually transformed value. |
- Access
- private


getError() : Integer
Returns the error type.
Type | Description |
---|---|
Integer | Error type. |
- Access
- public


getMessage() : String
Returns the error message.
Type | Description |
---|---|
String | Error message. |
- Access
- public


getValue() : Mixed
Returns the eventually transformed value.
Type | Description |
---|---|
Mixed | Transformed value. |
- Access
- public


set(Integer $iType, Mixed $mTransValue, String $sMessage = '') : Object
Returns an object reference of the given type.
Name | Type | Description |
---|---|---|
$iType | Integer | iType Error type. |
$mTransValue | Mixed | mTransValue Original and eventually transformed value. |
$sMessage | String | sMessage Error message. |
Type | Description |
---|---|
Object | New validation error object. |
- Access
- public
- Static