Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions code/admin/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@

// No direct access.
defined('_JEXEC') or die();
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;

// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_api'))
if (!Factory::getUser()->authorise('core.manage', 'com_api'))
{
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'));
}

require_once JPATH_SITE . '/components/com_api/defines.php';

// Include dependancies
jimport('joomla.application.component.controller');

$controller = JControllerLegacy::getInstance('Api');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller = BaseController::getInstance('Api');
$controller->execute(Factory::getApplication()->input->get('task'));
$controller->redirect();
12 changes: 8 additions & 4 deletions code/admin/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
// No direct access
defined('_JEXEC') or die();

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Factory;

/**
* API Controller class
*
* @since 1.0
*/
class ApiController extends JControllerLegacy
class ApiController extends BaseController
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link InputFilter::clean()}.
*
* @return JController This object to support chaining.
*
Expand All @@ -30,8 +34,8 @@ public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/api.php';

$view = JFactory::getApplication()->input->getCmd('view', 'keys');
JFactory::getApplication()->input->set('view', $view);
$view = Factory::getApplication()->input->getCmd('view', 'keys');
Factory::getApplication()->input->set('view', $view);

parent::display($cachable, $urlparams);

Expand Down
7 changes: 4 additions & 3 deletions code/admin/controllers/key.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
// No direct access
defined('_JEXEC') or die();

jimport('joomla.application.component.controllerform');
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Controller\BaseController;

/**
* Key controller class.
*
* @since 1.0
*/
class ApiControllerKey extends JControllerForm
class ApiControllerKey extends FormController
{
/**
* Constructor.
*
* @see \JControllerLegacy
* @see \BaseController
* @since 1.6
* @throws \Exception
*/
Expand Down
12 changes: 7 additions & 5 deletions code/admin/controllers/keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@
// No direct access.
defined('_JEXEC') or die();

jimport('joomla.application.component.controlleradmin');
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Factory;

/**
* Keys list controller class.
*
* @since 1.0
*/
class ApiControllerKeys extends JControllerAdmin
class ApiControllerKeys extends AdminController
{
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
*
* @return \JModelLegacy|boolean Model object on success; otherwise false on failure.
* @return \BaseDatabaseModel|boolean Model object on success; otherwise false on failure.
*
* @since 3.0
*/
Expand All @@ -45,7 +47,7 @@ public function getModel($name = 'key', $prefix = 'ApiModel')
public function saveOrderAjax()
{
// Get the input
$input = JFactory::getApplication()->input;
$input = Factory::getApplication()->input;
$pks = $input->post->get('cid', array(), 'array');
$order = $input->post->get('order', array(), 'array');

Expand All @@ -65,6 +67,6 @@ public function saveOrderAjax()
}

// Close the application
JFactory::getApplication()->close();
Factory::getApplication()->close();
}
}
7 changes: 4 additions & 3 deletions code/admin/controllers/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
// No direct access.
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controlleradmin');
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;

