Skip to content

Commit 2fa3ffc

Browse files
Remove use of deprecated JText, JHtml, JFactory etc
1 parent 422f61f commit 2fa3ffc

Some content is hidden

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

83 files changed

+2386
-2157
lines changed

administrator/components/com_jtg/controllers/cats.php

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919
defined('_JEXEC') or die('Restricted access');
2020

2121
jimport('joomla.application.component.controller');
22+
23+
use Joomla\CMS\Factory;
24+
use Joomla\CMS\Language\Text;
25+
use Joomla\CMS\Router\Route;
26+
use Joomla\CMS\Session\Session;
27+
use Joomla\CMS\Table\Table;
2228
use Joomla\Utilities\ArrayHelper;
23-
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jtg/tables');
29+
30+
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jtg/tables');
2431

2532
/**
2633
* Controller Class Categories
@@ -55,21 +62,21 @@ public function display($cachable = false, $urlparams = false)
5562
function uploadcatimages ()
5663
{
5764
// Check for request forgeries
58-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
65+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
5966

6067
$model = $this->getModel('cat');
6168
$success = $model->saveCatImage();
6269

6370
// Redirect to cats overview
64-
$link = JRoute::_("index.php?option=com_jtg&controller=cats&task=managecatpics", false);
71+
$link = Route::_("index.php?option=com_jtg&controller=cats&task=managecatpics", false);
6572

6673
if ($success)
6774
{
68-
$this->setRedirect($link, JText::_('COM_JTG_CATPIC_SAVED'));
75+
$this->setRedirect($link, Text::_('COM_JTG_CATPIC_SAVED'));
6976
}
7077
else
7178
{
72-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_CATPIC_NOTSAVED'), 'Warning');
79+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_CATPIC_NOTSAVED'), 'Warning');
7380
$this->setRedirect($link);
7481
}
7582
}
@@ -83,21 +90,21 @@ function uploadcatimages ()
8390
function savecat ()
8491
{
8592
// Check for request forgeries
86-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
93+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
8794

8895
$model = $this->getModel('cat');
8996
$success = $model->saveCat();
9097

9198
// Redirect to cats overview
92-
$link = JRoute::_("index.php?option=com_jtg&task=cats&controller=cats", false);
99+
$link = Route::_("index.php?option=com_jtg&task=cats&controller=cats", false);
93100

94101
if ($success)
95102
{
96-
$this->setRedirect($link, JText::_('COM_JTG_CAT_SAVED'));
103+
$this->setRedirect($link, Text::_('COM_JTG_CAT_SAVED'));
97104
}
98105
else
99106
{
100-
$this->setRedirect($link, JText::_('COM_JTG_CAT_NOT_SAVED'));
107+
$this->setRedirect($link, Text::_('COM_JTG_CAT_NOT_SAVED'));
101108
}
102109
}
103110

@@ -109,12 +116,12 @@ function savecat ()
109116
function orderup ()
110117
{
111118
// Check for request forgeries
112-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
119+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
113120

114121
$model = $this->getModel('cat');
115122
$model->move(- 1);
116123

117-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats', false));
124+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats', false));
118125
}
119126

120127
/**
@@ -125,12 +132,12 @@ function orderup ()
125132
function orderdown ()
126133
{
127134
// Check for request forgeries
128-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
135+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
129136

130137
$model = $this->getModel('cat');
131138
$model->move(1);
132139

133-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats', false));
140+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats', false));
134141
}
135142

136143
/**
@@ -141,17 +148,17 @@ function orderdown ()
141148
function saveorder ()
142149
{
143150
// Check for request forgeries
144-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
151+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
145152

146-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
147-
$order = JFactory::getApplication()->input->get('order', array(), 'array');
153+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
154+
$order = Factory::getApplication()->input->get('order', array(), 'array');
148155
ArrayHelper::toInteger($cid);
149156
ArrayHelper::toInteger($order);
150157

151158
$model = $this->getModel('cat');
152159
$model->saveorder($order, $cid);
153160

154-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats', false));
161+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats', false));
155162
}
156163

157164
/**
@@ -162,14 +169,14 @@ function saveorder ()
162169
function publish ()
163170
{
164171
// Check for request forgeries
165-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
172+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
166173

167-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
174+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
168175
ArrayHelper::toInteger($cid);
169176

170177
if (count($cid) < 1)
171178
{
172-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_PUBLISH'), 'Error');
179+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_PUBLISH'), 'Error');
173180
}
174181

175182
$model = $this->getModel('cat');
@@ -179,7 +186,7 @@ function publish ()
179186
echo "<script> alert('" . $model->getError(true) . "'); window.history.go(-1); </script>\n";
180187
}
181188

182-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats', false));
189+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats', false));
183190
}
184191

185192
/**
@@ -190,14 +197,14 @@ function publish ()
190197
function unpublish ()
191198
{
192199
// Check for request forgeries
193-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
200+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
194201

195-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
202+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
196203
ArrayHelper::toInteger($cid);
197204

198205
if (count($cid) < 1)
199206
{
200-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_UNPUBLISH'), 'Error');
207+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_UNPUBLISH'), 'Error');
201208
}
202209

203210
$model = $this->getModel('cat');
@@ -207,7 +214,7 @@ function unpublish ()
207214
echo "<script> alert('" . $model->getError(true) . "'); window.history.go(-1); </script>\n";
208215
}
209216

210-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats', false));
217+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats', false));
211218
}
212219

213220
/**
@@ -218,13 +225,13 @@ function unpublish ()
218225
function removepic ()
219226
{
220227
// Check for request forgeries
221-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
228+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
222229

223-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
230+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
224231

225232
if (count($cid) < 1)
226233
{
227-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_DELETE'), 'Error');
234+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_DELETE'), 'Error');
228235
}
229236

230237
$model = $this->getModel('cat');
@@ -234,7 +241,7 @@ function removepic ()
234241
echo "<script> alert('" . $model->getError(true) . "'); window.history.go(-1); </script>\n";
235242
}
236243

237-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats&task=managecatpics', false));
244+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats&task=managecatpics', false));
238245
}
239246

240247
/**
@@ -245,14 +252,14 @@ function removepic ()
245252
function remove ()
246253
{
247254
// Check for request forgeries
248-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
255+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
249256

250-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
257+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
251258
ArrayHelper::toInteger($cid);
252259

253260
if (count($cid) < 1)
254261
{
255-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_DELETE'), 'Error');
262+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_DELETE'), 'Error');
256263
}
257264

258265
$model = $this->getModel('cat');
@@ -262,7 +269,7 @@ function remove ()
262269
echo "<script> alert('" . $model->getError(true) . "'); window.history.go(-1); </script>\n";
263270
}
264271

265-
$this->setRedirect(JRoute::_('index.php?option=com_jtg&task=cats&controller=cats', false));
272+
$this->setRedirect(Route::_('index.php?option=com_jtg&task=cats&controller=cats', false));
266273
}
267274

268275
/**
@@ -273,21 +280,21 @@ function remove ()
273280
function updatecat ()
274281
{
275282
// Check the token
276-
JSession::checkToken() or die('JINVALID_TOKEN');
283+
Session::checkToken() or die('JINVALID_TOKEN');
277284

278285
$model = $this->getModel('cat');
279286
$success = $model->updateCat();
280287

281288
// Redirect to cats overview
282-
$link = JRoute::_("index.php?option=com_jtg&task=cats&controller=cats", false);
289+
$link = Route::_("index.php?option=com_jtg&task=cats&controller=cats", false);
283290

284291
if ($success)
285292
{
286-
$this->setRedirect($link, JText::_('COM_JTG_CAT_SAVED'));
293+
$this->setRedirect($link, Text::_('COM_JTG_CAT_SAVED'));
287294
}
288295
else
289296
{
290-
$this->setRedirect($link, JText::_('COM_JTG_CAT_NOT_SAVED'));
297+
$this->setRedirect($link, Text::_('COM_JTG_CAT_NOT_SAVED'));
291298
}
292299
}
293300
}

administrator/components/com_jtg/controllers/comments.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
defined('_JEXEC') or die('Restricted access');
1919

2020
jimport('joomla.application.component.controller');
21+
22+
use Joomla\CMS\Factory;
23+
use Joomla\CMS\Language\Text;
24+
use Joomla\CMS\Session\Session;
2125
use Joomla\Utilities\ArrayHelper;
2226
/**
2327
* JtgControllerComments class for the jtg component
@@ -37,14 +41,14 @@ class JtgControllerComments extends JtgController
3741
function publish ()
3842
{
3943
// Check for request forgeries
40-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
44+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
4145

42-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
46+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
4347
ArrayHelper::toInteger($cid);
4448

4549
if (count($cid) < 1)
4650
{
47-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_PUBLISH'), 'Error');
51+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_PUBLISH'), 'Error');
4852
}
4953

5054
$model = $this->getModel('comments');
@@ -65,14 +69,14 @@ function publish ()
6569
function unpublish ()
6670
{
6771
// Check for request forgeries
68-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
72+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
6973

70-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
74+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
7175
ArrayHelper::toInteger($cid);
7276

7377
if (count($cid) < 1)
7478
{
75-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_UNPUBLISH'), 'Error');
79+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_UNPUBLISH'), 'Error');
7680
}
7781

7882
$model = $this->getModel('comments');
@@ -93,14 +97,14 @@ function unpublish ()
9397
function remove ()
9498
{
9599
// Check for request forgeries
96-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
100+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
97101

98-
$cid = JFactory::getApplication()->input->get('cid', array(), 'array');
102+
$cid = Factory::getApplication()->input->get('cid', array(), 'array');
99103
ArrayHelper::toInteger($cid);
100104

101105
if (count($cid) < 1)
102106
{
103-
JFactory::getApplication()->enqueueMessage(JText::_('COM_JTG_SELECT_AN_ITEM_TO_DELETE'), 'Error');
107+
Factory::getApplication()->enqueueMessage(Text::_('COM_JTG_SELECT_AN_ITEM_TO_DELETE'), 'Error');
104108
}
105109

106110
$model = $this->getModel('comments');
@@ -121,7 +125,7 @@ function remove ()
121125
function saveComment ()
122126
{
123127
// Check for request forgeries
124-
JSession::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
128+
Session::checkToken() or jexit(JTEXT::_('JINVALID_TOKEN'));
125129

126130
$model = $this->getModel('comments');
127131

administrator/components/com_jtg/controllers/config.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
defined('_JEXEC') or die('Restricted access');
2020

2121
jimport('joomla.application.component.controller');
22+
23+
use Joomla\CMS\Factory;
24+
use Joomla\CMS\Language\Text;
25+
use Joomla\CMS\Router\Route;
26+
use Joomla\CMS\Session\Session;
27+
2228
/**
2329
* Controller Class Configuration
2430
*
@@ -52,19 +58,17 @@ public function display($cachable = false, $urlparams = false)
5258
*/
5359
function saveconfig()
5460
{
55-
$mainframe = JFactory::getApplication();
56-
5761
// check the token
58-
JSession::checkToken() or die( 'JINVALID_TOKEN' );
62+
Session::checkToken() or die( 'JINVALID_TOKEN' );
5963
$model = $this->getModel('config');
6064
$error = $model->saveConfig();
6165

6266
if ($error !== true)
6367
{
64-
JFactory::getApplication()->enqueueMessage($error, 'Warning');
68+
Factory::getApplication()->enqueueMessage($error, 'Warning');
6569
}
6670

67-
$link = JRoute::_("index.php?option=com_jtg&task=config&controller=config", false);
68-
$this->setRedirect($link, JText::_('COM_JTG_CONFIG_SAVED'));
71+
$link = Route::_("index.php?option=com_jtg&task=config&controller=config", false);
72+
$this->setRedirect($link, Text::_('COM_JTG_CONFIG_SAVED'));
6973
}
7074
}

0 commit comments

Comments
 (0)