Skip to content

Commit 6cf6c53

Browse files
Task #173069 feat: Update infra extensions code used to make Joomla 4 compatible (#57)
1 parent c179ef0 commit 6cf6c53

File tree

25 files changed

+170
-114
lines changed

25 files changed

+170
-114
lines changed

plugins/api/tjactivity/tjactivity.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<extension version="3.0" type="plugin" group="api" method="upgrade">
33
<name>com_api_tjactivity</name>
4-
<version>1.0.3</version>
5-
<creationDate>22nd Jul 2021</creationDate>
4+
<version>2.0.0</version>
5+
<creationDate>25th Jan 2022</creationDate>
66
<author>Techjoomla</author>
77
<authorEmail>[email protected]</authorEmail>
88
<authorUrl>https://techjoomla.com</authorUrl>
9-
<copyright>Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.</copyright>
9+
<copyright>Copyright (C) 2016 - 2022 Techjoomla. All rights reserved.</copyright>
1010
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
1111
<description>PLG_API_TJACTIVITY_DESCRIPTION</description>
1212
<languages>

src/activitystream.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<extension type="component" version="3.0" method="upgrade">
33
<name>com_activitystream</name>
4-
<creationDate>22nd Jul 2021</creationDate>
4+
<creationDate>25th Jan 2022</creationDate>
55
<author>Techjoomla</author>
66
<authorEmail>[email protected]</authorEmail>
77
<authorUrl>https://techjoomla.com</authorUrl>
8-
<copyright>Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.</copyright>
8+
<copyright>Copyright (C) 2016 - 2022 Techjoomla. All rights reserved.</copyright>
99
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
10-
<version>1.0.3</version>
10+
<version>2.0.0</version>
1111
<description>COM_ACTIVITYSTREAM_DESCRIPTION</description>
1212
<scriptfile>script.activitystream.php</scriptfile>
1313
<install>

src/admin/activitystream.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
// No direct access to this file
1111
defined('_JEXEC') or die;
12+
use Joomla\CMS\MVC\Controller\BaseController;
13+
use Joomla\CMS\Factory;
1214

1315
// Get an instance of the controller prefixed by HelloWorld
14-
$controller = JControllerLegacy::getInstance('activitystream');
16+
$controller = BaseController::getInstance('activitystream');
1517

1618
// Perform the Request task
17-
$input = JFactory::getApplication()->input;
19+
$input = Factory::getApplication()->input;
1820
$controller->execute($input->getCmd('task'));
1921

2022
// Redirect if set by the controller

src/admin/controller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// No direct access to this file
1111
defined('_JEXEC') or die;
12+
use Joomla\CMS\MVC\Controller\BaseController;
1213

1314
/**
1415
* General Controller of ActivityStream component
@@ -17,7 +18,7 @@
1718
* @subpackage com_activitystream
1819
* @since 0.0.7
1920
*/
20-
class ActivityStreamController extends JControllerLegacy
21+
class ActivityStreamController extends BaseController
2122
{
2223
/**
2324
* The default view for the display method.

src/admin/controllers/activities.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
*/
88
// No direct access to this file
99
defined('_JEXEC') or die;
10+
use Joomla\CMS\MVC\Controller\AdminController;
11+
use Joomla\CMS\Table\Table;
12+
use Joomla\CMS\Factory;
13+
use Joomla\CMS\Language\Text;
14+
use Joomla\CMS\Log\Log;
15+
use Joomla\CMS\Router\Route;
1016
use Joomla\Utilities\ArrayHelper;
1117

1218
/**
1319
* Activity Stream Controller
1420
*
1521
* @since 0.0.1
1622
*/
17-
class ActivityStreamControllerActivities extends JControllerAdmin
23+
class ActivityStreamControllerActivities extends AdminController
1824
{
1925
/**
2026
* Proxy for getModel.
@@ -44,7 +50,7 @@ public function getModel($name = 'Activity', $prefix = 'ActivityStreamModel', $c
4450
public function getActivities()
4551
{
4652
// Load component tables
47-
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_activitystream/tables');
53+
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_activitystream/tables');
4854

4955
// Variable to store activity data fetched
5056
$result = array();
@@ -54,14 +60,14 @@ public function getActivities()
5460

5561
$ActivityStreamModelActivities = $this->getModel('Activities');
5662

57-
$jinput = JFactory::getApplication()->input;
63+
$jinput = Factory::getApplication()->input;
5864
$type = $jinput->get("type", '', 'STRING');
5965

6066
// Return result related to specified activity type
6167
if (empty($type))
6268
{
6369
$result_arr['success'] = false;
64-
$result_arr['message'] = JText::_("COM_ACTIVITYSTREAM_ERROR_ACTIVITY_TYPE");
70+
$result_arr['message'] = Text::_("COM_ACTIVITYSTREAM_ERROR_ACTIVITY_TYPE");
6571

6672
echo json_encode($result_arr);
6773

@@ -90,7 +96,7 @@ public function getActivities()
9096
if (empty($result['results']))
9197
{
9298
$result_arr['success'] = false;
93-
$result_arr['message'] = JText::_("COM_ACTIVITYSTREAM_NO_ACTIVITY");
99+
$result_arr['message'] = Text::_("COM_ACTIVITYSTREAM_NO_ACTIVITY");
94100
}
95101
else
96102
{
@@ -113,13 +119,13 @@ public function getActivities()
113119
*/
114120
public function delete()
115121
{
116-
$input = JFactory::getApplication()->input;
122+
$input = Factory::getApplication()->input;
117123
$client = $input->get('client', '', 'STRING');
118-
$id = JFactory::getApplication()->input->get('cid', array(), 'array');
124+
$id = Factory::getApplication()->input->get('cid', array(), 'array');
119125

120126
if (!is_array($id) || count($id) < 1)
121127
{
122-
JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
128+
Log::add(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), Log::WARNING, 'jerror');
123129
}
124130
else
125131
{
@@ -133,7 +139,7 @@ public function delete()
133139
// Remove the activity.
134140
if ($model->delete($id))
135141
{
136-
$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($id)));
142+
$this->setMessage(Text::plural($this->text_prefix . '_N_ITEMS_DELETED', count($id)));
137143
}
138144
else
139145
{
@@ -142,11 +148,11 @@ public function delete()
142148

143149
if (isset($client))
144150
{
145-
$this->setRedirect(JRoute::_('index.php?option=com_activitystream&view=activities&client=' . $client, false));
151+
$this->setRedirect(Route::_('index.php?option=com_activitystream&view=activities&client=' . $client, false));
146152
}
147153
else
148154
{
149-
$this->setRedirect(JRoute::_('index.php?option=com_activitystream&view=activities', false));
155+
$this->setRedirect(Route::_('index.php?option=com_activitystream&view=activities', false));
150156
}
151157
}
152158
}