/**
* Logs list controller class.
*
* @since 1.0
*/
class ApiControllerLogs extends JControllerAdmin
class ApiControllerLogs extends AdminController
{
/**
* Method to get a model object, loading it if required.
Expand All @@ -27,7 +28,7 @@ class ApiControllerLogs extends JControllerAdmin
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return \JModelLegacy|boolean Model object on success; otherwise false on failure.
* @return \BaseDatabaseModel|boolean Model object on success; otherwise false on failure.
*
* @since 3.0
*/
Expand Down
34 changes: 21 additions & 13 deletions code/admin/helpers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
// No direct access.
defined('_JEXEC') or die();

use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Factory;

/**
* Content component helper.
*
Expand All @@ -27,31 +32,34 @@ class ApiHelper
*/
public static function addSubmenu($vName = '')
{
$submenus = array();
$submenus[] = array(
'title' => JText::_('COM_API_TITLE_KEYS'), 'link' => 'index.php?option=com_api&view=keys', 'view' => $vName == 'keys'
);
$submenus[] = array(
'title' => JText::_('COM_API_TITLE_LOGS'), 'link' => 'index.php?option=com_api&view=logs', 'view' => $vName == 'logs'
);

foreach ($submenus as $submenu)
if (JVERSION < '4.0.0')
{
JHtmlSidebar::addEntry($submenu['title'], $submenu['link'], $submenu['view']);
$submenus = array();
$submenus[] = array(
'title' => Text::_('COM_API_TITLE_KEYS'), 'link' => 'index.php?option=com_api&view=keys', 'view' => $vName == 'keys'
);
$submenus[] = array(
'title' => Text::_('COM_API_TITLE_LOGS'), 'link' => 'index.php?option=com_api&view=logs', 'view' => $vName == 'logs'
);

foreach ($submenus as $submenu)
{
JHtmlSidebar::addEntry($submenu['title'], $submenu['link'], $submenu['view']);
}
}
}

/**
* Gets a list of the actions that can be performed.
*
* @return JObject
* @return CMSObject
*
* @since 1.0
*/
public static function getActions()
{
$user = JFactory::getUser();
$result = new JObject;
$user = Factory::getUser();
$result = new CMSObject;

$assetName = 'com_api';

Expand Down
7 changes: 4 additions & 3 deletions code/admin/models/fields/createdby.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

defined('JPATH_BASE') or die();

jimport('joomla.form.formfield');
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;

/**
* Abstract Form Field class
Expand Down Expand Up @@ -42,11 +43,11 @@ protected function getInput()

if ($userId)
{
$user = JFactory::getUser($userId);
$user = Factory::getUser($userId);
}
else
{
$user = JFactory::getUser();
$user = Factory::getUser();
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $user->id . '" />';
}

Expand Down
17 changes: 10 additions & 7 deletions code/admin/models/key.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
// No direct access.
defined('_JEXEC') or die();

jimport('joomla.application.component.modeladmin');
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Factory;

/**
* Api model.
*
* @since 1.0
*/
class ApiModelKey extends JModelAdmin
class ApiModelKey extends AdminModel
{
/**
* The prefix to use with controller messages.
Expand All @@ -33,14 +36,14 @@ class ApiModelKey extends JModelAdmin
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return \JTable A \JTable object
* @return \Table A \Table object
*
* @since 3.0
* @throws \Exception
*/
public function getTable($type = 'Key', $prefix = 'ApiTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
return Table::getInstance($type, $prefix, $config);
}

/**
Expand All @@ -49,14 +52,14 @@ public function getTable($type = 'Key', $prefix = 'ApiTable', $config = array())
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return \JForm|boolean A \JForm object on success, false on failure
* @return \Form|boolean A \Form object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Initialise variables.
$app = JFactory::getApplication();
$app = Factory::getApplication();

// Get the form.
$form = $this->loadForm('com_api.key', 'key', array('control' => 'jform', 'load_data' => $loadData));
Expand All @@ -79,7 +82,7 @@ public function getForm($data = array(), $loadData = true)
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_api.edit.key.data', array());
$data = Factory::getApplication()->getUserState('com_api.edit.key.data', array());

if (empty($data))
{
Expand Down
13 changes: 8 additions & 5 deletions code/admin/models/keys.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
// No direct access.
defined('_JEXEC') or die();

jimport('joomla.application.component.modellist');
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Data\DataObject;

/**
* Methods supporting a list of keys records.
*
* @since 1.0
*/
class ApiModelKeys extends JModelList
class ApiModelKeys extends ListModel
{
/**
* Constructor.
Expand Down Expand Up @@ -54,7 +57,7 @@ public function __construct($config = array())
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
$app = JFactory::getApplication('administrator');
$app = Factory::getApplication('administrator');

// Load the filter state.
$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
Expand All @@ -64,7 +67,7 @@ protected function populateState($ordering = null, $direction = null)
$this->setState('filter.state', $state);

// Load the parameters.
$params = JComponentHelper::getParams('com_api');
$params = ComponentHelper::getParams('com_api');
$this->setState('params', $params);

// List state information.
Expand Down Expand Up @@ -96,7 +99,7 @@ protected function getStoreId($id = '')
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
* @return DataObjectbaseQuery
*
* @since 1.6
*/
Expand Down
Loading