Documentation

Variables
in package
implements ArrayAccess, Countable, IteratorAggregate

An OO-way to access form variables.

Tags
todo

$_expected and $_vars are used inconsistently. $_expected is used in exists(), but not in getExists(). And both are expected to be of the same format, while Horde_Form submits $_expected as a flat list and $_vars as a multi-dimensional array, if the the form elements are or array type (like object[] in Turba).

todo

The sanitized feature doesn't seem to be used anywhere at all.

author

Robert E. Coyle robertecoyle@hotmail.com

author

Chuck Hagenbuch chuck@horde.org

author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2009-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Interfaces, Classes, Traits and Enums

ArrayAccess
Countable
IteratorAggregate

Table of Contents

$expected  : array<string|int, mixed>
The list of expected variables.
$sanitized  : bool
Has the input been sanitized?
$vars  : array<string|int, mixed>
Array of form variables.
__construct()  : mixed
Constructor.
__get()  : mixed
Returns the value of a given form variable.
__isset()  : bool
isset() implementation.
__set()  : mixed
Sets the value of a given form variable.
__unset()  : mixed
Deletes a given form variable.
add()  : bool
Set $varname to $value ONLY if it's not already present.
count()  : mixed
exists()  : mixed
Alias of isset().
filter()  : string|array<string|int, mixed>
Filters a form value so that it can be used in HTML output.
get()  : mixed
Returns the value of a given form variable.
getDefaultVariables()  : Variables
Returns a Horde_Variables object populated with the form input.
getExists()  : mixed
Given a variable name, returns the value and sets a variable indicating whether the value exists in the form data.
getIterator()  : mixed
merge()  : mixed
Merges a list of variables into the current form variable list.
offsetExists()  : mixed
Implements isset() for ArrayAccess interface.
offsetGet()  : mixed
Implements getter for ArrayAccess interface.
offsetSet()  : mixed
Implements setter for ArrayAccess interface.
offsetUnset()  : mixed
Implements unset() for ArrayAccess interface.
remove()  : mixed
Deletes a given form variable.
sanitize()  : mixed
Sanitize the form input.
set()  : mixed
Sets the value of a given form variable.
_getExists()  : bool
Fetch the requested variable ($varname) into $value, and return whether or not the variable was set in $array.

Properties

$expected

The list of expected variables.

protected array<string|int, mixed> $expected = []

$sanitized

Has the input been sanitized?

protected bool $sanitized = false

$vars

Array of form variables.

protected array<string|int, mixed> $vars

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $vars = [] ][, bool $sanitize = false ]) : mixed
Parameters
$vars : array<string|int, mixed> = []

The list of form variables (if null, defaults to PHP's $_REQUEST value). If '_formvars' exists, it must be a JSON encoded array that contains the list of allowed form variables.

$sanitize : bool = false

Sanitize the input variables?

Return values
mixed

__get()

Returns the value of a given form variable.

public __get(string $varname) : mixed
Parameters
$varname : string

The form variable name.

Return values
mixed

The form variable, or null if it doesn't exist.

__isset()

isset() implementation.

public __isset(string $varname) : bool
Parameters
$varname : string

The form variable name.

Return values
bool

Does $varname form variable exist?

__set()

Sets the value of a given form variable.

public __set(string $varname, mixed $value) : mixed
Parameters
$varname : string

The form variable name.

$value : mixed

The value to set.

Return values
mixed

__unset()

Deletes a given form variable.

public __unset(string $varname) : mixed
Parameters
$varname : string

The form variable name.

Return values
mixed

add()

Set $varname to $value ONLY if it's not already present.

public add(string $varname, mixed $value) : bool
Parameters
$varname : string

The form variable name.

$value : mixed

The value to set.

Return values
bool

True if the value was altered.

count()

public count() : mixed
Return values
mixed

exists()

Alias of isset().

public exists(mixed $varname) : mixed
Parameters
$varname : mixed
Tags
see
__isset()
Return values
mixed

filter()

Filters a form value so that it can be used in HTML output.

public filter(string|array<string|int, mixed> $varname) : string|array<string|int, mixed>
Parameters
$varname : string|array<string|int, mixed>

The form variable name.

Return values
string|array<string|int, mixed>

The filtered variable, or null if it doesn't exist.

get()

Returns the value of a given form variable.

public get(string $varname[, string $default = null ]) : mixed
Parameters
$varname : string

The form variable name.

$default : string = null

The default form variable value.

Return values
mixed

The form variable, or $default if it doesn't exist.

getDefaultVariables()

Returns a Horde_Variables object populated with the form input.

public static getDefaultVariables([bool $sanitize = false ]) : Variables
Parameters
$sanitize : bool = false

Sanitize the input variables?

Return values
Variables

Variables object.

getExists()

Given a variable name, returns the value and sets a variable indicating whether the value exists in the form data.

public getExists(string $varname, bool &$exists) : mixed
Parameters
$varname : string

The form variable name.

$exists : bool

Reference to variable that will indicate whether $varname existed in form data.

Return values
mixed

The form variable, or null if it doesn't exist.

getIterator()

public getIterator() : mixed
Return values
mixed

merge()

Merges a list of variables into the current form variable list.

public merge(array<string|int, mixed> $vars) : mixed
Parameters
$vars : array<string|int, mixed>

Form variables.

Return values
mixed

offsetExists()

Implements isset() for ArrayAccess interface.

public offsetExists(mixed $field) : mixed
Parameters
$field : mixed
Tags
see
__isset()
Return values
mixed

offsetGet()

Implements getter for ArrayAccess interface.

public offsetGet(mixed $field) : mixed
Parameters
$field : mixed
Tags
see
__get()
Return values
mixed

offsetSet()

Implements setter for ArrayAccess interface.

public offsetSet(mixed $field, mixed $value) : mixed
Parameters
$field : mixed
$value : mixed
Tags
see
__set()
Return values
mixed

offsetUnset()

Implements unset() for ArrayAccess interface.

public offsetUnset(mixed $field) : mixed
Parameters
$field : mixed
Tags
see
__unset()
Return values
mixed

remove()

Deletes a given form variable.

public remove(mixed $varname) : mixed
Parameters
$varname : mixed
Tags
see
__unset()
Return values
mixed

sanitize()

Sanitize the form input.

public sanitize() : mixed
Return values
mixed

set()

Sets the value of a given form variable.

public set(mixed $varname, mixed $value) : mixed
Parameters
$varname : mixed
$value : mixed
Tags
see
__set()
Return values
mixed

_getExists()

Fetch the requested variable ($varname) into $value, and return whether or not the variable was set in $array.

protected _getExists(array<string|int, mixed> $array, string $varname, mixed &$value) : bool
Parameters
$array : array<string|int, mixed>

The array to search in (usually either $this->_vars or $this->_expected).

$varname : string

The name of the variable to look for.

$value : mixed

$varname's value gets assigned to this variable.

Return values
bool

Whether or not the variable was set (or, if we've checked $this->_expected, should have been set).

Search results