src/admin/controllers/activity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
// No direct access to this file
1010
defined('_JEXEC') or die;
11+
use Joomla\CMS\MVC\Controller\FormController;
1112

1213
/**
1314
* HelloWorld Controller
@@ -16,6 +17,6 @@
1617
* @subpackage com_activitystream
1718
* @since 0.0.9
1819
*/
19-
class ActivityStreamControllerActivity extends JControllerForm
20+
class ActivityStreamControllerActivity extends FormController
2021
{
2122
}

src/admin/helpers/activities.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
// No direct access
1111
defined('_JEXEC') or die();
12+
use Joomla\CMS\Factory;
1213

1314
/**
1415
* Products helper for quick2cart backend.
@@ -87,7 +88,7 @@ public function json_to_array($array, $recursive = true)
8788
*/
8889
public function buildActivityFilterQuery($filterString)
8990
{
90-
$db = JFactory::getDbo();
91+
$db = Factory::getDbo();
9192

9293
// Check if $filterString is comma separated string.
9394
if ((strpos($filterString, ',') !== false))

src/admin/models/activities.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
*/
88
// No direct access to this file
99
defined('_JEXEC') or die;
10+
use Joomla\CMS\MVC\Model\ListModel;
11+
use Joomla\CMS\Factory;
12+
use Joomla\CMS\HTML\HTMLHelper;
1013

1114
/**
1215
* ActivityStreamList Model
1316
*
1417
* @since 0.0.1
1518
*/
16-
class ActivityStreamModelActivities extends JModelList
19+
class ActivityStreamModelActivities extends ListModel
1720
{
1821
/**
1922
* Constructor.
@@ -60,7 +63,7 @@ public function __construct($config = array())
6063
protected function populateState($ordering = 'id', $direction = 'desc')
6164
{
6265
// Initialise variables.
63-
$jinput = JFactory::getApplication()->input;
66+
$jinput = Factory::getApplication()->input;
6467

6568
// Client filter
6669
$extension = $jinput->get("client", '', 'STRING');
@@ -94,7 +97,7 @@ protected function populateState($ordering = 'id', $direction = 'desc')
9497
protected function getListQuery()
9598
{
9699
// Initialize variables.
97-
$db = JFactory::getDbo();
100+
$db = Factory::getDbo();
98101
$query = $db->getQuery(true);
99102

100103
// Create the base select statement.
@@ -184,8 +187,8 @@ public function getItems()
184187
foreach ($items as $k => $item)
185188
{
186189
// Get date in local time zone
187-
$item->created_date = JHtml::date($item->created_date, 'Y-m-d h:i:s');
188-
$item->updated_date = JHtml::date($item->updated_date, 'Y-m-d h:i:s');
190+
$item->created_date = HTMLHelper::date($item->created_date, 'Y-m-d h:i:s');
191+
$item->updated_date = HTMLHelper::date($item->updated_date, 'Y-m-d h:i:s');
189192

190193
// Get extra date info
191194
$items[$k]->created_day = date_format(date_create($item->created_date), "D");

src/admin/models/activity.php

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

99
// No direct access to this file
1010
defined('_JEXEC') or die;
11+
use Joomla\CMS\MVC\Model\AdminModel;
12+
use Joomla\CMS\Table\Table;
13+
use Joomla\CMS\Factory;
1114

1215
/**
1316
* ActivityStream Model
1417
*
1518
* @since 0.0.1
1619
*/
17-
class ActivityStreamModelActivity extends JModelAdmin
20+
class ActivityStreamModelActivity extends AdminModel
1821
{
1922
/**
2023
* Method to get a table object, load it if necessary.
@@ -29,7 +32,7 @@ class ActivityStreamModelActivity extends JModelAdmin
2932
*/
3033
public function getTable($type = 'activity', $prefix = 'ActivityStreamTable', $config = array())
3134
{
32-
return JTable::getInstance($type, $prefix, $config);
35+
return Table::getInstance($type, $prefix, $config);
3336
}
3437

3538
/**
@@ -72,7 +75,7 @@ public function getForm($data = array(), $loadData = true)
7275
protected function loadFormData()
7376
{
7477
// Check the session for previously entered form data.
75-
$data = JFactory::getApplication()->getUserState(
78+
$data = Factory::getApplication()->getUserState(
7679
'com_activitystream.edit.activity.data',
7780
array()
7881
);
@@ -96,7 +99,7 @@ protected function loadFormData()
9699
*/
97100
public function save($data)
98101
{
99-
$cdate = JFactory::getDate('now');
102+
$cdate = Factory::getDate('now');
100103

101104
if (empty($data['id']))
102105
{

src/admin/models/fields/activitytype.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
// No direct access.
1111
defined('_JEXEC') or die();
12+
use Joomla\CMS\Form\FormHelper;
13+
use Joomla\CMS\Factory;
14+
use Joomla\CMS\Language\Text;
15+
use Joomla\CMS\HTML\HTMLHelper;
1216

1317
JFormHelper::loadFieldClass('list');
1418

@@ -44,8 +48,8 @@ class JFormFieldActivityType extends JFormFieldList
4448
*/
4549
protected function getOptions()
4650
{
47-
$db = JFactory::getDbo();
48-
$client = JFactory::getApplication()->input->get('client', '', 'STRING');
51+
$db = Factory::getDbo();
52+
$client = Factory::getApplication()->input->get('client', '', 'STRING');
4953
$query = $db->getQuery(true);
5054

5155
$query->select('distinct l.type')
@@ -57,14 +61,14 @@ protected function getOptions()
5761
// Send filter values
5862
$activityType = $db->loadObjectList();
5963
$options = array();
60-
$options[] = JHtml::_('select.option', 'all', JText::_('COM_ACTIVITYSTREAM_SEARCH_FILTER'));
64+
$options[] = HTMLHelper::_('select.option', 'all', Text::_('COM_ACTIVITYSTREAM_SEARCH_FILTER'));
6165

6266
foreach ($activityType as $type)
6367
{
6468
$temp = implode("_", explode('.', $type->type));
6569
$filterValue = $client . '_activity_type_' . $temp;
6670
$filterText = strtoupper($filterValue);
67-
$options[] = JHtml::_('select.option', $type->type, JText::_($filterText));
71+
$options[] = HTMLHelper::_('select.option', $type->type, Text::_($filterText));
6872
}
6973

7074
return $options;

src/admin/tables/activity.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
*/
99
// No direct access
1010
defined('_JEXEC') or die;
11+
use Joomla\CMS\Table\Table;
12+
use Joomla\CMS\Factory;
13+
use Joomla\CMS\Language\Text;
1114

1215
/**
1316
* Hello Table class
1417
*
1518
* @since 0.0.1
1619
*/
17-
class ActivityStreamTableActivity extends JTable
20+
class ActivityStreamTableActivity extends Table
1821
{
1922
/**
2023
* Constructor
@@ -34,34 +37,34 @@ public function __construct(&$db)
3437
*/
3538
public function check()
3639
{
37-
$jinput = JFactory::getApplication()->input;
38-
$db = JFactory::getDbo();
40+
$jinput = Factory::getApplication()->input;
41+
$db = Factory::getDbo();
3942
$errors = array();
4043

4144
// Activity type should not be empty
4245
if (empty($this->type))
4346
{
44-
$errors['type'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TYPE_REQUIRED');
47+
$errors['type'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TYPE_REQUIRED');
4548
}
4649

4750
// Actor and actor_id should not be empty
4851
if (empty($this->actor_id) || empty($this->actor))
4952
{
50-
$errors['actor'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_ACTOR_REQUIRED');
53+
$errors['actor'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_ACTOR_REQUIRED');
5154
}
5255

5356
// Object and object_id should not be empty
5457
if (empty($this->object_id) || empty($this->object))
5558
{
56-
$errors['object'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_OBJECT_REQUIRED');
59+
$errors['object'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_OBJECT_REQUIRED');
5760
}
5861

5962
// If there is data in target then target_id should not be empty
6063
if (!empty($this->target))
6164
{
6265
if (empty($this->target_id))
6366
{
64-
$errors['target_id'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TARGET_REQUIRED');
67+
$errors['target_id'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TARGET_REQUIRED');
6568
}
6669
}
6770

0 commit comments

Comments
 (0)