Skip to content

Commit

Permalink
Namespace com_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed May 22, 2017
1 parent 0fe53ca commit cb7e5a2
Show file tree
Hide file tree
Showing 19 changed files with 443 additions and 357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Fields\Administrator\Controller;

defined('_JEXEC') or die;

/**
* Fields Controller
*
* @since 3.7.0
*/
class FieldsController extends JControllerLegacy
class Controller extends \Joomla\CMS\Controller\Controller
{
/**
* The default view.
Expand All @@ -31,9 +33,9 @@ class FieldsController extends JControllerLegacy
* you will need to override it in your own controllers.
*
* @param boolean $cachable If true, the view output will be cached
* @param array|bool $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}
* @param array|bool $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}
*
* @return JControllerLegacy|boolean A JControllerLegacy object to support chaining.
* @return Controller|boolean A Controller object to support chaining.
*
* @since 3.7.0
*/
Expand All @@ -47,9 +49,9 @@ public function display($cachable = false, $urlparams = false)
if ($vName == 'field' && !$this->checkEditId('com_fields.edit.field', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setError(\JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_fields&view=fields&context=' . $this->input->get('context'), false));
$this->setRedirect(\JRoute::_('index.php?option=com_fields&view=fields&context=' . $this->input->get('context'), false));

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Fields\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Controller\Form;
use Joomla\CMS\Model\Model;
use Joomla\CMS\Mvc\Factory\MvcFactoryInterface;
use Joomla\Registry\Registry;

/**
* The Field controller
*
* @since 3.7.0
*/
class FieldsControllerField extends JControllerForm
class Field extends Form
{
private $internalContext;

Expand All @@ -31,18 +36,23 @@ class FieldsControllerField extends JControllerForm
protected $text_prefix = 'COM_FIELDS_FIELD';

/**
* Class constructor.
* Constructor.
*
* @param array $config A named array of configuration variables.
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MvcFactoryInterface $factory The factory.
* @param CmsApplication $app The JApplication for the dispatcher
* @param \JInput $input Input
*
* @since 3.7.0
* @since 3.0
*/
public function __construct($config = array())
public function __construct($config = array(), MvcFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config);
parent::__construct($config, $factory, $app, $input);

$this->internalContext = JFactory::getApplication()->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD');
$parts = FieldsHelper::extract($this->internalContext);
$this->internalContext = \JFactory::getApplication()->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD');
$parts = \FieldsHelper::extract($this->internalContext);
$this->component = $parts ? $parts[0] : null;
}

Expand All @@ -55,12 +65,12 @@ public function __construct($config = array())
*/
public function storeform()
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));

$app = JFactory::getApplication();
$app = \JFactory::getApplication();
$data = $this->input->get($this->input->get('formcontrol', 'jform'), array(), 'array');

$parts = FieldsHelper::extract($this->input->getCmd('context'));
$parts = \FieldsHelper::extract($this->input->getCmd('context'));

if ($parts)
{
Expand All @@ -75,7 +85,7 @@ public function storeform()
$redirectUrl = base64_decode($this->input->get->getBase64('return'));

// Don't redirect to an external URL.
If (!JUri::isInternal($redirectUrl))
If (!\JUri::isInternal($redirectUrl))
{
$redirectUrl = 'index.php';
}
Expand All @@ -95,7 +105,7 @@ public function storeform()
*/
protected function allowAdd($data = array())
{
return JFactory::getUser()->authorise('core.create', $this->component);
return \JFactory::getUser()->authorise('core.create', $this->component);
}

/**
Expand All @@ -111,7 +121,7 @@ protected function allowAdd($data = array())
protected function allowEdit($data = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
$user = \JFactory::getUser();

// Check general edit permission first.
if ($user->authorise('core.edit', $this->component))
Expand Down Expand Up @@ -154,7 +164,7 @@ protected function allowEdit($data = array(), $key = 'id')
*/
public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));

// Set the model
$model = $this->getModel('Field');
Expand Down Expand Up @@ -195,14 +205,14 @@ protected function getRedirectToListAppend()
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
* @param Model $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 3.7.0
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
protected function postSaveHook(Model $model, $validData = array())
{
$item = $model->getItem();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Fields\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Controller\Admin;

/**
* Fields list controller class.
*
* @since 3.7.0
*/
class FieldsControllerFields extends JControllerAdmin
class Fields extends Admin
{
/**
* The prefix to use with controller messages.
Expand All @@ -27,15 +31,15 @@ class FieldsControllerFields extends JControllerAdmin
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config The array of possible config values. Optional.
* @param string $name The name of the model.
* @param string $prefix The prefix for the PHP class name.
* @param array $config Array of configuration parameters.
*
* @return FieldsModelField|boolean
* @return \Joomla\CMS\Model\Model
*
* @since 3.7.0
* @since 1.6
*/
public function getModel($name = 'Field', $prefix = 'FieldsModel', $config = array('ignore_request' => true))
public function getModel($name = 'Field', $prefix = 'Administrator', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Fields\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Controller\Form;
use Joomla\CMS\Model\Model;
use Joomla\CMS\Mvc\Factory\MvcFactoryInterface;
use Joomla\Registry\Registry;

/**
* The Group controller
*
* @since 3.7.0
*/
class FieldsControllerGroup extends JControllerForm
class Group extends Form
{
/**
* The prefix to use with controller messages.
Expand All @@ -35,17 +40,22 @@ class FieldsControllerGroup extends JControllerForm
private $component = '';

/**
* Class constructor.
* Constructor.
*
* @param array $config A named array of configuration variables.
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MvcFactoryInterface $factory The factory.
* @param CmsApplication $app The JApplication for the dispatcher
* @param \JInput $input Input
*
* @since 3.7.0
* @since 3.0
*/
public function __construct($config = array())
public function __construct($config = array(), MvcFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config);
parent::__construct($config, $factory, $app, $input);

$parts = FieldsHelper::extract($this->input->getCmd('context'));
$parts = \FieldsHelper::extract($this->input->getCmd('context'));

if ($parts)
{
Expand All @@ -64,7 +74,7 @@ public function __construct($config = array())
*/
public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
\JSession::checkToken() or jexit(\JText::_('JINVALID_TOKEN'));

// Set the model
$model = $this->getModel('Group');
Expand All @@ -86,7 +96,7 @@ public function batch($model = null)
*/
protected function allowAdd($data = array())
{
return JFactory::getUser()->authorise('core.create', $this->component);
return \JFactory::getUser()->authorise('core.create', $this->component);
}

/**
Expand All @@ -102,7 +112,7 @@ protected function allowAdd($data = array())
protected function allowEdit($data = array(), $key = 'parent_id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
$user = \JFactory::getUser();

// Check general edit permission first.
if ($user->authorise('core.edit', $this->component))
Expand Down Expand Up @@ -137,14 +147,14 @@ protected function allowEdit($data = array(), $key = 'parent_id')
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
* @param Model $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 3.7.0
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
protected function postSaveHook(Model $model, $validData = array())
{
$item = $model->getItem();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Fields\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Controller\Admin;

/**
* Groups list controller class.
*
* @since 3.7.0
*/
class FieldsControllerGroups extends JControllerAdmin
class Groups extends Admin
{
/**
* The prefix to use with controller messages.
Expand All @@ -27,15 +31,15 @@ class FieldsControllerGroups extends JControllerAdmin
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config The array of possible config values. Optional.
* @param string $name The name of the model.
* @param string $prefix The prefix for the PHP class name.
* @param array $config Array of configuration parameters.
*
* @return JModelLegacy|boolean Model object on success; otherwise false on failure.
* @return \Joomla\CMS\Model\Model
*
* @since 3.7.0
* @since 1.6
*/
public function getModel($name = 'Group', $prefix = 'FieldsModel', $config = array('ignore_request' => true))
public function getModel($name = 'Group', $prefix = 'Administrator', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
Expand Down

0 comments on commit cb7e5a2

Please sign in to comment.