[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

(no description)

File Size: 286 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

return: string
param: string $data

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

return: Input
param: Callable|string $filter

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

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

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

see: isset
param: string $name Parameter name

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

return: mixed
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()

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

return: mixed (reference)
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()

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

return: 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()

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

return: 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()

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.

return: null|mixed
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

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

return: bool
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()

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

return: 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()

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

return: Input
param: string $name