Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JRequest

Liste de tous les membres

Fonctions membres publiques statiques

static getURI ()
static getMethod ()
static getVar ($name, $default=null, $hash= 'default', $type= 'none', $mask=0)
static getInt ($name, $default=0, $hash= 'default')
static getUInt ($name, $default=0, $hash= 'default')
static getFloat ($name, $default=0.0, $hash= 'default')
static getBool ($name, $default=false, $hash= 'default')
static getWord ($name, $default= '', $hash= 'default')
static getCmd ($name, $default= '', $hash= 'default')
static getString ($name, $default= '', $hash= 'default', $mask=0)
static setVar ($name, $value=null, $hash= 'method', $overwrite=true)
static get ($hash= 'default', $mask=0)
static set ($array, $hash= 'default', $overwrite=true)
static checkToken ($method= 'post')

Fonctions membres protégées statiques

static _cleanVar ($var, $mask=0, $type=null)

Description détaillée

Définition à la ligne 38 du fichier request.php.


Documentation des fonctions membres

static JRequest::_cleanVar (   $var,
  $mask = 0,
  $type = null 
)
staticprotected

Clean up an input variable.

Paramètres:
mixed$varThe input variable.
integer$maskFilter bit mask. 1 = no trim: If this flag is cleared and the input is a string, the string will have leading and trailing whitespace trimmed. 2 = allow_raw: If set, no more filtering is performed, higher bits are ignored. 4 = allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering is performed. If no bits other than the 1 bit is set, a strict filter is applied.
string$typeThe variable type {
Voir également:
JFilterInput::clean()}.
Renvoie:
mixed Same as $var
Obsolète:
12.1
Depuis:
11.1

Définition à la ligne 525 du fichier request.php.

Références JFilterInput\getInstance().

{
// If the no trim flag is not set, trim the variable
if (!($mask & 1) && is_string($var))
{
$var = trim($var);
}
// Now we handle input filtering
if ($mask & 2)
{
// If the allow raw flag is set, do not modify the variable
$var = $var;
}
elseif ($mask & 4)
{
// If the allow HTML flag is set, apply a safe HTML filter to the variable
$safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1);
$var = $safeHtmlFilter->clean($var, $type);
}
else
{
// Since no allow flags were set, we will apply the most strict filter to the variable
// $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults.
$noHtmlFilter = JFilterInput::getInstance();
$var = $noHtmlFilter->clean($var, $type);
}
return $var;
}

+ Voici le graphe d'appel pour cette fonction :

static JRequest::checkToken (   $method = 'post')
static

Checks for a form token in the request.

Use in conjunction with JHtml::_('form.token').

Paramètres:
string$methodThe request method in which to look for the token key.
Renvoie:
boolean True if found and valid, false otherwise.
Obsolète:
12.1 Use JSession::checkToken() instead. Note that 'default' has to become 'request'.
Depuis:
11.1

Définition à la ligne 498 du fichier request.php.

Références JSession\checkToken().

{
if ($method == 'default')
{
$method = 'request';
}
return JSession::checkToken($method);
}

+ Voici le graphe d'appel pour cette fonction :

static JRequest::get (   $hash = 'default',
  $mask = 0 
)
static

Fetches and returns a request array.

The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning $_GET, POST and PUT will result in returning $_POST.

You can force the source by setting the $hash parameter:

post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST

Paramètres:
string$hashto get (POST, GET, FILES, METHOD).
integer$maskFilter mask for the variable.
Renvoie:
mixed Request hash.
Obsolète:
12.1 User JInput::get
Voir également:
JInput
Depuis:
11.1

Définition à la ligne 420 du fichier request.php.

{
$hash = strtoupper($hash);
if ($hash === 'METHOD')
{
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}
switch ($hash)
{
case 'GET':
$input = $_GET;
break;
case 'POST':
$input = $_POST;
break;
case 'FILES':
$input = $_FILES;
break;
case 'COOKIE':
$input = $_COOKIE;
break;
case 'ENV':
$input = &$_ENV;
break;
case 'SERVER':
$input = &$_SERVER;
break;
default:
$input = $_REQUEST;
break;
}
$result = self::_cleanVar($input, $mask);
return $result;
}
static JRequest::getBool (   $name,
  $default = false,
  $hash = 'default' 
)
static

