Skip to content

Commit

Permalink
Task #173069 feat: Update infra extensions code used to make Joomla 4…
Browse files Browse the repository at this point in the history
… compatible (#220)

* Task #172430 feat: Update JGive code to make Joomla 4 compatible

* Task #172430 feat: Update JGive code to make Joomla 4 compatible

* Task #172430 feat: Update JGive code to make Joomla 4 compatible

* Task #172430 feat: Update JGive code to make Joomla 4 compatible

* Task #175539 fix: Make extension compatible with Joomla 4

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

* Task #173069 feat: Update infra extensions code used in JGive to make Joomla 4 compatible

Co-authored-by: Deepa Gawade <[email protected]>
  • Loading branch information
ankush-maherwal and deepa-g authored Jan 25, 2022
1 parent 8a26e8b commit f79cbf1
Show file tree
Hide file tree
Showing 66 changed files with 1,622 additions and 906 deletions.
9 changes: 6 additions & 3 deletions tjreports/administrator/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,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 +32,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
2 changes: 1 addition & 1 deletion tjreports/administrator/controllers/indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function createTable()
{
$app = Factory::getApplication();

if ($app->isSite())
if ($app->isClient("site"))
{
echo 'Error creating DB table - Need to run this in admin area';

Expand Down
1 change: 0 additions & 1 deletion tjreports/administrator/controllers/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

// No direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controlleradmin');

// Load frontend venues model
JLoader::import('com_tjreports.controllers.reports', JPATH_SITE . '/components');
19 changes: 11 additions & 8 deletions tjreports/administrator/controllers/tjreport.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
// No direct access to this file
defined('_JEXEC') or die;

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

/**
* tjreport Controller
*
* @package Joomla.Administrator
* @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);
}
}
}
12 changes: 7 additions & 5 deletions tjreports/administrator/controllers/tjreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
// No direct access to this file
defined('_JEXEC') or die;

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

/**
* tjreport Controller
*
* @package Joomla.Administrator
* @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
25 changes: 16 additions & 9 deletions tjreports/administrator/controllers/tjreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
*/
// 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 +53,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 +72,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 +96,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 +117,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
27 changes: 16 additions & 11 deletions tjreports/administrator/helpers/tjreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,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 +31,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 +54,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,22 +103,22 @@ 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;

$layoutname = $layout . '.php';

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

if (JFile::exists($override))
if (File::exists($override))
{
return $view = $override;
}
else
{
return $view = $useViewpath . '/' . 'components' . '/' . $component . '/' . 'views' . '/' . $viewname . '/' . 'tmpl' . '/' . $layoutname;
return $view = $useViewpath . '/components/' . $component . '/views/' . $viewname . '/tmpl/' . $layoutname;
}
}
}
7 changes: 4 additions & 3 deletions tjreports/administrator/models/fields/createdby.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

defined('JPATH_BASE') or die;

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

/**
* Supports an HTML select list of categories
Expand Down Expand Up @@ -43,11 +44,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: 1 addition & 2 deletions tjreports/administrator/models/fields/custom_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

defined('JPATH_BASE') or die;

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

/**
* Supports an HTML select list of categories
Expand Down
2 changes: 1 addition & 1 deletion tjreports/administrator/models/fields/filemultiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('JPATH_BASE') or die;

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

/**
* Supports an HTML select list of categories
Expand Down
12 changes: 7 additions & 5 deletions tjreports/administrator/models/fields/foreignkey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*/
defined('JPATH_BASE') or die;

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

/**
* Supports a value from an external table
Expand Down Expand Up @@ -64,7 +66,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 +115,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 +138,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

0 comments on commit f79cbf1

Please sign in to comment.