@@ -150,7 +155,7 @@ class="input-medium" onchange="Joomla.orderTable()">
items)) : ?>
@@ -158,23 +163,23 @@ class="input-medium" onchange="Joomla.orderTable()">
@@ -182,14 +187,14 @@ class="input-medium" onchange="Joomla.orderTable()">
items as $i => $item) : ?>
|
- id); ?>
+ id); ?>
|
hash; ?>
name) : ?>
name; ?> |
-
+
ip_address; ?>
@@ -217,7 +222,7 @@ class="input-medium" onchange="Joomla.orderTable()">
-
+
diff --git a/code/admin/views/logs/view.html.php b/code/admin/views/logs/view.html.php
index cc2e37a..3b81ad6 100644
--- a/code/admin/views/logs/view.html.php
+++ b/code/admin/views/logs/view.html.php
@@ -9,19 +9,24 @@
// No direct access.
defined('_JEXEC') or die();
-jimport('joomla.application.component.view');
+use Joomla\CMS\MVC\View\HtmlView;
+use Joomla\CMS\Object\CMSObject;
+use Joomla\CMS\Pagination\Pagination;
+use Joomla\CMS\HTML\HTMLHelper;
+use Joomla\CMS\Language\Text;
+
/**
* View class for list of logs
*
* @since 1.0
*/
-class ApiViewLogs extends JViewLegacy
+class ApiViewLogs extends HtmlView
{
/**
* The model state.
*
- * @var JObject
+ * @var CMSObject
* @since 1.0
*/
protected $state;
@@ -37,7 +42,7 @@ class ApiViewLogs extends JViewLegacy
/**
* The pagination object.
*
- * @var JPagination
+ * @var Pagination
* @since 1.0
*/
protected $pagination;
@@ -89,11 +94,11 @@ protected function addToolbar()
if (JVERSION >= '3.0')
{
- JToolBarHelper::title(JText::_('COM_API_TITLE_LOGS'), 'list');
+ JToolBarHelper::title(Text::_('COM_API_TITLE_LOGS'), 'list');
}
else
{
- JToolBarHelper::title(JText::_('COM_API_TITLE_LOGS'), 'logs.png');
+ JToolBarHelper::title(Text::_('COM_API_TITLE_LOGS'), 'logs.png');
}
if ($canDo->get('core.edit.state'))
@@ -141,11 +146,11 @@ protected function addToolbar()
protected function getSortFields()
{
return array(
- 'u.name' => JText::_('COM_API_LOGS_USER'),
- 'a.hash' => JText::_('COM_API_KEYS_HASH'),
- 'a.ip_address' => JText::_('COM_API_LOGS_IP_ADDRESS'),
- 'a.time' => JText::_('COM_API_LOGS_TIME'),
- 'a.request_method' => JText::_('COM_API_LOGS_REQUEST_METHOD')
+ 'u.name' => Text::_('COM_API_LOGS_USER'),
+ 'a.hash' => Text::_('COM_API_KEYS_HASH'),
+ 'a.ip_address' => Text::_('COM_API_LOGS_IP_ADDRESS'),
+ 'a.time' => Text::_('COM_API_LOGS_TIME'),
+ 'a.request_method' => Text::_('COM_API_LOGS_REQUEST_METHOD')
);
}
}
diff --git a/code/api.xml b/code/api.xml
index 8242ae5..6023500 100644
--- a/code/api.xml
+++ b/code/api.xml
@@ -1,13 +1,13 @@
com_api
- 22nd Oct 2019
+ 13th Jul 2022
Copyright (C) 2009 - 2019 Techjoomla. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
Techjoomla
extensions@techjoomla.com
https://techjoomla.com
- 2.5.1
+ 3.0.0
Multi-purpose REST API framework for Joomla
diff --git a/code/plugins/authentication/tjapi/tjapi.php b/code/plugins/authentication/tjapi/tjapi.php
index 10673f1..95a2c0a 100644
--- a/code/plugins/authentication/tjapi/tjapi.php
+++ b/code/plugins/authentication/tjapi/tjapi.php
@@ -9,12 +9,18 @@
defined('_JEXEC') or die('Unauthorized Access');
+use Joomla\CMS\Plugin\CMSPlugin;
+use Joomla\CMS\Table\Table;
+use Joomla\CMS\Authentication\Authentication;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\User\User;
+
/**
* Class for Tjapi Authentication Plugin
*
* @since 1.0.0
*/
-class PlgAuthenticationTjapi extends JPlugin
+class PlgAuthenticationTjapi extends CMSPlugin
{
/**
* Verify Api Key
@@ -27,8 +33,8 @@ class PlgAuthenticationTjapi extends JPlugin
public function verifyApiKey($userId, $key)
{
// Load table
- JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_api/tables');
- $table = JTable::getInstance('Key', 'ApiTable');
+ Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_api/tables');
+ $table = Table::getInstance('Key', 'ApiTable');
$table->load(array('userid' => $userId));
if ($key == $table->hash)
@@ -59,8 +65,8 @@ public function onUserAuthenticate(&$credentials, $options, &$response)
if (empty($uid) || empty($key))
{
- $response->status = JAuthentication::STATUS_FAILURE;
- $response->error_message = JText::_('JGLOBAL_AUTH_NO_USER');
+ $response->status = Authentication::STATUS_FAILURE;
+ $response->error_message = Text::_('JGLOBAL_AUTH_NO_USER');
}
else
{
@@ -70,7 +76,7 @@ public function onUserAuthenticate(&$credentials, $options, &$response)
if ($match === true)
{
// Bring this in line with the rest of the authentication
- $user = JUser::getInstance($uid);
+ $user = User::getInstance($uid);
// Set response data.
$response->username = $user->username;
@@ -79,14 +85,14 @@ public function onUserAuthenticate(&$credentials, $options, &$response)
$response->password = $user->password;
$response->language = $user->getParam('language');
- $response->status = JAuthentication::STATUS_SUCCESS;
+ $response->status = Authentication::STATUS_SUCCESS;
$response->error_message = '';
}
else
{
// Invalid password
- $response->status = JAuthentication::STATUS_FAILURE;
- $response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS');
+ $response->status = Authentication::STATUS_FAILURE;
+ $response->error_message = Text::_('JGLOBAL_AUTH_INVALID_PASS');
}
}
diff --git a/code/plugins/authentication/tjapi/tjapi.xml b/code/plugins/authentication/tjapi/tjapi.xml
index 070c808..36e8d78 100644
--- a/code/plugins/authentication/tjapi/tjapi.xml
+++ b/code/plugins/authentication/tjapi/tjapi.xml
@@ -5,10 +5,10 @@
Techjoomla
extensions@techjoomla.com
https://techjoomla.com
- 22nd Oct 2019
+ 13th Jul 2022
Copyright (C) 2009 - 2019 Techjoomla. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- 2.5.1
+ 3.0.0
tjapi.php
diff --git a/code/plugins/system/tjtokenlogin/tjtokenlogin.php b/code/plugins/system/tjtokenlogin/tjtokenlogin.php
index 39ff3a1..96a7d75 100644
--- a/code/plugins/system/tjtokenlogin/tjtokenlogin.php
+++ b/code/plugins/system/tjtokenlogin/tjtokenlogin.php
@@ -9,12 +9,17 @@
defined('_JEXEC') or die('Unauthorized Access');
-jimport('joomla.filesystem.file');
+use Joomla\CMS\Filesystem\File;
+use Joomla\CMS\Plugin\CMSPlugin;
+use Joomla\CMS\Application\CMSApplication;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Table\Table;
+use Joomla\CMS\Router\Route;
$jwtBasePath = JPATH_SITE . '/components/com_api/vendors/php-jwt/src';
$jwtFilePath = $jwtBasePath . '/JWT.php';
-if (!JFile::exists($jwtFilePath))
+if (!File::exists($jwtFilePath))
{
return;
}
@@ -36,12 +41,12 @@
*
* @since 1.0.0
*/
-class PlgSystemTjtokenlogin extends JPlugin
+class PlgSystemTjtokenlogin extends CMSPlugin
{
/**
* Application object.
*
- * @var JApplicationCms
+ * @var CMSApplication
* @since 1.0.0
*/
protected $app;
@@ -60,7 +65,7 @@ public function onAfterInitialise()
// Get the application if not done by JPlugin. This may happen during upgrades from Joomla 2.5.
if (!$this->app)
{
- $this->app = JFactory::getApplication();
+ $this->app = Factory::getApplication();
}
// No remember me for admin.
@@ -70,7 +75,7 @@ public function onAfterInitialise()
}
// Get logintoken
- $input = JFactory::getApplication()->input;
+ $input = Factory::getApplication()->input;
$loginToken = $input->get->get('logintoken', '', 'STRING');
// If loginToken is not set, return
@@ -99,8 +104,8 @@ public function onAfterInitialise()
}
// Load api key table
- JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_api/tables');
- $table = JTable::getInstance('Key', 'ApiTable');
+ Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_api/tables');
+ $table = Table::getInstance('Key', 'ApiTable');
$table->load(array('userid' => $payload->id));
$key = $table->hash;
@@ -129,7 +134,7 @@ public function onAfterInitialise()
$redirect = $input->get->get('redirect', '', 'STRING');
$redirect = base64_decode($redirect);
- $this->app->redirect(JRoute::_($redirect, false));
+ $this->app->redirect(Route::_($redirect, false));
// }
}
diff --git a/code/plugins/system/tjtokenlogin/tjtokenlogin.xml b/code/plugins/system/tjtokenlogin/tjtokenlogin.xml
index 0cd6028..4ea9f80 100644
--- a/code/plugins/system/tjtokenlogin/tjtokenlogin.xml
+++ b/code/plugins/system/tjtokenlogin/tjtokenlogin.xml
@@ -5,10 +5,10 @@
Techjoomla
extensions@techjoomla.com
https://techjoomla.com
- 22nd Oct 2019
+ 13th Jul 2022
Copyright (C) 2009 - 2019 Techjoomla. All rights reserved.
http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- 2.5.1
+ 3.0.0
tjtokenlogin.php
diff --git a/code/script.api.php b/code/script.api.php
index cc56322..107470b 100644
--- a/code/script.api.php
+++ b/code/script.api.php
@@ -11,9 +11,11 @@
// No direct access.
defined('_JEXEC') or die('Restricted access');
-jimport('joomla.filesystem.folder');
-jimport('joomla.filesystem.file');
-jimport('joomla.application.component.controller');
+use Joomla\CMS\Installer\Installer;
+use Joomla\CMS\Object\CMSObject;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Filesystem\File;
+use Joomla\CMS\Filesystem\Folder;
if (! defined('DS'))
{
@@ -91,7 +93,7 @@ public function preflight($type, $parent)
* Runs after install, update or discover_update
*
* @param string $type install, update or discover_update
- * @param JInstaller $parent parent
+ * @param Installer $parent parent
*
* @return mixed
*
@@ -121,7 +123,7 @@ public function install($parent)
/**
* Runs on uninstallation
*
- * @param JInstaller $parent parent
+ * @param Installer $parent parent
*
* @return mixed
*
@@ -159,9 +161,9 @@ private function renderPostInstallation()
/**
* Installs subextensions (modules, plugins) bundled with the main extension
*
- * @param JInstaller $parent parent
+ * @param Installer $parent parent
*
- * @return JObject The subextension installation status
+ * @return CMSObject The subextension installation status
*
* @since 1.0.0
*/
@@ -169,9 +171,9 @@ private function installSubextensions($parent)
{
$src = $parent->getParent()->getPath('source');
- $db = JFactory::getDbo();
+ $db = Factory::getDbo();
- $status = new JObject;
+ $status = new CMSObject;
$status->modules = array();
$status->plugins = array();
@@ -224,7 +226,7 @@ private function installSubextensions($parent)
$db->setQuery($sql);
$count = $db->loadResult();
- $installer = new JInstaller;
+ $installer = new Installer;
$result = $installer->install($path);
$status->modules[] = array(
'name' => $module, 'client' => $folder, 'result' => $result, 'status' => $modulePreferences[1]
@@ -345,7 +347,7 @@ private function installSubextensions($parent)
$db->setQuery($query);
$count = $db->loadResult();
- $installer = new JInstaller;
+ $installer = new Installer;
$result = $installer->install($path);
$status->plugins[] = array(
@@ -384,7 +386,7 @@ private function installSubextensions($parent)
$db->setQuery($query);
$count = $db->loadResult();
- $installer = new JInstaller;
+ $installer = new Installer;
$result = $installer->install($path);
$status->libraries[] = array(
@@ -424,12 +426,12 @@ protected function removeFilesAndFolders($removeList)
{
$file = JPATH_ROOT . '/' . $file;
- if (!JFile::exists($file))
+ if (!File::exists($file))
{
continue;
}
- JFile::delete($file);
+ File::delete($file);
}
}
@@ -439,12 +441,12 @@ protected function removeFilesAndFolders($removeList)
{
$folder = JPATH_ROOT . '/' . $folder;
- if (!JFolder::exists($folder))
+ if (!Folder::exists($folder))
{
continue;
}
- JFolder::delete($folder);
+ Folder::delete($folder);
}
}
}
diff --git a/code/site/api.php b/code/site/api.php
index e00504c..9cb22b2 100755
--- a/code/site/api.php
+++ b/code/site/api.php
@@ -11,7 +11,9 @@
*/
defined('_JEXEC') or die('Restricted access');
-jimport('joomla.application.component.controller');
+use Joomla\CMS\Table\Table;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
$library_path = JPATH_COMPONENT . '/libraries';
@@ -32,11 +34,11 @@
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_api/tables');
JLoader::discover('API', JPATH_COMPONENT . '/libraries/exceptions');
-$app = JFactory::getApplication();
+$app = Factory::getApplication();
$view = $app->input->get('view', '', 'CMD');
-if ($view)
+if (in_array($view, array("api", "applogin", "documentation")))
{
$c = $view;
}
@@ -55,7 +57,7 @@
else
{
// JError::raiseError(404, JText::_('COM_API_CONTROLLER_NOT_FOUND'));
- throw new Exception(JText::_('COM_API_CONTROLLER_NOT_FOUND'), 404);
+ throw new Exception(Text::_('COM_API_CONTROLLER_NOT_FOUND'), 404);
}
$command = $app->input->get('task', 'display', 'CMD');
diff --git a/code/site/controllers/applogin.php b/code/site/controllers/applogin.php
index e4dce70..803b353 100644
--- a/code/site/controllers/applogin.php
+++ b/code/site/controllers/applogin.php
@@ -10,6 +10,9 @@
defined('_JEXEC') or die('Restricted access');
+use Joomla\CMS\Filter\InputFilter;
+use Joomla\CMS\MVC\Controller\BaseController;
+
/**
* Class for a Applogin Controller
*
@@ -24,9 +27,9 @@ class ApiControllerApplogin extends ApiController
* you will need to override it in your own controllers.
*
* @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 \JControllerLegacy A \JControllerLegacy object to support chaining.
+ * @return \BaseController A \BaseController object to support chaining.
*
* @since 3.0
*/
diff --git a/code/site/controllers/documentation.php b/code/site/controllers/documentation.php
index 788beab..4701190 100644
--- a/code/site/controllers/documentation.php
+++ b/code/site/controllers/documentation.php
@@ -10,8 +10,6 @@
defined('_JEXEC') or die( 'Restricted access' );
-jimport('joomla.application.component.controller');
-
class ApiControllerDocumentation extends ApiController {
diff --git a/code/site/controllers/http.php b/code/site/controllers/http.php
index f68c179..5afb853 100644
--- a/code/site/controllers/http.php
+++ b/code/site/controllers/http.php
@@ -11,8 +11,11 @@
*/
defined('_JEXEC') or die('Restricted access');
-jimport('joomla.application.component.controller');
-jimport('joomla.plugin.helper');
+use Joomla\CMS\Filter\InputFilter;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Component\ComponentHelper;
+use Joomla\CMS\Uri\Uri;
+
/**
* ApiControllerHttp class
@@ -27,7 +30,7 @@ class ApiControllerHttp extends ApiController
* Typical view method for MVC based architecture
*
* @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 Mixed
*
@@ -36,15 +39,15 @@ class ApiControllerHttp extends ApiController
public function display($cachable = false, $urlparams = array())
{
$this->resetDocumentType();
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$name = $app->input->get('app', '', 'CMD');
- $params = JComponentHelper::getParams('com_api');
+ $params = ComponentHelper::getParams('com_api');
$callMethod = $app->input->getMethod();
$httpOrigin = $app->input->server->getString('HTTP_REFERER', '');
- $JUriObj = JUri::getInstance($httpOrigin);
- $referer = $JUriObj->toString(array('scheme', 'host', 'port'));
+ $UriObj = Uri::getInstance($httpOrigin);
+ $referer = $UriObj->toString(array('scheme', 'host', 'port'));
// Special method for OPTIONS method
if ((! empty($params->get("allow_cors"))))
@@ -78,14 +81,16 @@ public function display($cachable = false, $urlparams = array())
try
{
- JResponse::setHeader('status', 200);
+ header("status: 200");
+ //JResponse::setHeader('status', 200);
$resource_response = ApiPlugin::getInstance($name)->fetchResource();
echo $this->respond($resource_response);
}
catch (Exception $e)
{
- JResponse::setHeader('status', $e->http_code);
+ header("status: " . $e->http_code);
+ //JResponse::setHeader('status', $e->http_code);
echo $this->respond($e);
}
}
@@ -101,7 +106,7 @@ public function display($cachable = false, $urlparams = array())
*/
private function respond($response)
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$accept = $app->input->server->get('HTTP_ACCEPT', 'application/json', 'STRING');
$compatibility = $app->input->server->get('HTTP_X_COMPATIBILITY_MODE', 0, 'INT');
@@ -170,6 +175,13 @@ private function respond($response)
*/
private function resetDocumentType()
{
- JResponse::clearHeaders();
+ if (!headers_sent())
+ {
+ foreach (headers_list() as $header)
+ {
+ header_remove($header);
+ }
+ }
+ //JResponse::clearHeaders();
}
}
diff --git a/code/site/defines.php b/code/site/defines.php
index e87858c..93af439 100644
--- a/code/site/defines.php
+++ b/code/site/defines.php
@@ -9,11 +9,17 @@
// No direct access.
defined('_JEXEC') or die();
+use Joomla\CMS\HTML\HTMLHelper;
+
// Define wrapper class
define('COM_APIS_WRAPPER_CLASS', "api-wrapper");
-JHtml::_('behavior.tabstate');
-JHtml::_('behavior.tooltip');
-JHtml::_('bootstrap.tooltip');
-JHtml::_('behavior.multiselect');
-JHtml::_('formbehavior.chosen', 'select');
+if (JVERSION < '4.0.0')
+{
+ HTMLHelper::_('formbehavior.chosen', 'select');
+ HTMLHelper::_('behavior.tabstate');
+}
+
+HTMLHelper::_('bootstrap.tooltip');
+HTMLHelper::_('bootstrap.tooltip');
+HTMLHelper::_('behavior.multiselect');
diff --git a/code/site/libraries/admin/controller.php b/code/site/libraries/admin/controller.php
index be65d5a..eefbe5f 100755
--- a/code/site/libraries/admin/controller.php
+++ b/code/site/libraries/admin/controller.php
@@ -10,7 +10,11 @@
defined('_JEXEC') or die( 'Restricted access' );
-jimport('joomla.application.component.controller');
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Session\Session;
+use Joomla\CMS\Table\Table;
+
class ApiControllerAdmin extends ApiController {
@@ -19,11 +23,11 @@ public function __construct($config=array()) {
$this->registerTask('apply', 'save');
$this->registerTask('add', 'edit');
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$default_url = 'index.php?option='.$this->get('option');
- //$view = JRequest::getVar('view','');
+ //$view = Factory::getApplication()->input->get('view','');
$view = $app->input->get('view','','STRING');
$task = $app->input->post->get('task','','STRING');
@@ -39,14 +43,14 @@ public function __construct($config=array()) {
}
public function display() {
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
- //$view = JRequest::getVar('view', '');
+ //$view = Factory::getApplication()->input->get('view', '');
$view = $app->input->get('view','','STRING');
if (!$view) :
- //JRequest::setVar('view', 'cpanel');
+ //Factory::getApplication()->input->set('view', 'cpanel');
$app->input->set('view','cpanel');
endif;
@@ -56,7 +60,7 @@ public function display() {
}
public function edit() {
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$view = $this->getEntityName();
$layout = 'default';
@@ -73,27 +77,27 @@ public function edit() {
public function cancel() {
//JRequest::checkToken() or jexit(JText::_('INVALID_TOKEN'));
- JSession::checkToken() or jexit(JText::_('INVALID_TOKEN'));
- $app = JFactory::getApplication();
- //$this->setRedirect(JRequest::getVar('ret', $this->get('default_url')), $msg);
+ Session::checkToken() or jexit(Text::_('INVALID_TOKEN'));
+ $app = Factory::getApplication();
+ //$this->setRedirect(Factory::getApplication()->input->get('ret', $this->get('default_url')), $msg);
$this->setRedirect($app->input->get('ret', $this->get('default_url'),'STRING'), $msg);
}
public function remove($hash='post') {
- JSession::checkToken($hash) or jexit(JText::_('INVALID_TOKEN'));
- $app = JFactory::getApplication();
+ Session::checkToken($hash) or jexit(Text::_('INVALID_TOKEN'));
+ $app = Factory::getApplication();
$name = $this->getEntityName();
- //$post = JRequest::get('post');
+ //$post = Factory::getApplication()->input->get('post');
$post = $app->input->post;
$model = $this->getModel($name);
- //$cid = JRequest::getVar('cid', array(), $hash, 'array');
+ //$cid = Factory::getApplication()->input->get('cid', array(), $hash, 'array');
$cid = $app->input->post->get('cid',array(), 'ARRAY');
if (empty($cid)) :
- //$cid = JRequest::getVar('id', 0, $hash, 'int');
+ //$cid = Factory::getApplication()->input->get('id', 0, $hash, 'int');
$cid = $app->input->post->get('id', 0,'INT');
endif;
@@ -102,11 +106,11 @@ public function remove($hash='post') {
$msg = $model->getError();
$type = 'error';
else :
- $msg = JText::_('COM_API_DELETE_SUCCESS');
+ $msg = Text::_('COM_API_DELETE_SUCCESS');
$type = 'message';
endif;
else :
- $msg = JText::_('COM_API_NO_SELECTION');
+ $msg = Text::_('COM_API_NO_SELECTION');
$type = 'error';
endif;
@@ -115,9 +119,9 @@ public function remove($hash='post') {
}
public function save() {
- JSession::checkToken() or jexit(JText::_('INVALID_TOKEN'));
+ Session::checkToken() or jexit(Text::_('INVALID_TOKEN'));
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$name = $this->getEntityName();
@@ -139,14 +143,14 @@ public function save() {
if (!$item = $model->save($post)) :
$msg = $model->getError();
- //$url = JRequest::getVar('HTTP_REFERER', $this->get('default_url'), 'server');
+ //$url = Factory::getApplication()->input->get('HTTP_REFERER', $this->get('default_url'), 'server');
$url = $app->input->server->get('HTTP_REFERER', $this->get('default_url'), 'STRING');
$this->setRedirect($url, $msg, 'error');
return;
endif;
$name = strtolower($name);
- $msg = JText::_("COM_API_SAVE_SUCCESSFUL");
+ $msg = Text::_("COM_API_SAVE_SUCCESSFUL");
if($this->getTask() == 'apply') :
$url = "index.php?option=".$this->get('option')."&view=".$name."&cid[]=".$item->id;
elseif (isset($post['ret'])) :
@@ -160,9 +164,9 @@ public function save() {
public function publish() {
//JRequest::checkToken() or jexit(JText::_('INVALID_TOKEN'));
- JSession::checkToken() or jexit(JText::_('INVALID_TOKEN'));
+ Session::checkToken() or jexit(Text::_('INVALID_TOKEN'));
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$this->changeState(1);
@@ -170,7 +174,7 @@ public function publish() {
$msg = $error;
$type = 'error';
else :
- $msg = JText::_("COM_API_PUBLISH_SUCCESS");
+ $msg = Text::_("COM_API_PUBLISH_SUCCESS");
$type = 'message';
endif;
@@ -180,16 +184,16 @@ public function publish() {
public function unpublish() {
//JRequest::checkToken() or jexit(JText::_('INVALID_TOKEN'));
- JSession::checkToken() or jexit(JText::_('INVALID_TOKEN'));
+ Session::checkToken() or jexit(Text::_('INVALID_TOKEN'));
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$this->changeState(0);
if ($error = $this->getError()) :
$msg = $error;
$type = 'error';
else :
- $msg = JText::_("COM_API_UNPUBLISH_SUCCESS");
+ $msg = Text::_("COM_API_UNPUBLISH_SUCCESS");
$type = 'message';
endif;
@@ -198,7 +202,7 @@ public function unpublish() {
protected function changeState($state, $cids=array(), $table_class=null) {
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
if (empty($cids)) :
$cids = $app->input->post->get('cid', array(),'ARRAY');
@@ -206,7 +210,7 @@ protected function changeState($state, $cids=array(), $table_class=null) {
$table_class = $table_class ? $table_class : $this->getEntityName();
- $table = JTable::getInstance($table_class, 'ApiTable');
+ $table = Table::getInstance($table_class, 'ApiTable');
if (!$table->publish($cids, $state)) :
$this->setError($table->getError());
diff --git a/code/site/libraries/authentication.php b/code/site/libraries/authentication.php
index 63805a9..2ed1107 100644
--- a/code/site/libraries/authentication.php
+++ b/code/site/libraries/authentication.php
@@ -9,14 +9,20 @@
*/
defined('_JEXEC') or die;
-jimport('joomla.application.component.model');
+
+use Joomla\CMS\Object\CMSObject;
+use Joomla\CMS\Component\ComponentHelper;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Plugin\PluginHelper;
+use Joomla\CMS\User\User;
/**
* Class for API authetication
*
* @since 1.0
*/
-abstract class ApiAuthentication extends JObject
+abstract class ApiAuthentication extends CMSObject
{
protected $auth_method = null;
@@ -57,8 +63,8 @@ abstract public function authenticate();
*/
public static function authenticateRequest()
{
- $params = JComponentHelper::getParams('com_api');
- $app = JFactory::getApplication();
+ $params = ComponentHelper::getParams('com_api');
+ $app = Factory::getApplication();
$className = 'APIAuthentication' . ucwords(self::getAuthMethod());
@@ -69,34 +75,36 @@ public static function authenticateRequest()
{
self::setAuthError($auth_handler->getError());
- return false;
+ return Factory::getUser();
}
else
{
- $user = JFactory::getUser($user_id);
+ $user = Factory::getUser($user_id);
if (!$user->id)
{
- self::setAuthError(JText::_("COM_API_USER_NOT_FOUND"));
+ self::setAuthError(Text::_("COM_API_USER_NOT_FOUND"));
return false;
}
if ($user->block == 1)
{
- self::setAuthError(JText::_("COM_API_BLOCKED_USER"));
+ self::setAuthError(Text::_("COM_API_BLOCKED_USER"));
return false;
}
/* V1.8.1 - to set admin info headers
- $log_user = JFactory::getUser(); */
+ $log_user = Factory::getUser(); */
$isroot = $user->authorise('core.admin');
if ($isroot)
{
- JResponse::setHeader('x-api', self::getCom_apiVersion());
- JResponse::setHeader('x-plugins', implode(',', self::getPluginsList()));
+ header("x-api: " . self::getCom_apiVersion());
+ header("x-plugins: " . implode(',', self::getPluginsList()));
+ //JResponse::setHeader('x-api', self::getCom_apiVersion());
+ //JResponse::setHeader('x-plugins', implode(',', self::getPluginsList()));
}
return $user;
@@ -145,12 +153,12 @@ public static function getAuthError()
*/
public static function getPluginsList()
{
- $plugins = JPluginHelper::getPlugin('api');
+ $plugins = PluginHelper::getPlugin('api');
$pluginsArr = array();
foreach ($plugins as $plg)
{
- $xml = JFactory::getXML(JPATH_SITE . '/plugins/api/' . $plg->name . '/' . $plg->name . '.xml');
+ $xml = simplexml_load_file(JPATH_SITE . '/plugins/api/' . $plg->name . '/' . $plg->name . '.xml');
$version = (string) $xml->version;
$pluginsArr[] = $plg->name . '-' . $version;
}
@@ -167,7 +175,7 @@ public static function getPluginsList()
*/
public static function getCom_apiVersion()
{
- $xml = JFactory::getXML(JPATH_ADMINISTRATOR . '/components/com_api/api.xml');
+ $xml = simplexml_load_file(JPATH_ADMINISTRATOR . '/components/com_api/api.xml');
return $version = (string) $xml->version;
}
@@ -181,7 +189,7 @@ public static function getCom_apiVersion()
*/
private static function getAuthMethod()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$key = $app->input->get('key');
if (isset($_SERVER['HTTP_X_AUTH']) && $_SERVER['HTTP_X_AUTH'])
@@ -283,7 +291,7 @@ private static function getAuthorizationHeader()
*/
public static function getImpersonateHeader()
{
- $jinput = JFactory::getApplication()->input;
+ $jinput = Factory::getApplication()->input;
$xImpersonate = $jinput->server->get('X-Impersonate', '', 'STRING');
$httpXImpersonate = $jinput->server->get('HTTP_X_IMPERSONATE', '', 'STRING');
@@ -318,7 +326,7 @@ public static function getUserIdToImpersonate($tokenUserId)
}
// Get user from tokenUserId
- $user = JFactory::getUser($tokenUserId);
+ $user = Factory::getUser($tokenUserId);
$isSuperAdmin = $user->authorise('core.admin');
// If this user is not super admin user, return false
@@ -346,7 +354,7 @@ public static function getUserIdToImpersonate($tokenUserId)
}
else
{
- ApiError::raiseError("400", JText::_('COM_API_INVALID_USER_TO_IMPERSONATE'), 'APIValidationException');
+ ApiError::raiseError("400", Text::_('COM_API_INVALID_USER_TO_IMPERSONATE'), 'APIValidationException');
return false;
}
@@ -354,7 +362,7 @@ public static function getUserIdToImpersonate($tokenUserId)
// If username or emailid exists ?
if ($searchFor)
{
- $db = JFactory::getDbo();
+ $db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__users'))
@@ -367,7 +375,7 @@ public static function getUserIdToImpersonate($tokenUserId)
}
else
{
- ApiError::raiseError("400", JText::_('COM_API_INVALID_USER_TO_IMPERSONATE'), 'APIValidationException');
+ ApiError::raiseError("400", Text::_('COM_API_INVALID_USER_TO_IMPERSONATE'), 'APIValidationException');
return false;
}
@@ -375,7 +383,7 @@ public static function getUserIdToImpersonate($tokenUserId)
// If userid exists ?
elseif ($userId)
{
- $table = JUser::getTable();
+ $table = User::getTable();
if ($table->load($userId))
{
@@ -383,7 +391,7 @@ public static function getUserIdToImpersonate($tokenUserId)
}
else
{
- ApiError::raiseError("400", JText::_('COM_API_INVALID_USER_TO_IMPERSONATE'), 'APIValidationException');
+ ApiError::raiseError("400", Text::_('COM_API_INVALID_USER_TO_IMPERSONATE'), 'APIValidationException');
return false;
}
diff --git a/code/site/libraries/authentication/jfbconnect.php b/code/site/libraries/authentication/jfbconnect.php
index cbdc911..b357bf1 100644
--- a/code/site/libraries/authentication/jfbconnect.php
+++ b/code/site/libraries/authentication/jfbconnect.php
@@ -19,8 +19,13 @@
// No direct access.
defined('_JEXEC') or die('Restricted access');
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Filesystem\File;
+use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
+
/**
* Jfbconnec ApiAuthentication class
*
@@ -43,18 +48,18 @@ public function authenticate()
$this->validateInstall();
// Init vars
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$providerName = $app->input->json->get('provider', '', 'STRING');
$accessToken = $app->input->json->get('access_token', '', 'STRING');
if (empty($providerName))
{
- ApiError::raiseError(400, JText::_('COM_API_JFBCONNECT_MISSING_PROVIDER'));
+ ApiError::raiseError(400, Text::_('COM_API_JFBCONNECT_MISSING_PROVIDER'));
}
if (empty($accessToken))
{
- ApiError::raiseError(400, JText::_('COM_API_JFBCONNECT_MISSING_ACCESS_TOKEN'));
+ ApiError::raiseError(400, Text::_('COM_API_JFBCONNECT_MISSING_ACCESS_TOKEN'));
}
// Get provider object
@@ -68,7 +73,7 @@ public function authenticate()
}
catch (Exception $e)
{
- ApiError::raiseError(400, JText::_('api auth error'));
+ ApiError::raiseError(400, Text::_('api auth error'));
}*/
/*echo ' provider class is: ' . get_class($provider);
@@ -97,16 +102,15 @@ public function authenticate()
*/
private function validateInstall()
{
- jimport('joomla.filesystem.file');
// Check if JFB is installed and enabled
- if (JFile::exists(JPATH_ROOT . '/components/com_jfbconnect/jfbconnect.php')
- && JComponentHelper::isEnabled('com_jfbconnect', true))
+ if (File::exists(JPATH_ROOT . '/components/com_jfbconnect/jfbconnect.php')
+ && ComponentHelper::isEnabled('com_jfbconnect', true))
{
return true;
}
- ApiError::raiseError(500, JText::_('PLG_API_JFBCONNECT_NOT_INSTALLED'));
+ ApiError::raiseError(500, Text::_('PLG_API_JFBCONNECT_NOT_INSTALLED'));
return false;
}
@@ -129,7 +133,7 @@ private function jfbGetProvider($providerName)
if (empty($provider->name))
{
- ApiError::raiseError(500, JText::_('Invalid provider'));
+ ApiError::raiseError(500, Text::_('Invalid provider'));
}
return $provider;
@@ -185,7 +189,7 @@ private function jfbRegisterUser($provider)
{
// Declare vars needed for JFB code to work
BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_jfbconnect/models');
- $loginRegisterModel = JModelLegacy::getInstance('LoginRegister', 'JFBConnectModel');
+ $loginRegisterModel = BaseDatabaseModel::getInstance('LoginRegister', 'JFBConnectModel');
$userMapModel = JFBCFactory::usermap();
$providerUserId = $provider->getProviderUserId();
$jUserId = 0;
@@ -215,14 +219,14 @@ private function jfbRegisterUser($provider)
if ($userMapModel->map($jUserEmailId, $providerUserId, strtolower($provider->name), $provider->client->getToken()))
{
- JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
+ JFBCFactory::log(Text::sprintf('COM_JFBCONNECT_MAP_USER_SUCCESS', $provider->name));
// Update the temp jId so that we login below
$jUserId = $jUserEmailId;
}
else
{
- JFBCFactory::log(JText::sprintf('COM_JFBCONNECT_MAP_USER_FAIL', $provider->name));
+ JFBCFactory::log(Text::sprintf('COM_JFBCONNECT_MAP_USER_FAIL', $provider->name));
}
}
}
@@ -234,13 +238,13 @@ private function jfbRegisterUser($provider)
* !allowUserRegistration and !social_registration => registration not allowed
* !allowUserRegistration and social_registration => registration allowed
* allowUserRegistration and !social_registration => registration not allowed
- * JComponentHelper::getParams('com_users')->get('allowUserRegistration') check is not needed since
+ * ComponentHelper::getParams('com_users')->get('allowUserRegistration') check is not needed since
* we prioritized the JFBConnect social registration config
*/
if (JFBCFactory::config()->getSetting('social_registration') == 0 && !$jUserId)
{
- JFBCFactory::log(JText::_('COM_JFBCONNECT_MSG_USER_REGISTRATION_DISABLED'), 'notice');
+ JFBCFactory::log(Text::_('COM_JFBCONNECT_MSG_USER_REGISTRATION_DISABLED'), 'notice');
// Commmented code below for com_api plugin
diff --git a/code/site/libraries/authentication/key.php b/code/site/libraries/authentication/key.php
index 37cd788..55faa91 100755
--- a/code/site/libraries/authentication/key.php
+++ b/code/site/libraries/authentication/key.php
@@ -9,7 +9,10 @@
*/
defined('_JEXEC') or die;
-jimport('joomla.application.component.model');
+
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Table\Table;
/**
* API resource class
@@ -29,7 +32,7 @@ class ApiAuthenticationKey extends ApiAuthentication
*/
public function authenticate()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$query_token = $app->input->get('key', '', 'STRING');
$header_token = $this->getBearerToken();
$key = $header_token ? $header_token : $query_token;
@@ -47,7 +50,7 @@ public function authenticate()
return $token->userid;
}
- $this->setError(JText::_('COM_API_KEY_NOT_FOUND'));
+ $this->setError(Text::_('COM_API_KEY_NOT_FOUND'));
return false;
}
@@ -61,7 +64,7 @@ public function authenticate()
*/
public function loadTokenByHash($hash)
{
- $table = JTable::getInstance('Key', 'ApiTable');
+ $table = Table::getInstance('Key', 'ApiTable');
$table->loadByHash($hash);
return $table;
diff --git a/code/site/libraries/authentication/login.php b/code/site/libraries/authentication/login.php
index e1bfe98..6d1b479 100755
--- a/code/site/libraries/authentication/login.php
+++ b/code/site/libraries/authentication/login.php
@@ -10,6 +10,11 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Authentication\Authentication;
+use Joomla\CMS\User\UserHelper;
+use Joomla\CMS\Uri\Uri;
+
/**
* ApiAuthenticationLogin class.
*
@@ -30,7 +35,7 @@ class ApiAuthenticationLogin extends ApiAuthentication
*/
public function authenticate()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$username = $app->input->post->get('username', '', 'STRING');
$password = $app->input->post->get('password', '', 'STRING');
@@ -38,7 +43,7 @@ public function authenticate()
$userId = $this->loadUserByCredentials($username, $password);
// Remove username and password from request for when it gets logged
- $uri = JFactory::getURI();
+ $uri = Uri::getInstance();
$uri->delVar('username');
$uri->delVar('password');
@@ -64,15 +69,14 @@ public function authenticate()
*/
public function loadUserByCredentials($user, $pass)
{
- jimport('joomla.user.authentication');
- $authenticate = JAuthentication::getInstance();
+ $authenticate = Authentication::getInstance();
$response = $authenticate->authenticate(array('username' => $user, 'password' => $pass), $options = array());
- if ($response->status === JAuthentication::STATUS_SUCCESS)
+ if ($response->status === Authentication::STATUS_SUCCESS)
{
- $userId = JUserHelper::getUserId($response->username);
+ $userId = UserHelper::getUserId($response->username);
if ($userId === false)
{
diff --git a/code/site/libraries/authentication/session.php b/code/site/libraries/authentication/session.php
index e0bd694..284a0bd 100644
--- a/code/site/libraries/authentication/session.php
+++ b/code/site/libraries/authentication/session.php
@@ -11,7 +11,9 @@
*/
defined('_JEXEC') or die();
-jimport('joomla.application.component.model');
+
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
/**
* API user authentication
@@ -33,12 +35,12 @@ class ApiAuthenticationSession extends ApiAuthentication
*/
public function authenticate()
{
- $app = JFactory::getApplication();
- $user = JFactory::getUser();
+ $app = Factory::getApplication();
+ $user = Factory::getUser();
if (! $user->id)
{
- $this->setError(JText::_('COM_API_LOGIN_MSG'));
+ $this->setError(Text::_('COM_API_LOGIN_MSG'));
return false;
}
diff --git a/code/site/libraries/authentication/user.php b/code/site/libraries/authentication/user.php
index d0ac983..b7c0841 100755
--- a/code/site/libraries/authentication/user.php
+++ b/code/site/libraries/authentication/user.php
@@ -10,6 +10,10 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Authentication\Authentication;
+use Joomla\CMS\User\User;
+
class ApiAuthenticationUser extends ApiAuthentication
{
protected $auth_method = null;
@@ -17,18 +21,18 @@ class ApiAuthenticationUser extends ApiAuthentication
public function authenticate()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$username = $app->input->post->get('username','','STRING');
$password = $app->input->post->get('password','','STRING');
- //$username = JRequest::getVar( 'username' );
- //$password = JRequest::getVar( 'password' );
+ //$username = Factory::getApplication()->input->get( 'username' );
+ //$password = Factory::getApplication()->input->get( 'password' );
$user = $this->loadUserByCredentials( $username, $password );
// Remove username and password from request for when it gets logged
- $uri = JFactory::getURI();
+ $uri = Factory::getURI();
$uri->delVar('username');
$uri->delVar('password');
@@ -42,13 +46,12 @@ public function authenticate()
public function loadUserByCredentials( $user, $pass )
{
- jimport('joomla.user.authentication');
- $authenticate = JAuthentication::getInstance();
+ $authenticate = Authentication::getInstance();
$response = $authenticate->authenticate(array( 'username' => $user, 'password' => $pass ));
- if ($response->status === JAuthentication::STATUS_SUCCESS) {
- $instance = JUser::getInstance($response->username);
+ if ($response->status === Authentication::STATUS_SUCCESS) {
+ $instance = User::getInstance($response->username);
if ( $instance === false ) {
$this->setError( JError::getError() );
return false;
diff --git a/code/site/libraries/cache.php b/code/site/libraries/cache.php
index 0e5edfd..73b938b 100755
--- a/code/site/libraries/cache.php
+++ b/code/site/libraries/cache.php
@@ -10,6 +10,8 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Factory;
+
class APICache {
const CACHE_GROUP = 'com_api';
@@ -20,11 +22,11 @@ class APICache {
public static function callback($object, $method, $args=array(), $cache_lifetime=null, $overrideConfig=false) {
- $conf = JFactory::getConfig();
+ $conf = Factory::getConfig();
$cacheactive = $conf->getValue('config.caching');
$cachetime = $conf->getValue('config.cachetime');
- $cache= & JFactory::getCache(self::CACHE_GROUP,'callback');
+ $cache= & Factory::getCache(self::CACHE_GROUP,'callback');
if ($overrideConfig) :
$cache->setCaching(1); //enable caching
diff --git a/code/site/libraries/controller.php b/code/site/libraries/controller.php
index 504eac9..db961f5 100755
--- a/code/site/libraries/controller.php
+++ b/code/site/libraries/controller.php
@@ -10,11 +10,13 @@
defined('_JEXEC') or die( 'Restricted access' );
-jimport('joomla.application.component.controller');
-jimport('joomla.application.component.modellist');
+use Joomla\CMS\MVC\Controller\BaseController;
+use Joomla\CMS\Factory;
+use Joomla\CMS\MVC\Model\ListModel;
+use Joomla\CMS\Table\Table;
//class ApiController extends JController {
-class ApiController extends JControllerLegacy {
+class ApiController extends BaseController {
/**
* Base Controller Constructor
@@ -27,13 +29,11 @@ class ApiController extends JControllerLegacy {
public function __construct($config=array()) {
parent::__construct();
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
- $this->set('option', $app->input->get('option','','STRING'));
-
- JModelList::addIncludePath(JPATH_SITE.'/components/com_api/models');
- JTable::addIncludePath(JPATH_ROOT.'/administrator/components/com_api/tables');
+ $this->option = $app->input->get('option','','STRING');
+ ListModel::addIncludePath(JPATH_SITE.'/components/com_api/models');
+ Table::addIncludePath(JPATH_ROOT.'/administrator/components/com_api/tables');
}
-
}
diff --git a/code/site/libraries/helper.php b/code/site/libraries/helper.php
index f26d949..d8f98e0 100755
--- a/code/site/libraries/helper.php
+++ b/code/site/libraries/helper.php
@@ -10,6 +10,9 @@
defined( '_JEXEC' ) or die( 'Restricted access' );
+use Joomla\CMS\Factory;
+use Joomla\CMS\User\User;
+
class APIHelper
{
function getAPIUserID()
@@ -25,13 +28,13 @@ function getAPIUserID()
function setSessionUser()
{
- $session =& JFactory::getSession();
- $session->set( 'user', JUser::getInstance( APIHelper::getAPIUserID() ) );
+ $session =& Factory::getSession();
+ $session->set( 'user', User::getInstance( APIHelper::getAPIUserID() ) );
}
function unsetSessionUser()
{
- $session =& JFactory::getSession();
+ $session =& Factory::getSession();
$session->clear( 'user' );
}
}
diff --git a/code/site/libraries/model.php b/code/site/libraries/model.php
index aaf58c7..bc76618 100755
--- a/code/site/libraries/model.php
+++ b/code/site/libraries/model.php
@@ -10,9 +10,10 @@
defined('_JEXEC') or die( 'Restricted access' );
-jimport('joomla.application.component.model');
+use Joomla\CMS\MVC\Model\BaseDatabaseModel;
+use Joomla\CMS\Pagination\Pagination;
-class ApiModel extends JModelLegacy {
+class ApiModel extends BaseDatabaseModel {
public function __construct($config=array()) {
parent::__construct($config);
@@ -25,8 +26,7 @@ public function getPagination() {
endif;
if (empty($this->pagination)) {
- jimport('joomla.html.pagination');
- $this->pagination = new JPagination($this->get('total'), $this->getState('limitstart'), $this->getState('limit'));
+ $this->pagination = new Pagination($this->get('total'), $this->getState('limitstart'), $this->getState('limit'));
}
return $this->pagination;
}
diff --git a/code/site/libraries/plugin.php b/code/site/libraries/plugin.php
index 29e3d6c..50b8b20 100755
--- a/code/site/libraries/plugin.php
+++ b/code/site/libraries/plugin.php
@@ -12,10 +12,14 @@
defined('_JEXEC') or die('Restricted access');
-jimport('joomla.plugin.plugin');
-jimport('joomla.filesystem.file');
-jimport('joomla.application.component.helper');
-
+use Joomla\CMS\Plugin\CMSPlugin;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Plugin\PluginHelper;
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Filesystem\File;
+use Joomla\CMS\Component\ComponentHelper;
+use Joomla\CMS\Table\Table;
+use Joomla\CMS\User\User;
use Joomla\Registry\Registry;
/**
@@ -24,7 +28,7 @@
*
* @since 1.0
*/
-class ApiPlugin extends JPlugin
+class ApiPlugin extends CMSPlugin
{
protected $user = null;
@@ -69,49 +73,54 @@ class ApiPlugin extends JPlugin
*/
public static function getInstance($name)
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$param_path = JPATH_BASE . self::$plg_path . $name . '.xml';
- $plugin = JPluginHelper::getPlugin('api', $name);
+ $plugin = PluginHelper::getPlugin('api', $name);
+ PluginHelper::importPlugin("api");
if (isset(self::$instances[$name]))
{
return self::$instances[$name];
}
- if (version_compare(JVERSION, '3.0', 'ge'))
+ if (version_compare(JVERSION, '4.0', 'ge'))
{
- $dispatcher = JDispatcher::getInstance();
+ $dispatcher = $app->getDispatcher();
}
- else
+ else if (version_compare(JVERSION, '3.0', 'ge'))
{
$dispatcher = JEventDispatcher::getInstance();
+ }
+ else
+ {
self::$plg_path = self::$plg_path . $plugin->name . '/';
}
if (empty($plugin))
{
- ApiError::raiseError(400, JText::sprintf('COM_API_PLUGIN_CLASS_NOT_FOUND', ucfirst($name)), 'APINotFoundException');
+ ApiError::raiseError(400, Text::sprintf('COM_API_PLUGIN_CLASS_NOT_FOUND', ucfirst($name)), 'APINotFoundException');
}
$plgfile = JPATH_BASE . self::$plg_path . $name . '/' . $name . '.php';
- if (! JFile::exists($plgfile))
+ if (!File::exists($plgfile))
{
- ApiError::raiseError(400, JText::sprintf('COM_API_FILE_NOT_FOUND', ucfirst($name)), 'APINotFoundException');
+ ApiError::raiseError(400, Text::sprintf('COM_API_FILE_NOT_FOUND', ucfirst($name)), 'APINotFoundException');
}
include_once $plgfile;
$class = self::$plg_prefix . ucwords($name);
- if (! class_exists($class))
+ if (!class_exists($class))
{
- ApiError::raiseError(400, JText::sprintf('COM_API_PLUGIN_CLASS_NOT_FOUND', ucfirst($name)), 'APINotFoundException');
+ ApiError::raiseError(400, Text::sprintf('COM_API_PLUGIN_CLASS_NOT_FOUND', ucfirst($name)), 'APINotFoundException');
}
- $cparams = JComponentHelper::getParams('com_api');
+ $cparams = ComponentHelper::getParams('com_api');
+ $enabled = PluginHelper::isEnabled("api", $name);
+
$handler = new $class($dispatcher, array('params' => $cparams));
$handler->set('params', $cparams);
-
$call_methd = $app->input->server->get('REQUEST_METHOD', '', 'STRING');
// Switch case for differ calling method
@@ -284,8 +293,9 @@ final public function fetchResource($resource_name = null)
}
$user = APIAuthentication::authenticateRequest();
+
$this->set('user', $user);
- $session = JFactory::getSession();
+ $session = Factory::getSession();
$session->set('user', $user);
$access = $this->getResourceAccess($resource_name, $this->request_method);
@@ -297,7 +307,7 @@ final public function fetchResource($resource_name = null)
if (! $this->checkRequestLimit())
{
- ApiError::raiseError(403, JText::_('COM_API_RATE_LIMIT_EXCEEDED'), 'APIUnauthorisedException');
+ ApiError::raiseError(403, Text::_('COM_API_RATE_LIMIT_EXCEEDED'), 'APIUnauthorisedException');
}
$this->lastUsed();
@@ -327,12 +337,12 @@ final private function checkInternally($resource_name)
{
if (! method_exists($this, $resource_name))
{
- ApiError::raiseError(404, JText::sprintf('COM_API_PLUGIN_METHOD_NOT_FOUND', ucfirst($resource_name)), 'APINotFoundException');
+ ApiError::raiseError(404, Text::sprintf('COM_API_PLUGIN_METHOD_NOT_FOUND', ucfirst($resource_name)), 'APINotFoundException');
}
if (! is_callable(array($this, $resource_name)))
{
- ApiError::raiseError(404, JText::sprintf('COM_API_PLUGIN_METHOD_NOT_CALLABLE', ucfirst($resource_name)), 'APINotFoundException');
+ ApiError::raiseError(404, Text::sprintf('COM_API_PLUGIN_METHOD_NOT_CALLABLE', ucfirst($resource_name)), 'APINotFoundException');
}
return true;
@@ -347,7 +357,7 @@ final private function checkInternally($resource_name)
*/
final private function checkRequestLimit()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$limit = $this->params->get('request_limit', 0);
if ($limit == 0)
@@ -378,7 +388,7 @@ final private function checkRequestLimit()
$query_time = time() - $offset;
- $db = JFactory::getDBO();
+ $db = Factory::getDBO();
$query = $db->getQuery(true);
$query->select('COUNT(*)');
$query->from($db->quoteName('#__api_logs'));
@@ -413,14 +423,14 @@ final private function log()
return;
}
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
// For exclude password from log
- $params = JComponentHelper::getParams('com_api');
+ $params = ComponentHelper::getParams('com_api');
$excludes = $params->get('exclude_log');
$raw_post = file_get_contents('php://input');
$redactions = explode(",", $excludes);
- $req_url = JURI::current() . '?' . JFactory::getURI()->getQuery();
+ $req_url = Uri::current() . '?' . Factory::getURI()->getQuery();
switch ($app->input->server->get('CONTENT_TYPE'))
{
@@ -446,8 +456,8 @@ final private function log()
break;
}
- $table = JTable::getInstance('Log', 'ApiTable');
- $date = JFactory::getDate();
+ $table = Table::getInstance('Log', 'ApiTable');
+ $date = Factory::getDate();
$table->hash = $app->input->get('key', '', 'STRING');
$table->ip_address = $app->input->server->get('REMOTE_ADDR', '', 'STRING');
$table->time = $date->toSql();
@@ -467,8 +477,8 @@ final private function log()
*/
final private function lastUsed()
{
- $app = JFactory::getApplication();
- $table = JTable::getInstance('Key', 'ApiTable');
+ $app = Factory::getApplication();
+ $table = Table::getInstance('Key', 'ApiTable');
$hash = $app->input->get('key', '', 'STRING');
$table->setLastUsed($hash);
@@ -485,6 +495,12 @@ final private function lastUsed()
*/
public function setResponse($data)
{
+ // For backward compatability -- TODO
+ if (!isset($data->result))
+ {
+ $data->result = clone $data;
+ }
+
$this->set('response', $data);
}
@@ -509,7 +525,7 @@ public function setApiResponse($error, $data)
if ($error)
{
$result->err_code = $this->err_code;
- $result->err_message = JText::_($this->err_message);
+ $result->err_message = Text::_($this->err_message);
}
else
{
@@ -528,7 +544,7 @@ public function setApiResponse($error, $data)
*/
public function encode()
{
- $document = JFactory::getDocument();
+ $document = Factory::getDocument();
$document->setMimeEncoding($this->format);
$format_name = $this->content_types[$this->format];
@@ -536,12 +552,12 @@ public function encode()
if (! method_exists($this, $method))
{
- ApiError::raiseError(406, JText::_('COM_API_PLUGIN_NO_ENCODER'));
+ ApiError::raiseError(406, Text::_('COM_API_PLUGIN_NO_ENCODER'));
}
if (! is_callable(array($this, $method)))
{
- ApiError::raiseError(404, JText::_('COM_API_PLUGIN_NO_ENCODER'));
+ ApiError::raiseError(404, Text::_('COM_API_PLUGIN_NO_ENCODER'));
}
return $this->$method();
@@ -550,10 +566,35 @@ public function encode()
/**
* Method to get current logged in API user
*
- * @return JUser
+ * @return User
*/
public function getUser()
{
return $this->user;
}
+
+ /**
+ * Method to get value of the property
+ *
+ * @return User
+ */
+ public function get($property, $default = null)
+ {
+ if (!isset($this->$property))
+ {
+ return $default;
+ }
+
+ return $this->$property;
+ }
+
+ /**
+ * Method to set value of the property
+ *
+ * @return User
+ */
+ public function set($property, $value = null)
+ {
+ $this->$property = $value;
+ }
}
diff --git a/code/site/libraries/resource.php b/code/site/libraries/resource.php
index 2b14404..032ae45 100755
--- a/code/site/libraries/resource.php
+++ b/code/site/libraries/resource.php
@@ -10,7 +10,9 @@
defined('_JEXEC') or die( 'Restricted access' );
-jimport('joomla.plugin.plugin');
+use Joomla\CMS\Language\Text;
+use Joomla\CMS\Filesystem\Path;
+
abstract class ApiResource {
@@ -30,7 +32,7 @@ final public function invoke() {
$this->$method_name();
else :
- ApiError::raiseError(404, JText::_('COM_API_PLUGIN_METHOD_NOT_FOUND'));
+ ApiError::raiseError(404, Text::_('COM_API_PLUGIN_METHOD_NOT_FOUND'));
endif;
}
@@ -39,7 +41,7 @@ final public static function getInstance($name, ApiPlugin $plugin, $prefix=null)
if (is_null($prefix))
{
- $prefix = $plugin->get('component').'ApiResource';
+ $prefix = $plugin->get('component') . 'ApiResource';
}
$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $name);
@@ -47,8 +49,7 @@ final public static function getInstance($name, ApiPlugin $plugin, $prefix=null)
if (!class_exists( $resourceClass ))
{
- jimport('joomla.filesystem.path');
- if($path = JPath::find(self::addIncludePath(), strtolower($type).'.php'))
+ if($path = Path::find(self::addIncludePath(), strtolower($type).'.php'))
{
require_once $path;
diff --git a/code/site/libraries/response/jsonresponse.php b/code/site/libraries/response/jsonresponse.php
index 369c9b3..de43335 100644
--- a/code/site/libraries/response/jsonresponse.php
+++ b/code/site/libraries/response/jsonresponse.php
@@ -8,6 +8,8 @@
* and the com_api extension by Brian Edgerton (http://www.edgewebworks.com)
*/
+use Joomla\CMS\Factory;
+
/**
* Class APIJSONResponse to convert the response of API in json
*
@@ -38,7 +40,7 @@ class APIJSONResponse
*/
public function __construct($response)
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$this->data = new \stdClass;
if ($response instanceof Exception)
@@ -75,7 +77,7 @@ public function __construct($response)
*/
public function __toString()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$callback = $app->input->get($this->callbackname, '', 'CMD');
if ($callback)
diff --git a/code/site/libraries/response/xmlresponse.php b/code/site/libraries/response/xmlresponse.php
index 92524dd..3a5f77e 100644
--- a/code/site/libraries/response/xmlresponse.php
+++ b/code/site/libraries/response/xmlresponse.php
@@ -8,6 +8,8 @@
* and the com_api extension by Brian Edgerton (http://www.edgewebworks.com)
*/
+use Joomla\CMS\Factory;
+
/**
* Class APIXMLResponse to convert the response of API in XML
*
@@ -36,7 +38,7 @@ class APIXMLResponse
*/
public function __construct($response)
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$this->data = new \stdClass;
if ($response instanceof Exception)
diff --git a/code/site/libraries/view.php b/code/site/libraries/view.php
index 9183040..e3138f1 100755
--- a/code/site/libraries/view.php
+++ b/code/site/libraries/view.php
@@ -10,9 +10,11 @@
defined('_JEXEC') or die;
-jimport('joomla.application.component.view');
+use Joomla\CMS\MVC\View\HtmlView;
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
-class ApiView extends JViewLegacy {
+class ApiView extends HtmlView {
protected $option = null;
protected $view = null;
@@ -20,7 +22,7 @@ class ApiView extends JViewLegacy {
function __construct() {
//vishal - for j3.2 changes
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$option = $app->input->get('option','','STRING');
@@ -29,8 +31,8 @@ function __construct() {
}
public function display($tpl = null) {
- $app = JFactory::getApplication();
- if ($app->isAdmin()) :
+ $app = Factory::getApplication();
+ if ($app->isClient("administrator")) :
$this->generateSubmenu();
endif;
@@ -49,8 +51,8 @@ private function generateSubmenu() {
protected function getMainViews() {
$views = array(
- array('name' => JText::_('COM_API_CONTROL_PANEL'), 'view' => 'cpanel'),
- array('name' => JText::_('COM_API_KEYS'), 'view' => 'keys'),
+ array('name' => Text::_('COM_API_CONTROL_PANEL'), 'view' => 'cpanel'),
+ array('name' => Text::_('COM_API_KEYS'), 'view' => 'keys'),
);
return $views;
}
diff --git a/code/site/models/documentation.php b/code/site/models/documentation.php
index 42bcf3f..4943a1e 100644
--- a/code/site/models/documentation.php
+++ b/code/site/models/documentation.php
@@ -9,9 +9,11 @@
*/
defined('_JEXEC') or die;
-jimport('joomla.application.component.model');
-jimport('joomla.filesystem.folder');
-jimport('joomla.filesystem.file');
+
+use Joomla\CMS\Factory;
+use Joomla\CMS\Plugin\PluginHelper;
+use Joomla\CMS\Filesystem\Folder;
+use Joomla\CMS\Filesystem\File;
class ApiModelDocumentation extends ApiModel
{
@@ -28,7 +30,7 @@ public function __construct()
{
parent::__construct();
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$this->option = $app->input->get('option','','CMD');
$this->view = $app->input->get('view','','CMD');
@@ -39,7 +41,7 @@ public function __construct()
protected function populateState()
{
- $app = JFactory::getApplication();
+ $app = Factory::getApplication();
$search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search', '', 'string');
$this->setState('filter.search', $search);
@@ -58,18 +60,17 @@ protected function populateState()
}
public function getList($override=false, $filter=true) {
- JPluginHelper::importPlugin('api');
+ PluginHelper::importPlugin('api');
- $dispatcher = JEventDispatcher::getInstance();
$api_paths = ApiResource::addIncludePath();
$methods = array ('get', 'post', 'put', 'delete', 'head');
foreach ($api_paths as $path) {
- $resources = JFolder::files($path);
+ $resources = Folder::files($path);
foreach ($resources as $resource) {
$item = new stdClass;
$item->app = basename($path);
- $item->resource = JFile::stripExt(basename($resource));
+ $item->resource = File::stripExt(basename($resource));
$class_name = ucfirst($item->app) . 'ApiResource' . ucfirst($item->resource);
require_once $path . '/' . $resource;
diff --git a/code/site/router.php b/code/site/router.php
index ddccdff..9e6e270 100755
--- a/code/site/router.php
+++ b/code/site/router.php
@@ -10,12 +10,14 @@
defined('_JEXEC') or die;
+use Joomla\CMS\Component\Router\RouterBase;
+
/**
* Routing class from com_api
*
* @since 2.0.1
*/
-class APIRouter extends JComponentRouterBase
+class APIRouter extends RouterBase
{
private $views = array('documentation','applogin', 'keys');
diff --git a/code/site/views/applogin/tmpl/default.php b/code/site/views/applogin/tmpl/default.php
index f95a2b2..2181f61 100644
--- a/code/site/views/applogin/tmpl/default.php
+++ b/code/site/views/applogin/tmpl/default.php
@@ -10,11 +10,13 @@
defined('_JEXEC') or die('Restricted access');
-$base_url = JUri::base();
-$formToken = JSession::getFormToken();
+use Joomla\CMS\Uri\Uri;
+use Joomla\CMS\Session\Session;
+
+$base_url = Uri::base();
+$formToken = Session::getFormToken();
$url = base64_encode($base_url.'tjlogin-registration');
-// @use Joomla\CMS\Uri\Uri;
?>
|