Fetches and returns a given filtered variable. The bool filter will only return true/false bool values. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name.
string$defaultDefault value if the variable does not exist.
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Renvoie:
boolean Requested variable.
Obsolète:
12.1
Depuis:
11.1

Définition à la ligne 253 du fichier request.php.

{
return self::getVar($name, $default, $hash, 'bool');
}
static JRequest::getCmd (   $name,
  $default = '',
  $hash = 'default' 
)
static

Cmd (Word and Integer0 filter

Fetches and returns a given filtered variable. The cmd filter only allows the characters [A-Za-z0-9.-_]. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Renvoie:
string Requested variable
Obsolète:
12.1
Depuis:
11.1

Définition à la ligne 298 du fichier request.php.

{
return self::getVar($name, $default, $hash, 'cmd');
}
static JRequest::getFloat (   $name,
  $default = 0.0,
  $hash = 'default' 
)
static

Fetches and returns a given filtered variable. The float filter only allows digits and periods. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name.
string$defaultDefault value if the variable does not exist.
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Renvoie:
float Requested variable.
Depuis:
11.1
Obsolète:
12.1

Définition à la ligne 232 du fichier request.php.

{
return self::getVar($name, $default, $hash, 'float');
}
static JRequest::getInt (   $name,
  $default = 0,
  $hash = 'default' 
)
static

Fetches and returns a given filtered variable. The integer filter will allow only digits and the - sign to be returned. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name.
string$defaultDefault value if the variable does not exist.
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Renvoie:
integer Requested variable.
Depuis:
11.1
Obsolète:
12.1

Définition à la ligne 189 du fichier request.php.

{
return self::getVar($name, $default, $hash, 'int');
}
static JRequest::getMethod ( )
static

Gets the request method.

Renvoie:
string
Depuis:
11.1
Obsolète:
12.1 Use JInput::getMethod() instead

Définition à la ligne 64 du fichier request.php.

{
$method = strtoupper($_SERVER['REQUEST_METHOD']);
return $method;
}
static JRequest::getString (   $name,
  $default = '',
  $hash = 'default',
  $mask = 0 
)
static

Fetches and returns a given filtered variable. The string filter deletes 'bad' HTML code, if not overridden by the mask. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name
string$defaultDefault value if the variable does not exist
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
integer$maskFilter mask for the variable
Renvoie:
string Requested variable
Depuis:
11.1
Obsolète:
12.1

Définition à la ligne 321 du fichier request.php.

{
// Cast to string, in case JREQUEST_ALLOWRAW was specified for mask
return (string) self::getVar($name, $default, $hash, 'string', $mask);
}
static JRequest::getUInt (   $name,
  $default = 0,
  $hash = 'default' 
)
static

Fetches and returns a given filtered variable. The unsigned integer filter will allow only digits to be returned. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name.
string$defaultDefault value if the variable does not exist.
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Renvoie:
integer Requested variable.
Obsolète:
12.1
Depuis:
11.1

Définition à la ligne 210 du fichier request.php.

{
return self::getVar($name, $default, $hash, 'uint');
}
static JRequest::getURI ( )
static

Gets the full request path.

Renvoie:
string
Depuis:
11.1
Obsolète:
12.1

Définition à la ligne 49 du fichier request.php.

Références JUri\getInstance().

{
return $uri->toString(array('path', 'query'));
}

+ Voici le graphe d'appel pour cette fonction :

static JRequest::getVar (   $name,
  $default = null,
  $hash = 'default',
  $type = 'none',
  $mask = 0 
)
static

Fetches and returns a given variable.

The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning an entry from $_GET, POST and PUT will result in returning an entry from $_POST.

You can force the source by setting the $hash parameter:

post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST

Paramètres:
string$nameVariable name.
string$defaultDefault value if the variable does not exist.
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
string$typeReturn type for the variable, for valid values see JFilterInput::clean().
integer$maskFilter mask for the variable.
Renvoie:
mixed Requested variable.
Depuis:
11.1
Obsolète:
12.1 Use JInput::Get

Définition à la ligne 101 du fichier request.php.

Références $GLOBALS.

{
// Ensure hash and type are uppercase
$hash = strtoupper($hash);
if ($hash === 'METHOD')
{
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}
$type = strtoupper($type);
$sig = $hash . $type . $mask;
// Get the input hash
switch ($hash)
{
case 'GET':
$input = &$_GET;
break;
case 'POST':
$input = &$_POST;
break;
case 'FILES':
$input = &$_FILES;
break;
case 'COOKIE':
$input = &$_COOKIE;
break;
case 'ENV':
$input = &$_ENV;
break;
case 'SERVER':
$input = &$_SERVER;
break;
default:
$input = &$_REQUEST;
$hash = 'REQUEST';
break;
}
if (isset($GLOBALS['_JREQUEST'][$name]['SET.' . $hash]) && ($GLOBALS['_JREQUEST'][$name]['SET.' . $hash] === true))
{
// Get the variable from the input hash
$var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default;
$var = self::_cleanVar($var, $mask, $type);
}
elseif (!isset($GLOBALS['_JREQUEST'][$name][$sig]))
{
if (isset($input[$name]) && $input[$name] !== null)
{
// Get the variable from the input hash and clean it
$var = self::_cleanVar($input[$name], $mask, $type);
$GLOBALS['_JREQUEST'][$name][$sig] = $var;
}
elseif ($default !== null)
{
// Clean the default value
$var = self::_cleanVar($default, $mask, $type);
}
else
{
$var = $default;
}
}
else
{
$var = $GLOBALS['_JREQUEST'][$name][$sig];
}
return $var;
}
static JRequest::getWord (   $name,
  $default = '',
  $hash = 'default' 
)
static

Fetches and returns a given filtered variable. The word filter only allows the characters [A-Za-z_]. This is currently only a proxy function for getVar().

See getVar() for more in-depth documentation on the parameters.

Paramètres:
string$nameVariable name.
string$defaultDefault value if the variable does not exist.
string$hashWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Renvoie:
string Requested variable.
Depuis:
11.1
Obsolète:
12.1

Définition à la ligne 275 du fichier request.php.

{
return self::getVar($name, $default, $hash, 'word');
}
static JRequest::set (   $array,
  $hash = 'default',
  $overwrite = true 
)
static

Sets a request variable.

Paramètres:
array$arrayAn associative array of key-value pairs.
string$hashThe request variable to set (POST, GET, FILES, METHOD).
boolean$overwriteIf true and an existing key is found, the value is overwritten, otherwise it is ignored.
Renvoie:
void
Obsolète:
12.1 Use JInput::set()
Voir également:
JInput::set()
Depuis:
11.1

Définition à la ligne 478 du fichier request.php.

{
foreach ($array as $key => $value)
{
self::setVar($key, $value, $hash, $overwrite);
}
}
static JRequest::setVar (   $name,
  $value = null,
  $hash = 'method',
  $overwrite = true 
)
static

Set a variable in one of the request variables.

Paramètres:
string$nameName
string$valueValue
string$hashHash
boolean$overwriteBoolean
Renvoie:
string Previous value
Depuis:
11.1
Obsolète:
12.1

Définition à la ligne 341 du fichier request.php.

Références $GLOBALS.

{
// If overwrite is true, makes sure the variable hasn't been set yet
if (!$overwrite && array_key_exists($name, $_REQUEST))
{
return $_REQUEST[$name];
}
// Clean global request var
$GLOBALS['_JREQUEST'][$name] = array();
// Get the request hash value
$hash = strtoupper($hash);
if ($hash === 'METHOD')
{
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}
$previous = array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : null;
switch ($hash)
{
case 'GET':
$_GET[$name] = $value;
$_REQUEST[$name] = $value;
break;
case 'POST':
$_POST[$name] = $value;
$_REQUEST[$name] = $value;
break;
case 'COOKIE':
$_COOKIE[$name] = $value;
$_REQUEST[$name] = $value;
break;
case 'FILES':
$_FILES[$name] = $value;
break;
case 'ENV':
$_ENV['name'] = $value;
break;
case 'SERVER':
$_SERVER['name'] = $value;
break;
}
// Mark this variable as 'SET'
$GLOBALS['_JREQUEST'][$name]['SET.' . $hash] = true;
$GLOBALS['_JREQUEST'][$name]['SET.REQUEST'] = true;
return $previous;
}

La documentation de cette classe a été générée à partir du fichier suivant :