[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Input/ -> Input.php (summary)

(no description)

File Size: 287 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Input:: (14 methods):
  __construct()
  applyfilter()
  filter()
  has()
  remove()
  param()
  set()
  ref()
  int()
  str()
  valid()
  bool()
  arr()
  extract()


Class: Input  - X-Ref

Encapsulates access to the $_REQUEST array, making sure used parameters are initialized and
have the correct type.

All function access the $_REQUEST array by default, if you want to access $_POST or $_GET
explicitly use the $post and $get members.

__construct()   X-Ref
Intilizes the dokuwiki\Input\Input class and it subcomponents


applyfilter($data)   X-Ref
Apply the set filter to the given value

param: string $data
return: string

filter($filter = 'stripctl')   X-Ref
Return a filtered copy of the input object

Expects a callable that accepts one string parameter and returns a filtered string

param: Callable|string $filter
return: Input

has($name)   X-Ref
Check if a parameter was set

Basically a wrapper around isset. When called on the $post and $get subclasses,
the parameter is set to $_POST or $_GET and to $_REQUEST

param: string $name Parameter name
return: bool
see: isset

remove($name)   X-Ref
Remove a parameter from the superglobals

Basically a wrapper around unset. When NOT called on the $post and $get subclasses,
the parameter will also be removed from $_POST or $_GET

param: string $name Parameter name
see: isset

param($name, $default = null, $nonempty = false)   X-Ref
Access a request parameter without any type conversion

param: string $name Parameter name
param: mixed $default Default to return if parameter isn't set
param: bool $nonempty Return $default if parameter is set but empty()
return: mixed

set($name, $value)   X-Ref
Sets a parameter

param: string $name Parameter name
param: mixed $value Value to set

ref($name, $default = '', $nonempty = false)   X-Ref
Get a reference to a request parameter

This avoids copying data in memory, when the parameter is not set it will be created
and intialized with the given $default value before a reference is returned

param: string $name Parameter name
param: mixed $default If parameter is not set, initialize with this value
param: bool $nonempty Init with $default if parameter is set but empty()
return: mixed (reference)

int($name, $default = 0, $nonempty = false)   X-Ref
Access a request parameter as int

param: string $name Parameter name
param: int $default Default to return if parameter isn't set or is an array
param: bool $nonempty Return $default if parameter is set but empty()
return: int

str($name, $default = '', $nonempty = false)   X-Ref
Access a request parameter as string

param: string $name Parameter name
param: string $default Default to return if parameter isn't set or is an array
param: bool $nonempty Return $default if parameter is set but empty()
return: string

valid($name, $valids, $default = null)   X-Ref
Access a request parameter and make sure it is has a valid value

Please note that comparisons to the valid values are not done typesafe (request vars
are always strings) however the function will return the correct type from the $valids
array when an match was found.

param: string $name Parameter name
param: array $valids Array of valid values
param: mixed $default Default to return if parameter isn't set or not valid
return: null|mixed

bool($name, $default = false, $nonempty = false)   X-Ref
Access a request parameter as bool

Note: $nonempty is here for interface consistency and makes not much sense for booleans

param: string $name Parameter name
param: mixed $default Default to return if parameter isn't set
param: bool $nonempty Return $default if parameter is set but empty()
return: bool

arr($name, $default = array()   X-Ref
Access a request parameter as array

param: string $name Parameter name
param: mixed $default Default to return if parameter isn't set
param: bool $nonempty Return $default if parameter is set but empty()
return: array

extract($name)   X-Ref
Create a simple key from an array key

This is useful to access keys where the information is given as an array key or as a single array value.
For example when the information was submitted as the name of a submit button.

This function directly changes the access array.

Eg. $_REQUEST['do']['save']='Speichern' becomes $_REQUEST['do'] = 'save'

This function returns the $INPUT object itself for easy chaining

param: string $name
return: Input