Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joomla 4 compability #201

Open
wants to merge 1 commit into
base: j4x
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions tjreports/administrator/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
*/
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;

/**
* Class TjreportsController
*
* @since 1.6
*/
class TjreportsController extends JControllerLegacy
class TjreportsController extends BaseController
{
/**
* Method to display a view.
Expand All @@ -29,8 +31,8 @@ class TjreportsController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
$view = JFactory::getApplication()->input->getCmd('view', 'tjreports');
JFactory::getApplication()->input->set('view', $view);
$view = Factory::getApplication()->input->getCmd('view', 'tjreports');
Factory::getApplication()->input->set('view', $view);

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

Expand Down
17 changes: 10 additions & 7 deletions tjreports/administrator/controllers/tjreport.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Factory;
use Joomla\CMS\Response\JsonResponse;

jimport('joomla.application.component.controllerform');
/**
Expand All @@ -17,7 +20,7 @@
* @subpackage com_tjreports
* @since 0.0.1
*/
class TjreportsControllerTjreport extends JControllerForm
class TjreportsControllerTjreport extends FormController
{
/**
* Contructor
Expand All @@ -38,7 +41,7 @@ public function getplugins()
{
try
{
$app = JFactory::getApplication();
$app = Factory::getApplication();
$jinput = $app->input;
$jform = $jinput->post->get('jform', array(), 'ARRAY');
$client = $jform['client'];
Expand All @@ -48,11 +51,11 @@ public function getplugins()
$model = $this->getModel('tjreport');
$reports = $model->getClientPlugins($client, $id, $userid);

echo new JResponseJson($reports);
echo new JsonResponse($reports);
}
catch (Exception $e)
{
echo new JResponseJson($e);
echo new JsonResponse($e);
}
}

Expand All @@ -66,7 +69,7 @@ public function getparams()
{
try
{
$app = JFactory::getApplication();
$app = Factory::getApplication();
$jinput = $app->input;
$jform = $jinput->post->get('jform', array(), 'ARRAY');
$plugin = $parent = null;
Expand All @@ -84,11 +87,11 @@ public function getparams()
$model = $this->getModel('tjreport');
$report = $model->getReportPluginData($parent, $plugin);

echo new JResponseJson($report);
echo new JsonResponse($report);
}
catch (Exception $e)
{
echo new JResponseJson($e);
echo new JsonResponse($e);
}
}
}
10 changes: 6 additions & 4 deletions tjreports/administrator/controllers/tjreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Factory;

jimport('joomla.application.component.controllerform');
/**
Expand All @@ -17,7 +19,7 @@
* @subpackage com_tjreports
* @since 0.0.1
*/
class TjreportsControllerTjreport extends JControllerForm
class TjreportsControllerTjreport extends FormController
{
/**
* Contructor
Expand All @@ -40,7 +42,7 @@ public function __construct()
*/
public function setRedirect($url, $msg = null,$type = null)
{
$extension = JFactory::getApplication()->input->get('extension', '', 'word');
$extension = Factory::getApplication()->input->get('extension', '', 'word');

if ($extension)
{
Expand All @@ -61,7 +63,7 @@ public function setRedirect($url, $msg = null,$type = null)
*/
protected function allowAdd($data = array())
{
$user = JFactory::getUser();
$user = Factory::getUser();

if ($user->authorise('core.create', 'com_tjreports'))
{
Expand All @@ -86,7 +88,7 @@ protected function allowAdd($data = array())
*/
protected function allowEdit($data = array(), $key = 'id')
{
$user = JFactory::getUser();
$user = Factory::getUser();

if ($user->authorise('core.edit', 'com_tjreports'))
{
Expand Down
23 changes: 14 additions & 9 deletions tjreports/administrator/controllers/tjreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
/**
* com tjreports Controller
*
* @since 0.0.1
*/
class TjreportsControllerTjreports extends JControllerAdmin
class TjreportsControllerTjreports extends AdminController
{
/**
* Proxy for getModel.
Expand Down Expand Up @@ -46,7 +51,7 @@ public function getModel($name = 'Tjreport', $prefix = 'TjreportsModel', $config
*/
public function setRedirect($url, $msg = null,$type = null)
{
$extension = JFactory::getApplication()->input->get('extension', '', 'word');
$extension = Factory::getApplication()->input->get('extension', '', 'word');

if ($extension)
{
Expand All @@ -65,10 +70,10 @@ public function setRedirect($url, $msg = null,$type = null)
*/
public function discover()
{
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjreports/models');
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables');
BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjreports/models');
Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables');

$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('element');
$query->from($db->quoteName('#__extensions'));
Expand All @@ -89,9 +94,9 @@ public function discover()

foreach ($discoverPlugins as $value)
{
$model = JModelLegacy::getInstance('Reports', 'TjreportsModel');
$model = BaseDatabaseModel::getInstance('Reports', 'TjreportsModel');
$pluginName = $value;
$reportTable = JTable::getInstance('Tjreport', 'TjreportsTable');
$reportTable = Table::getInstance('Tjreport', 'TjreportsTable');
$details = $model->getPluginInstallationDetail($pluginName);
$reportTable->load(array('plugin' => $pluginName, 'userid' => 0));

Expand All @@ -110,11 +115,11 @@ public function discover()
}
}

$message = JText::_('COM_TJREPORTS_NOTHING_TO_DISCOVER_PLUGINS');
$message = Text::_('COM_TJREPORTS_NOTHING_TO_DISCOVER_PLUGINS');

if ($count > 0)
{
$message = JText::sprintf(JText::_('COM_TJREPORTS_DISCOVER_NEW_PLUGINS'), $count);
$message = Text::sprintf(Text::_('COM_TJREPORTS_DISCOVER_NEW_PLUGINS'), $count);
}

$this->setRedirect('index.php?option=com_tjreports', $message);
Expand Down
22 changes: 13 additions & 9 deletions tjreports/administrator/helpers/tjreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
*/
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;

/**
* Cp helper.
*
* @since 1.6
*/
class TjreportsHelper extends JHelperContent
class TjreportsHelper extends ContentHelper
{
/**
* Configure the Linkbar.
Expand All @@ -26,17 +30,17 @@ class TjreportsHelper extends JHelperContent
*/
public static function addSubmenu($view='')
{
$client = JFactory::getApplication()->input->get('client', '', 'STRING');
$client = Factory::getApplication()->input->get('client', '', 'STRING');
$full_client = $client;

// Set ordering.
$mainframe = JFactory::getApplication();
$mainframe = Factory::getApplication();
$full_client = explode('.', $full_client);

// Eg com_jgive
$component = $full_client[0];
$eName = str_replace('com_', '', $component);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');
$file = Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

if (file_exists($file))
{
Expand All @@ -49,14 +53,14 @@ public static function addSubmenu($view='')
{
if (is_callable(array($cName, 'addSubmenu')))
{
$lang = JFactory::getLanguage();
$lang = Factory::getLanguage();

// Loading language file from the administrator/language directory then
// Loading language file from the administrator/components/*extension*/language directory
$lang->load($component, JPATH_BASE, null, false, false)
|| $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, false)
|| $lang->load($component, Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, false)
|| $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false)
|| $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), $lang->getDefault(), false, false);
|| $lang->load($component, Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component), $lang->getDefault(), false, false);

// Call_user_func(array($cName, 'addSubmenu'), 'categories' . (isset($section) ? '.' . $section : ''));
call_user_func(array($cName, 'addSubmenu'), $view . (isset($section) ? '.' . $section : ''));
Expand Down Expand Up @@ -98,7 +102,7 @@ public static function getActions($component = 'com_tjreports', $section = '', $
*/
public function getViewpath($component, $viewname, $layout = 'default', $searchTmpPath = 'SITE', $useViewpath = 'SITE')
{
$app = JFactory::getApplication();
$app = Factory::getApplication();

$searchTmpPath = ($searchTmpPath == 'SITE') ? JPATH_SITE : JPATH_ADMINISTRATOR;
$useViewpath = ($useViewpath == 'SITE') ? JPATH_SITE : JPATH_ADMINISTRATOR;
Expand All @@ -107,7 +111,7 @@ public function getViewpath($component, $viewname, $layout = 'default', $searchT

$override = $searchTmpPath . '/' . 'templates' . '/' . $app->getTemplate() . '/' . 'html' . '/' . $component . '/' . $viewname . '/' . $layoutname;

if (JFile::exists($override))
if (File::exists($override))
{
return $view = $override;
}
Expand Down
8 changes: 5 additions & 3 deletions tjreports/administrator/models/fields/createdby.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/

defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;

jimport('joomla.form.formfield');

Expand All @@ -16,7 +18,7 @@
*
* @since 1.6
*/
class JFormFieldCreatedby extends JFormField
class FormFieldCreatedby extends FormField
{
/**
* The form field type.
Expand All @@ -43,11 +45,11 @@ protected function getInput()

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

Expand Down
3 changes: 2 additions & 1 deletion tjreports/administrator/models/fields/custom_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;

jimport('joomla.html.html');
jimport('joomla.form.formfield');
Expand All @@ -17,7 +18,7 @@
*
* @since 1.6
*/
class JFormFieldCustomField extends JFormField
class FormFieldCustomField extends FormField
{
/**
* The form field type.
Expand Down
3 changes: 2 additions & 1 deletion tjreports/administrator/models/fields/filemultiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;

jimport('joomla.form.formfield');

Expand All @@ -16,7 +17,7 @@
*
* @since 1.6
*/
class JFormFieldFileMultiple extends JFormField
class FormFieldFileMultiple extends FormField
{
/**
* The form field type.
Expand Down
13 changes: 8 additions & 5 deletions tjreports/administrator/models/fields/foreignkey.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;

jimport('joomla.form.formfield');

Expand All @@ -16,7 +19,7 @@
*
* @since 1.6
*/
class JFormFieldForeignKey extends JFormField
class FormFieldForeignKey extends FormField
{
/**
* The form field type.
Expand Down Expand Up @@ -64,7 +67,7 @@ protected function getInput()
$fk_value = '';

// Load all the field options
$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true);

// Support for multiple fields on fk_values
Expand Down Expand Up @@ -113,7 +116,7 @@ protected function getInput()
// Iterate through all the results
foreach ($results as $result)
{
$options[] = JHtml::_('select.option', $result->{$this->key_field}, $result->{$this->value_field});
$options[] = HTMLHelper::_('select.option', $result->{$this->key_field}, $result->{$this->value_field});
}

$value = $this->value;
Expand All @@ -136,10 +139,10 @@ protected function getInput()
}
else
{
array_unshift($options, JHtml::_('select.option', '', ''));
array_unshift($options, HTMLHelper::_('select.option', '', ''));
}

$html = JHtml::_('select.genericlist', $options, $this->name, $input_options, 'value', 'text', $value, $this->id);
$html = HTMLHelper::_('select.genericlist', $options, $this->name, $input_options, 'value', 'text', $value, $this->id);
break;
}

Expand Down
Loading