Source for file input.php
Documentation is available at input.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Joomla! Input Base Class
* This is an abstracted input class used to manage retrieving data from the application environment.
* @package Joomla.Platform
* @property-read JInput $get
* @property-read JInput $post
* @property-read JInput $request
* @property-read JInput $server
* @property-read JInputFiles $files
* @property-read JInputCookie $cookie
* @method integer getInt() getInt($name, $default = null) Get a signed integer.
* @method integer getUint() getUint($name, $default = null) Get an unsigned integer.
* @method float getFloat() getFloat($name, $default = null) Get a floating-point number.
* @method boolean getBool() getBool($name, $default = null) Get a boolean.
* @method string getWord() getWord($name, $default = null)
* @method string getAlnum() getAlnum($name, $default = null)
* @method string getCmd() getCmd($name, $default = null)
* @method string getBase64() getBase64($name, $default = null)
* @method string getString() getString($name, $default = null)
* @method string getHtml() getHtml($name, $default = null)
* @method string getPath() getPath($name, $default = null)
* @method string getUsername() getUsername($name, $default = null)
class JInput implements Serializable, Countable
* Options array for the JInput instance.
protected $data =
array();
* @param array $source Source data (Optional, default is $_REQUEST)
* @param array $options Array of configuration parameters (Optional)
public function __construct($source =
null, array $options =
array())
if (isset
($options['filter']))
$this->filter =
$options['filter'];
$this->data =
&$_REQUEST;
// Set the options for the class.
* Magic method to get an input object
* @param mixed $name Name of the input object to retrieve.
* @return JInput The request input object
public function __get($name)
if (isset
($this->inputs[$name]))
$className =
'JInput' .
ucfirst($name);
if (isset
($GLOBALS[$superGlobal]))
// TODO throw an exception
* Get the number of variables.
* @return integer The number of variables in the input.
* @see Countable::count()
* Gets a value from the input data.
* @param string $name Name of the value to get.
* @param mixed $default Default value to return if variable does not exist.
* @param string $filter Filter to apply to the value.
* @return mixed The filtered input value.
public function get($name, $default =
null, $filter =
'cmd')
if (isset
($this->data[$name]))
* Gets an array of values from the request.
* @param array $vars Associative array of keys and filter types to apply.
* If empty and datasource is null, all the input data will be returned
* but filtered using the default case in JFilterInput::clean.
* @param mixed $datasource Array to retrieve data from, or null
* @return mixed The filtered input data.
public function getArray(array $vars =
array(), $datasource =
null)
if (empty($vars) &&
is_null($datasource))
foreach ($vars as $k =>
$v)
$results[$k] =
$this->getArray($v, $this->get($k, null, 'array'));
$results[$k] =
$this->getArray($v, $datasource[$k]);
$results[$k] =
$this->get($k, null, $v);
elseif (isset
($datasource[$k]))
$results[$k] =
$this->filter->clean($datasource[$k], $v);
* @param string $name Name of the value to set.
* @param mixed $value Value to assign to the input.
public function set($name, $value)
$this->data[$name] =
$value;
* Define a value. The value will only be set if there's no value for the name or if it is null.
* @param string $name Name of the value to define.
* @param mixed $value Value to assign to the input.
public function def($name, $value)
if (isset
($this->data[$name]))
$this->data[$name] =
$value;
* Magic method to get filtered input data.
* @param string $name Name of the filter type prefixed with 'get'.
* @param array $arguments [0] The name of the variable [1] The default value.
* @return mixed The filtered input value.
public function __call($name, $arguments)
if (substr($name, 0, 3) ==
'get')
if (isset
($arguments[1]))
$default =
$arguments[1];
return $this->get($arguments[0], $default, $filter);
* Gets the request method.
* @return string The request method.
* Method to serialize the input.
* @return string The serialized input.
// Load all of the inputs.
// Remove $_ENV and $_SERVER from the inputs.
unset
($inputs['server']);
// Serialize the options, data, and inputs.
* Method to unserialize the input.
* @param string $input The serialized input.
* @return JInput The input object.
// Unserialize the options, data, and inputs.
if (isset
($this->options['filter']))
* Method to load all of the global inputs.
// Load up all the globals.
foreach ($GLOBALS as $global =>
$data)
// Check if the global starts with an underscore.
if (strpos($global, '_') ===
0)
// Convert global name to input name.
$global =
strtolower($global);
$global =
substr($global, 1);
Documentation generated on Tue, 19 Nov 2013 15:05:36 +0100 by phpDocumentor 1.4.3