Skip to content

Commit 39deabd

Browse files
Merge pull request #138 from techjoomla/j4x
J4x
2 parents ce1f87e + 6eaa946 commit 39deabd

57 files changed

Lines changed: 695 additions & 460 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/version.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"com_api": {
3+
"3.0.0": {
4+
"com_api": {
5+
"version": "3.0.0",
6+
"repoUrl": "git@github.com:techjoomla/com_api.git",
7+
"branch": "j4x"
8+
}
9+
},
310
"2.5.2": {
411
"com_api": {
512
"version": "2.5.2",

code/admin/api.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88

99
// No direct access.
1010
defined('_JEXEC') or die();
11+
use Joomla\CMS\Factory;
12+
use Joomla\CMS\Language\Text;
13+
use Joomla\CMS\MVC\Controller\BaseController;
1114

1215
// Access check.
13-
if (!JFactory::getUser()->authorise('core.manage', 'com_api'))
16+
if (!Factory::getUser()->authorise('core.manage', 'com_api'))
1417
{
15-
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
18+
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'));
1619
}
1720

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

2023
// Include dependancies
21-
jimport('joomla.application.component.controller');
2224

23-
$controller = JControllerLegacy::getInstance('Api');
24-
$controller->execute(JFactory::getApplication()->input->get('task'));
25+
$controller = BaseController::getInstance('Api');
26+
$controller->execute(Factory::getApplication()->input->get('task'));
2527
$controller->redirect();

code/admin/controller.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
// No direct access
1010
defined('_JEXEC') or die();
1111

12+
use Joomla\CMS\MVC\Controller\BaseController;
13+
use Joomla\CMS\Filter\InputFilter;
14+
use Joomla\CMS\Factory;
15+
1216
/**
1317
* API Controller class
1418
*
1519
* @since 1.0
1620
*/
17-
class ApiController extends JControllerLegacy
21+
class ApiController extends BaseController
1822
{
1923
/**
2024
* Method to display a view.
2125
*
2226
* @param boolean $cachable If true, the view output will be cached
23-
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
27+
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link InputFilter::clean()}.
2428
*
2529
* @return JController This object to support chaining.
2630
*
@@ -30,8 +34,8 @@ public function display($cachable = false, $urlparams = false)
3034
{
3135
require_once JPATH_COMPONENT . '/helpers/api.php';
3236

33-
$view = JFactory::getApplication()->input->getCmd('view', 'keys');
34-
JFactory::getApplication()->input->set('view', $view);
37+
$view = Factory::getApplication()->input->getCmd('view', 'keys');
38+
Factory::getApplication()->input->set('view', $view);
3539

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

code/admin/controllers/key.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99
// No direct access
1010
defined('_JEXEC') or die();
1111

12-
jimport('joomla.application.component.controllerform');
12+
use Joomla\CMS\MVC\Controller\FormController;
13+
use Joomla\CMS\MVC\Controller\BaseController;
1314

1415
/**
1516
* Key controller class.
1617
*
1718
* @since 1.0
1819
*/
19-
class ApiControllerKey extends JControllerForm
20+
class ApiControllerKey extends FormController
2021
{
2122
/**
2223
* Constructor.
2324
*
24-
* @see \JControllerLegacy
25+
* @see \BaseController
2526
* @since 1.6
2627
* @throws \Exception
2728
*/

code/admin/controllers/keys.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@
99
// No direct access.
1010
defined('_JEXEC') or die();
1111

12-
jimport('joomla.application.component.controlleradmin');
12+
use Joomla\CMS\MVC\Controller\AdminController;
13+
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
14+
use Joomla\CMS\Factory;
1315

1416
/**
1517
* Keys list controller class.
1618
*
1719
* @since 1.0
1820
*/
19-
class ApiControllerKeys extends JControllerAdmin
21+
class ApiControllerKeys extends AdminController
2022
{
2123
/**
2224
* Method to get a model object, loading it if required.
2325
*
2426
* @param string $name The model name. Optional.
2527
* @param string $prefix The class prefix. Optional.
2628
*
27-
* @return \JModelLegacy|boolean Model object on success; otherwise false on failure.
29+
* @return \BaseDatabaseModel|boolean Model object on success; otherwise false on failure.
2830
*
2931
* @since 3.0
3032
*/
@@ -45,7 +47,7 @@ public function getModel($name = 'key', $prefix = 'ApiModel')
4547
public function saveOrderAjax()
4648
{
4749
// Get the input
48-
$input = JFactory::getApplication()->input;
50+
$input = Factory::getApplication()->input;
4951
$pks = $input->post->get('cid', array(), 'array');
5052
$order = $input->post->get('order', array(), 'array');
5153

@@ -65,6 +67,6 @@ public function saveOrderAjax()
6567
}
6668

6769
// Close the application
68-
JFactory::getApplication()->close();
70+
Factory::getApplication()->close();
6971
}
7072
}

code/admin/controllers/logs.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
// No direct access.
1212
defined('_JEXEC') or die('Restricted access');
1313

14-
jimport('joomla.application.component.controlleradmin');
14+
use Joomla\CMS\MVC\Controller\AdminController;
15+
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
1516

1617
/**
1718
* Logs list controller class.
1819
*
1920
* @since 1.0
2021
*/
21-
class ApiControllerLogs extends JControllerAdmin
22+
class ApiControllerLogs extends AdminController
2223
{
2324
/**
2425
* Method to get a model object, loading it if required.
@@ -27,7 +28,7 @@ class ApiControllerLogs extends JControllerAdmin
2728
* @param string $prefix The class prefix. Optional.
2829
* @param array $config Configuration array for model. Optional.
2930
*
30-
* @return \JModelLegacy|boolean Model object on success; otherwise false on failure.
31+
* @return \BaseDatabaseModel|boolean Model object on success; otherwise false on failure.
3132
*
3233
* @since 3.0
3334
*/

code/admin/helpers/api.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
// No direct access.
1010
defined('_JEXEC') or die();
1111

12+
use Joomla\CMS\Language\Text;
13+
use Joomla\CMS\HTML\HTMLHelper;
14+
use Joomla\CMS\Object\CMSObject;
15+
use Joomla\CMS\Factory;
16+
1217
/**
1318
* Content component helper.
1419
*
@@ -27,31 +32,34 @@ class ApiHelper
2732
*/
2833
public static function addSubmenu($vName = '')
2934
{
30-
$submenus = array();
31-
$submenus[] = array(
32-
'title' => JText::_('COM_API_TITLE_KEYS'), 'link' => 'index.php?option=com_api&view=keys', 'view' => $vName == 'keys'
33-
);
34-
$submenus[] = array(
35-
'title' => JText::_('COM_API_TITLE_LOGS'), 'link' => 'index.php?option=com_api&view=logs', 'view' => $vName == 'logs'
36-
);
37-
38-
foreach ($submenus as $submenu)
35+
if (JVERSION < '4.0.0')
3936
{
40-
JHtmlSidebar::addEntry($submenu['title'], $submenu['link'], $submenu['view']);
37+
$submenus = array();
38+
$submenus[] = array(
39+
'title' => Text::_('COM_API_TITLE_KEYS'), 'link' => 'index.php?option=com_api&view=keys', 'view' => $vName == 'keys'
40+
);
41+
$submenus[] = array(
42+
'title' => Text::_('COM_API_TITLE_LOGS'), 'link' => 'index.php?option=com_api&view=logs', 'view' => $vName == 'logs'
43+
);
44+
45+
foreach ($submenus as $submenu)
46+
{
47+
JHtmlSidebar::addEntry($submenu['title'], $submenu['link'], $submenu['view']);
48+
}
4149
}
4250
}
4351

4452
/**
4553
* Gets a list of the actions that can be performed.
4654
*
47-
* @return JObject
55+
* @return CMSObject
4856
*
4957
* @since 1.0
5058
*/
5159
public static function getActions()
5260
{
53-
$user = JFactory::getUser();
54-
$result = new JObject;
61+
$user = Factory::getUser();
62+
$result = new CMSObject;
5563

5664
$assetName = 'com_api';
5765

code/admin/models/fields/createdby.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
defined('JPATH_BASE') or die();
1010

11-
jimport('joomla.form.formfield');
11+
use Joomla\CMS\Form\FormField;
12+
use Joomla\CMS\Factory;
1213

1314
/**
1415
* Abstract Form Field class
@@ -42,11 +43,11 @@ protected function getInput()
4243

4344
if ($userId)
4445
{
45-
$user = JFactory::getUser($userId);
46+
$user = Factory::getUser($userId);
4647
}
4748
else
4849
{
49-
$user = JFactory::getUser();
50+
$user = Factory::getUser();
5051
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . $user->id . '" />';
5152
}
5253

code/admin/models/key.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
// No direct access.
1010
defined('_JEXEC') or die();
1111

12-
jimport('joomla.application.component.modeladmin');
12+
use Joomla\CMS\MVC\Model\AdminModel;
13+
use Joomla\CMS\Table\Table;
14+
use Joomla\CMS\Form\Form;
15+
use Joomla\CMS\Factory;
1316

1417
/**
1518
* Api model.
1619
*
1720
* @since 1.0
1821
*/
19-
class ApiModelKey extends JModelAdmin
22+
class ApiModelKey extends AdminModel
2023
{
2124
/**
2225
* The prefix to use with controller messages.
@@ -33,14 +36,14 @@ class ApiModelKey extends JModelAdmin
3336
* @param string $prefix The class prefix. Optional.
3437
* @param array $config Configuration array for model. Optional.
3538
*
36-
* @return \JTable A \JTable object
39+
* @return \Table A \Table object
3740
*
3841
* @since 3.0
3942
* @throws \Exception
4043
*/
4144
public function getTable($type = 'Key', $prefix = 'ApiTable', $config = array())
4245
{
43-
return JTable::getInstance($type, $prefix, $config);
46+
return Table::getInstance($type, $prefix, $config);
4447
}
4548

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

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

8487
if (empty($data))
8588
{

code/admin/models/keys.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
// No direct access.
1010
defined('_JEXEC') or die();
1111

12-
jimport('joomla.application.component.modellist');
12+
use Joomla\CMS\MVC\Model\ListModel;
13+
use Joomla\CMS\Factory;
14+
use Joomla\CMS\Component\ComponentHelper;
15+
use Joomla\Data\DataObject;
1316

1417
/**
1518
* Methods supporting a list of keys records.
1619
*
1720
* @since 1.0
1821
*/
19-
class ApiModelKeys extends JModelList
22+
class ApiModelKeys extends ListModel
2023
{
2124
/**
2225
* Constructor.
@@ -54,7 +57,7 @@ public function __construct($config = array())
5457
protected function populateState($ordering = null, $direction = null)
5558
{
5659
// Initialise variables.
57-
$app = JFactory::getApplication('administrator');
60+
$app = Factory::getApplication('administrator');
5861

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

6669
// Load the parameters.
67-
$params = JComponentHelper::getParams('com_api');
70+
$params = ComponentHelper::getParams('com_api');
6871
$this->setState('params', $params);
6972

7073
// List state information.
@@ -96,7 +99,7 @@ protected function getStoreId($id = '')
9699
/**
97100
* Build an SQL query to load the list data.
98101
*
99-
* @return JDatabaseQuery
102+
* @return DataObjectbaseQuery
100103
*
101104
* @since 1.6
102105
*/

0 commit comments

Comments
 (0)