Input.php
6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Input;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Filter\InputFilter;
/**
* Joomla! Input Base Class
*
* This is an abstracted input class used to manage retrieving data from the application environment.
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*
* @property-read Input $get
* @property-read Input $post
* @property-read Input $request
* @property-read Input $server
* @property-read Input $env
* @property-read Files $files
* @property-read Cookie $cookie
*/
class Input extends \Joomla\Input\Input
{
/**
* Container with allowed superglobals
*
* @var array
* @since 3.8.9
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
private static $allowedGlobals = array('REQUEST', 'GET', 'POST', 'FILES', 'SERVER', 'ENV');
/**
* Input objects
*
* @var Input[]
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
protected $inputs = array();
/**
* Constructor.
*
* @param array $source Source data (Optional, default is $_REQUEST)
* @param array $options Array of configuration parameters (Optional)
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function __construct($source = null, array $options = array())
{
if (!isset($options['filter']))
{
$this->filter = InputFilter::getInstance();
}
parent::__construct($source, $options);
}
/**
* Magic method to get an input object
*
* @param mixed $name Name of the input object to retrieve.
*
* @return Input The request input object
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function __get($name)
{
if (isset($this->inputs[$name]))
{
return $this->inputs[$name];
}
$className = '\\Joomla\\CMS\\Input\\' . ucfirst($name);
if (class_exists($className))
{
$this->inputs[$name] = new $className(null, $this->options);
return $this->inputs[$name];
}
$superGlobal = '_' . strtoupper($name);
if (in_array(strtoupper($name), self::$allowedGlobals, true) && isset($GLOBALS[$superGlobal]))
{
$this->inputs[$name] = new Input($GLOBALS[$superGlobal], $this->options);
return $this->inputs[$name];
}
// Try using the parent class
return parent::__get($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 filter given by the parameter defaultFilter in
* JFilterInput::clean.
* @param mixed $datasource Array to retrieve data from, or null.
* @param string $defaultFilter Default filter used in JFilterInput::clean if vars is empty and
* datasource is null. If 'unknown', the default case is used in
* JFilterInput::clean.
*
* @return mixed The filtered input data.
*
* @since 1.7.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function getArray(array $vars = array(), $datasource = null, $defaultFilter = 'unknown')
{
return $this->getArrayRecursive($vars, $datasource, $defaultFilter, false);
}
/**
* 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 filter given by the parameter defaultFilter in
* JFilterInput::clean.
* @param mixed $datasource Array to retrieve data from, or null.
* @param string $defaultFilter Default filter used in JFilterInput::clean if vars is empty and
* datasource is null. If 'unknown', the default case is used in
* JFilterInput::clean.
* @param bool $recursion Flag to indicate a recursive function call.
*
* @return mixed The filtered input data.
*
* @since 3.4.2
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
protected function getArrayRecursive(array $vars = array(), $datasource = null, $defaultFilter = 'unknown', $recursion = false)
{
if (empty($vars) && is_null($datasource))
{
$vars = $this->data;
}
else
{
if (!$recursion)
{
$defaultFilter = null;
}
}
$results = array();
foreach ($vars as $k => $v)
{
if (is_array($v))
{
if (is_null($datasource))
{
$results[$k] = $this->getArrayRecursive($v, $this->get($k, null, 'array'), $defaultFilter, true);
}
else
{
$results[$k] = $this->getArrayRecursive($v, $datasource[$k], $defaultFilter, true);
}
}
else
{
$filter = isset($defaultFilter) ? $defaultFilter : $v;
if (is_null($datasource))
{
$results[$k] = $this->get($k, null, $filter);
}
elseif (isset($datasource[$k]))
{
$results[$k] = $this->filter->clean($datasource[$k], $filter);
}
else
{
$results[$k] = $this->filter->clean(null, $filter);
}
}
}
return $results;
}
/**
* Method to unserialize the input.
*
* @param string $input The serialized input.
*
* @return Input The input object.
*
* @since 3.0.0
* @deprecated 5.0 Use Joomla\Input\Input instead
*/
public function unserialize($input)
{
// Unserialize the options, data, and inputs.
list($this->options, $this->data, $this->inputs) = unserialize($input);
// Load the filter.
if (isset($this->options['filter']))
{
$this->filter = $this->options['filter'];
}
else
{
$this->filter = InputFilter::getInstance();
}
}
}