Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1146 from realityking/jrequest

Deal with some occurrences of JRequest
  • Loading branch information...
commit f730a6fa453c5b1e35b65ef96b100dabbd94ab96 2 parents ec8b133 + b740a8c
Christophe Demko authored
2  libraries/joomla/cache/cache.php
View
@@ -645,7 +645,7 @@ public static function makeId()
foreach ($registeredurlparams as $key => $value)
{
- $safeuriaddon->$key = JRequest::getVar($key, null, 'default', $value);
+ $safeuriaddon->$key = $app->input->get($key, null, $value);
}
return md5(serialize($safeuriaddon));
5 libraries/legacy/application/application.php
View
@@ -106,10 +106,7 @@ public function __construct($config = array())
}
// Create the input object
- if (class_exists('JInput'))
- {
- $this->input = new JInput;
- }
+ $this->input = new JInput;
// Set the session default name.
if (!isset($config['session_name']))
5 libraries/legacy/application/helper.php
View
@@ -44,14 +44,15 @@ public static function getComponentName($default = null)
return $option;
}
- $option = strtolower(JRequest::getCmd('option'));
+ $input = JFactory::getApplication()->input;
+ $option = strtolower($input->get('option'));
if (empty($option))
{
$option = $default;
}
- JRequest::setVar('option', $option);
+ $input->set('option', $option);
return $option;
}
2  libraries/legacy/component/helper.php
View
@@ -327,7 +327,7 @@ public static function renderComponent($option, $params = array())
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
}
- $task = JRequest::getString('task');
+ $task = $app->input->getString('task');
// Load common and local language files.
$lang->load($option, JPATH_BASE, null, false, false) || $lang->load($option, JPATH_COMPONENT, null, false, false)
6 libraries/legacy/controller/admin.php
View
@@ -167,6 +167,8 @@ public function publish()
// Check for request forgeries
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
+ $input = JFactory::getApplication()->input;
+
// Get items to publish from the request.
$cid = JRequest::getVar('cid', array(), '', 'array');
$data = array('publish' => 1, 'unpublish' => 0, 'archive' => 2, 'trash' => -2, 'report' => -3);
@@ -211,8 +213,8 @@ public function publish()
$this->setMessage(JText::plural($ntext, count($cid)));
}
}
- $extension = JRequest::getCmd('extension');
- $extensionURL = ($extension) ? '&extension=' . JRequest::getCmd('extension') : '';
+ $extension = $input->get('extension');
+ $extensionURL = ($extension) ? '&extension=' . $extension : '';
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false));
}
15 libraries/legacy/controller/controller.php
View
@@ -218,10 +218,12 @@ public static function getInstance($prefix, $config = array())
return self::$instance;
}
+ $input = JFactory::getApplication()->input;
+
// Get the environment configuration.
$basePath = array_key_exists('base_path', $config) ? $config['base_path'] : JPATH_COMPONENT;
- $format = JRequest::getWord('format');
- $command = JRequest::getVar('task', 'display');
+ $format = $input->getWord('format');
+ $command = $input->get('task', 'display');
// Check for array format.
$filter = JFilterInput::getInstance();
@@ -246,7 +248,7 @@ public static function getInstance($prefix, $config = array())
$path = $basePath . '/controllers/' . $file;
// Reset the task without the controller context.
- JRequest::setVar('task', $task);
+ $input->set('task', $task);
}
else
{
@@ -614,8 +616,9 @@ public function display($cachable = false, $urlparams = array())
{
$document = JFactory::getDocument();
$viewType = $document->getType();
- $viewName = JRequest::getCmd('view', $this->default_view);
- $viewLayout = JRequest::getCmd('layout', 'default');
+ $input = JFactory::getApplication()->input;
+ $viewName = $input->get('view', $this->default_view);
+ $viewLayout = $input->get('layout', 'default');
$view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout));
@@ -633,7 +636,7 @@ public function display($cachable = false, $urlparams = array())
// Display the view
if ($cachable && $viewType != 'feed' && $conf->get('caching') >= 1)
{
- $option = JRequest::getCmd('option');
+ $option = $input->get('layout');
$cache = JFactory::getCache($option, 'view');
if (is_array($urlparams))
23 libraries/legacy/controller/form.php
View
@@ -310,7 +310,7 @@ public function cancel($key = null)
$key = $table->getKeyName();
}
- $recordId = JRequest::getInt($key);
+ $recordId = $app->input->getInt($key);
// Attempt to check-in the current record.
if ($recordId)
@@ -380,7 +380,8 @@ public function cancel($key = null)
public function edit($key = null, $urlVar = null)
{
// Initialise variables.
- $app = JFactory::getApplication();
+ $app = JFactory::getApplication();
+ $input = $app->input;
$model = $this->getModel();
$table = $model->getTable();
$cid = JRequest::getVar('cid', array(), 'post', 'array');
@@ -399,7 +400,7 @@ public function edit($key = null, $urlVar = null)
}
// Get the previous record id (if any) and the current record id.
- $recordId = (int) (count($cid) ? $cid[0] : JRequest::getInt($urlVar));
+ $recordId = (int) (count($cid) ? $cid[0] : $input->getInt($urlVar));
$checkin = property_exists($table, 'checked_out');
// Access check.
@@ -484,8 +485,9 @@ public function getModel($name = '', $prefix = '', $config = array('ignore_reque
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
- $tmpl = JRequest::getCmd('tmpl');
- $layout = JRequest::getCmd('layout', 'edit');
+ $input = JFactory::getApplication()->input;
+ $tmpl = $input->get('tmpl');
+ $layout = $input->get('layout', 'edit');
$append = '';
// Setup redirect info.
@@ -516,7 +518,7 @@ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
*/
protected function getRedirectToListAppend()
{
- $tmpl = JRequest::getCmd('tmpl');
+ $tmpl = JFactory::getApplication()->input->get('tmpl');
$append = '';
// Setup redirect info.
@@ -559,11 +561,12 @@ public function save($key = null, $urlVar = null)
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Initialise variables.
- $app = JFactory::getApplication();
- $lang = JFactory::getLanguage();
+ $app = JFactory::getApplication();
+ $input = $app->input;
+ $lang = JFactory::getLanguage();
$model = $this->getModel();
$table = $model->getTable();
- $data = JRequest::getVar('jform', array(), 'post', 'array');
+ $data = JRequest::getVar('jform', array(), 'post', 'array');
$checkin = property_exists($table, 'checked_out');
$context = "$this->option.edit.$this->context";
$task = $this->getTask();
@@ -580,7 +583,7 @@ public function save($key = null, $urlVar = null)
$urlVar = $key;
}
- $recordId = JRequest::getInt($urlVar);
+ $recordId = $input->getInt($urlVar);
if (!$this->checkEditId($context, $recordId))
{
3  libraries/legacy/form/field/media.php
View
@@ -50,13 +50,12 @@ protected function getInput()
$asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id'];
if ($asset == '')
{
- $asset = JRequest::getCmd('option');
+ $asset = JFactory::getApplication()->input->get('option');
}
$link = (string) $this->element['link'];
if (!self::$initialised)
{
-
// Load the modal behavior script.
JHtml::_('behavior.modal');
2  libraries/legacy/model/admin.php
View
@@ -799,7 +799,7 @@ protected function populateState()
$key = $table->getKeyName();
// Get the pk of the record from the request.
- $pk = JRequest::getInt($key);
+ $pk = JFactory::getApplication()->input->getInt($key);
$this->setState($this->getName() . '.id', $pk);
// Load the parameters.
5 libraries/legacy/model/list.php
View
@@ -347,13 +347,14 @@ protected function populateState($ordering = null, $direction = null)
public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true)
{
$app = JFactory::getApplication();
+ $input = $app->input;
$old_state = $app->getUserState($key);
$cur_state = (!is_null($old_state)) ? $old_state : $default;
- $new_state = JRequest::getVar($request, null, 'default', $type);
+ $new_state = $input->get($request, null, $type);
if (($cur_state != $new_state) && ($resetPage))
{
- JRequest::setVar('limitstart', 0);
+ $input->set('limitstart', 0);
}
// Save the new value only if it is set in this request.
2  libraries/legacy/model/model.php
View
@@ -496,7 +496,7 @@ protected function cleanCache($group = null, $client_id = 0)
$dispatcher = JDispatcher::getInstance();
$options = array(
- 'defaultgroup' => ($group) ? $group : (isset($this->option) ? $this->option : JRequest::getCmd('option')),
+ 'defaultgroup' => ($group) ? $group : (isset($this->option) ? $this->option : JFactory::getApplication()->input->get('option')),
'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'));
$cache = JCache::getInstance('callback', $options);
7 libraries/legacy/module/helper.php
View
@@ -80,6 +80,7 @@ public static function &getModules($position)
{
$position = strtolower($position);
$result = array();
+ $input = JFactory::getApplication()->input;
$modules =& self::_load();
@@ -94,7 +95,7 @@ public static function &getModules($position)
if (count($result) == 0)
{
- if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display'))
+ if ($input->getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display'))
{
$result[0] = self::getModule('mod_' . $position);
$result[0]->title = $position;
@@ -202,7 +203,7 @@ public static function renderModule($module, $attribs = array())
}
// Dynamically add outline style
- if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display'))
+ if ($app->input->getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display'))
{
$attribs['style'] .= ' outline';
}
@@ -289,8 +290,8 @@ protected static function &_load()
return $clean;
}
- $Itemid = JRequest::getInt('Itemid');
$app = JFactory::getApplication();
+ $Itemid = $app->input->getInt('Itemid');
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
$lang = JFactory::getLanguage()->getTag();
2  tests/core/mock/application.php
View
@@ -46,6 +46,8 @@ public static function create($test)
false
);
+ $mockObject->input = new JInput;
+
return $mockObject;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.