1919defined ('_JEXEC ' ) or die ('Restricted access ' );
2020
2121jimport ('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 ;
2228use 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}
0 commit comments