Stud.IP  5.4
Request Class Reference
Inheritance diagram for Request:

Public Member Functions

 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getIterator ()
 

Static Public Member Functions

static getInstance ()
 
static url ()
 
static protocol ()
 
static server ()
 
static path ()
 
static scriptName ()
 
static pathInfo ()
 
static set ($param, $value)
 
static get ($param, $default=NULL)
 
static i18n ($param, $default=NULL, Callable $op=null)
 
static quoted ($param, $default=NULL)
 
static option ($param, $default=NULL)
 
static int ($param, $default=NULL)
 
static float ($param, $default=NULL)
 
static getDateTime ( $param='date', $format='Y-m-d', $second_param=null, $second_format=null, $default=null)
 
static getTime ( $param='time', $format='H:i', $date=null)
 
static username ($param, $default=NULL)
 
static getArray ($param)
 
static quotedArray ($param)
 
static optionArray ($param)
 
static intArray ($param)
 
static floatArray ($param)
 
static bool ($param, $default=null)
 
static boolArray ($param)
 
static usernameArray ($param)
 
static submitted ($param)
 
static submittedSome ($param)
 
static addslashes ($value)
 
static method ()
 
static isGet ()
 
static isPost ()
 
static isPut ()
 
static isDelete ()
 
static isXhr ()
 
static isAjax ()
 
static extract ($what)
 
static isDialog ()
 
static getObject ($param, $expected_class=null, $allow_null=true)
 
static getManyObjects ($param, $expected_class=null, $allow_null=true)
 

Detailed Description

Singleton class representing a HTTP request in Stud.IP.

Member Function Documentation

◆ addslashes()

static addslashes (   $value)
static

Quote a given string or array using addslashes(). If the parameter is an array, the quoting is applied recursively.

Parameters
mixed$valuestring or array value to be quoted
Returns
mixed quoted string or array

◆ bool()

static bool (   $param,
  $default = null 
)
static

Return the value of the selected query parameter as a boolean.

Parameters
string$paramparameter name
bool$defaultdefault value if parameter is not set
Returns
bool parameter value as bool (if set), else NULL
Since
Stud.IP 4.4

◆ boolArray()

static boolArray (   $param)
static

Return the value of the selected query parameter as a boolean array.

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array
Since
Stud.IP 4.4

◆ extract()

static extract (   $what)
static

extracts some params from request, the desired params must be a comma separated list for each param, the type of used extraction method can be specified after the name, default is get null values are not returned

e.g.: $data = Request::extract('admission_prelim int, admission_binding submitted, admission_prelim_txt'); will yield array(3) { ["admission_prelim"]=> int(1) ["admission_binding"]=> bool(false) ["admission_prelim_txt"]=> string(0) "" }

Parameters
string$whatcomma separated list of param names and types
Returns
array assoc array with extracted data

◆ float()

static float (   $param,
  $default = NULL 
)
static

Return the value of the selected query parameter as a float.

Parameters
string$paramparameter name
float$defaultdefault value if parameter is not set
Returns
float parameter value as float (if set), else NULL

◆ floatArray()

static floatArray (   $param)
static

Return the value of the selected query parameter as a float array.

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array

◆ get()

static get (   $param,
  $default = NULL 
)
static

Return the value of the selected query parameter as a string.

Parameters
string$paramparameter name
string$defaultdefault value if parameter is not set
Returns
string parameter value as string (if set), else NULL

◆ getArray()

static getArray (   $param)
static

Return the value of the selected query parameter as an array.

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array

◆ getDateTime()

static getDateTime (   $param = 'date',
  $format = 'Y-m-d',
  $second_param = null,
  $second_format = null,
  $default = null 
)
static

Returns the date and time values from one or two fields as a DateTime object. The $second_param and $second_format parameters are handy in case the date and time values come from different fields.

Parameters
string$paramThe name of the date/time field.
string$formatThe date format of the date/time field.
string$second_paramThe name of the second field, if used. This parameter is optional.
string$second_formatThe time format of the second field, if used. This parameter is optional.
DateTime | null$defaultEither a default DateTime object or null if no default shall be set. In the latter case a DateTime object representing the unix timestamp 0 is returned.
Returns
DateTime|bool A DateTime object containing the date and time values of the specified date and time field. In case something went wrong the boolean value false is returned.
See also
the following PHP documentation page for a list of accepted date and time formats: https://secure.php.net/manual/en/datetime.createfromformat.php

◆ getInstance()

static getInstance ( )
static

Return the Request singleton instance.

◆ getIterator()

getIterator ( )

IteratorAggregate: Create interator for request parameters.

◆ getManyObjects()

static getManyObjects (   $param,
  $expected_class = null,
  $allow_null = true 
)
static

Returns a collection of objects that have previously been serialized using the ObjectBuilder.

Parameters
String$paramparameter name
mixed$expected_classExpected class name of objects (optional)
bool$allow_nullIf true, return empty array on error; otherwise an exception is thrown
Returns
array as collection of objects
Exceptions
Exceptionwhen an error occurs and $allow_null = false
See also
ObjectBuilder

◆ getObject()

static getObject (   $param,
  $expected_class = null,
  $allow_null = true 
)
static

Returns an object that has previously been serialized using the ObjectBuilder.

