\cge_param

A set of utilities for cleaning input parameters.

Summary

Methods
Properties
Constants
exists()
get_html()
get_int()
get_bool()
get_string()
get_float()
get_string_array()
get_separated_date()
get_date()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

exists()

exists(array $params, string $key) : bool

A convenience method to test if a key exists in the input array.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

Returns

bool

get_html()

get_html(array $params, string $key, string $dflt) : string

Get safe HTML from an input parameter.

This method uses htmlawed to clean input HTML.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

string $dflt

The default value to use if the key does not exist in the $params aray.

Returns

string

get_int()

get_int(array $params, string $key, int $dflt) : int

Get a safe integer from an input parameter.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

int $dflt

The default value to use if the key does not exist in the $params aray.

Returns

int

get_bool()

get_bool(array $params, string $key, bool $dflt)

Get a safe boolean from an input parameter.

This method can accept boolean strings like yes, no, true, false, on, off.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

bool $dflt

The default value to use if the key does not exist in the $params aray.

get_string()

get_string(array $params, string $key, string $dflt)

Get a safe string from an input parameter.

The string is stripped of any javascript or html code.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

string $dflt

The default value to use if the key does not exist in the $params aray.

get_float()

get_float(array $params, string $key, float $dflt)

Get a safe float from an input parameter.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

float $dflt

The default value to use if the key does not exist in the $params aray.

get_string_array()

get_string_array(array $params, string $key, string[] $dflt)

Get a safe array of strings from an input parameter that is an array.

Parameters

array $params

An associative array of input params

string $key

The key to the associative array

string[] $dflt

The default value to use if the key does not exist in the $params aray.

get_separated_date()

get_separated_date(array $params, string $prefix,  $dflt) : int

Get a unix timestamp from separate month, day and year fields.

This method is useful for converting dates a user entered into separate month day and year fields into a unix timestamp. i.e: if using the smarty {html_select_date} field for gathering dates.

This method assumes that there will be separate fields in the params array who's values are integers, and the key begins with the provided prefix and ends with _Month, _Day, and _Year respectively.

Note, if the year parameter does not exist in the params array, but month and day do... then the current year is used.

Parameters

array $params
string $prefix

The common prefix for the separate month, day and year parameters

$dflt

Returns

int —

A unix timestamp representing the day found, at midnight.

get_date()

get_date(array $params, string $key, \ing $dflt)

Get a unix timestamp from a input text or date field.

assumes DD/MM/YYYY format.

Parameters

array $params
string $key

The key to the associative array

\ing $dflt

The default timestamp value to use if the key does not exist in the $params aray.