Parameters
String$paramparameter name
mixed$expected_classExpected class name of object (optional)
bool$allow_nullIf true, return null on error; otherwise an exception is thrown
Returns
mixed Object of arbitrary type or null on error and $allow_null
Exceptions
Exceptionwhen an error occurs and $allow_null = false
See also
ObjectBuilder

◆ getTime()

static getTime (   $param = 'time',
  $format = 'H:i',
  $date = null 
)
static

Retrieves a parameter that stores time data and converts the time data to a DateTime object. If a date is specified using an existing DateTime object, the time will be set on the existing DateTime object and the modified object is returned.

Parameters
string$paramThe name of the time field.
string$formatThe time format of the time field.
DateTime | null$dateAn optional DateTime object whose time shall be set from the specified parameter.
Returns
DateTime|bool A DateTime object containing the time value of the specified date and time field. In case something went wrong the boolean value false is returned.

◆ i18n()

static i18n (   $param,
  $default = NULL,
Callable  $op = null 
)
static

Return the value of the selected query parameter as an I18NString.

Parameters
string$paramparameter name
string$defaultdefault value if parameter is not set
Callable$opOperation to perform on each text string
Returns
I18NString parameter value as string (if set), else NULL

◆ int()

static int (   $param,
  $default = NULL 
)
static

Return the value of the selected query parameter as an integer.

Parameters
string$paramparameter name
int$defaultdefault value if parameter is not set
Returns
int parameter value as integer (if set), else NULL

◆ intArray()

static intArray (   $param)
static

Return the value of the selected query parameter as an integer array.

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array

◆ isAjax()

static isAjax ( )
static

This is an alias of Request::isXhr

Returns
boolean true if this an XmlHttpRequest sent by jQuery/prototype

◆ isDelete()

static isDelete ( )
static
Returns
boolean true if this a DELETE request

◆ isDialog()

static isDialog ( )
static

returns true if http header indicates that the response will be rendered as dialog

Returns
bool

◆ isGet()

static isGet ( )
static
Returns
boolean true if this a GET request

◆ isPost()

static isPost ( )
static
Returns
boolean true if this a POST request

◆ isPut()

static isPut ( )
static
Returns
boolean true if this a PUT request

◆ isXhr()

static isXhr ( )
static
Returns
boolean true if this an XmlHttpRequest sent by jQuery/prototype

◆ method()

static method ( )
static

Returns the (uppercase) request method.

Returns
string the uppercased method of the request

◆ offsetExists()

offsetExists (   $offset)

ArrayAccess: Check whether the given offset exists.

◆ offsetGet()

offsetGet (   $offset)

ArrayAccess: Get the value at the given offset.

◆ offsetSet()

offsetSet (   $offset,
  $value 
)

ArrayAccess: Set the value at the given offset.

◆ offsetUnset()

offsetUnset (   $offset)

ArrayAccess: Delete the value at the given offset.

◆ option()

static option (   $param,
  $default = NULL 
)
static

Return the value of the selected query parameter as an alphanumeric string (consisting of only digits, letters and underscores).

Parameters
string$paramparameter name
string$defaultdefault value if parameter is not set
Returns
string parameter value as string (if set), else NULL

◆ optionArray()

static optionArray (   $param)
static

Return the value of the selected query parameter as an array of alphanumeric strings (consisting of only digits, letters and underscores).

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array

◆ path()

static path ( )
static

Return the current request path, relative to the server root.

◆ pathInfo()

static pathInfo ( )
static

Returns the complete path info including duplicated slashes. $_SERVER['PATH_INFO'] will remove them.

◆ protocol()

static protocol ( )
static

Return the current protocol ('http' or 'https').

◆ quoted()

static quoted (   $param,
  $default = NULL 
)
static

Return the value of the selected query parameter as a string. The contents of the string is quoted with addslashes().

Parameters
string$paramparameter name
string$defaultdefault value if parameter is not set
Returns
string parameter value as string (if set), else NULL

◆ quotedArray()

static quotedArray (   $param)
static

Return the value of the selected query parameter as a string array. The contents of each element is quoted with addslashes().

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array

◆ scriptName()

static scriptName ( )
static

Return the filename of the currently executing script.

Returns
string

◆ server()

static server ( )
static

Return the current server name and port (host:port).

◆ set()

static set (   $param,
  $value 
)
static

Set the selected query parameter to a specific value.

Parameters
string$paramparameter name
mixed$valueparameter value (string or array)

◆ submitted()

static submitted (   $param)
static

Check whether a form submit button has been pressed. This works for both image and text submit buttons.

Parameters
string$paramsubmit button name
Returns
boolean true if the button has been submitted, else false

◆ submittedSome()

static submittedSome (   $param)
static

Check whether one of the form submit buttons has been pressed. This works for both image and text submit buttons.

Parameters
string... a variable argument list of submit button names
Returns
boolean true if any button has been submitted, else false

◆ url()

static url ( )
static

Return the current URL, including query parameters.

◆ username()

static username (   $param,
  $default = NULL 
)
static

Return the value of the selected query parameter as a string consisting only of allowed characters for usernames.

Parameters
string$paramparameter name
string$defaultdefault value if parameter is not set
Returns
string parameter value (if set), else NULL

◆ usernameArray()

static usernameArray (   $param)
static

Return the value of the selected query parameter as an array of strings consisting only of allowed characters for usernames.

Parameters
string$paramparameter name
Returns
array parameter value as array (if set), else an empty array

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