Skip to content

Commit 6f20b2e

Browse files
[Modules][Plugin] Remove use of deprecated JText, JHtml, JFactory etc
1 parent 2fa3ffc commit 6f20b2e

File tree

10 files changed

+85
-68
lines changed

10 files changed

+85
-68
lines changed

modules/mod_jtrackgallery_closest/helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
1919

20+
use Joomla\CMS\Factory;
21+
2022
/**
2123
* ModjtrackgalleryClosestHelper class for Module JTrackGalleryClosest
2224
*
@@ -36,9 +38,7 @@ class ModjtrackgalleryClosestHelper
3638
*/
3739
public function getTracks($lon,$lat,$max_dist,$count)
3840
{
39-
$mainframe = JFactory::getApplication();
40-
41-
$db = JFactory::getDBO();
41+
$db = Factory::getDBO();
4242

4343
$lonrad = deg2rad($lon);
4444
$latrad = deg2rad($lat);

modules/mod_jtrackgallery_closest/mod_jtrackgallery_closest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
1919

20+
use Joomla\CMS\Helper\ModuleHelper;
21+
2022
require_once dirname(__FILE__) . '/helper.php';
2123
$helper = new ModjtrackgalleryClosestHelper;
2224

@@ -43,4 +45,4 @@
4345
}
4446

4547

46-
require JModuleHelper::getLayoutPath('mod_jtrackgallery_closest', $params->get('layout', 'default'));
48+
ModuleHelper::getLayoutPath('mod_jtrackgallery_closest', $params->get('layout', 'default'));

modules/mod_jtrackgallery_closest/tmpl/default.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616

1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
19+
20+
use Joomla\CMS\Factory;
21+
use Joomla\CMS\Language\Text;
22+
use Joomla\CMS\Router\Route;
23+
1924
$tcustom_enable = $params->get('tcustom_enable');
2025

2126
// Load english language file for 'com_jtg' component then override with current language file
22-
JFactory::getLanguage()->load('com_jtg_common', JPATH_SITE, null, true);
27+
Factory::getLanguage()->load('com_jtg_common', JPATH_SITE, null, true);
2328

2429
// Com_jtg_additional language files are in /images/jtrackgallery/language folder
25-
JFactory::getLanguage()->load('com_jtg_additional', JPATH_SITE . '/images/jtrackgallery', null, true);
30+
Factory::getLanguage()->load('com_jtg_additional', JPATH_SITE . '/images/jtrackgallery', null, true);
2631

2732
$max_dist = $params->get('max_dist');
2833
$earthRadius = 6378.137;
@@ -44,7 +49,7 @@
4449
if ($tcustom_enable)
4550
{
4651
$tcustom = $params->get('tcustom');
47-
$tcustom = str_replace('$cats', ($track->cat? JText::_($track->cat): '?'), $tcustom);
52+
$tcustom = str_replace('$cats', ($track->cat? Text::_($track->cat): '?'), $tcustom);
4853
$tcustom = str_replace('$distance_km', $distance_km, $tcustom);
4954
$tcustom = str_replace('$distance_mi', $distance_mi, $tcustom);
5055
}
@@ -69,7 +74,7 @@
6974
{
7075
if ( ($params->get('cats') != 0 ) and ($track->cat) )
7176
{
72-
echo '<div align="center">' . sprintf($params->get('tcats'), JText::_($track->cat)) . '</div>';
77+
echo '<div align="center">' . sprintf($params->get('tcats'), Text::_($track->cat)) . '</div>';
7378
}
7479

7580
if ($params->get('distance') != 0)
@@ -83,7 +88,7 @@
8388
elseif ($params->get('style') == 1)
8489
{
8590
echo '<table><tr>';
86-
$link = JRoute::_('index.php?option=com_jtg&view=files&layout=file&id=' . $track->id);
91+
$link = Route::_('index.php?option=com_jtg&view=files&layout=file&id=' . $track->id);
8792
echo '<td align="center" style="padding: 10px" valign="top">';
8893
if ( $map != 'none' ) {
8994
echo '<img src="https://maps.googleapis.com/maps/api/staticmap?center=' . $track->start_n . ',' .
@@ -101,7 +106,7 @@
101106
{
102107
if ( ($params->get('cats') != 0 ) and ($track->cat) )
103108
{
104-
echo '<div align="center">' . sprintf($params->get('tcats'), JText::_($track->cat)) . '</div>';
109+
echo '<div align="center">' . sprintf($params->get('tcats'), Text::_($track->cat)) . '</div>';
105110
}
106111

107112
if ($params->get('distance') != 0)

modules/mod_jtrackgallery_latest/helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
1919

20+
use Joomla\CMS\Factory;
21+
2022
/**
2123
* ModjtrackgalleryLatestHelper class for Module JTrackGalleryLatest
2224
*
@@ -36,9 +38,7 @@ class ModjtrackgalleryLatestHelper
3638
*/
3739
public function getTracks($count)
3840
{
39-
$mainframe = JFactory::getApplication();
40-
41-
$db = JFactory::getDBO();
41+
$db = Factory::getDbo();
4242

4343
$query = "SELECT a.*, b.title as cat FROM #__jtg_files AS a"
4444
. "\n LEFT JOIN #__jtg_cats AS b ON b.id=a.catid"

modules/mod_jtrackgallery_latest/mod_jtrackgallery_latest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
1919

20+
use Joomla\CMS\Helper\ModuleHelper;
21+
2022
require_once dirname(__FILE__) . '/helper.php';
2123
$latest = new ModjtrackgalleryLatestHelper;
2224

@@ -39,4 +41,4 @@
3941
}
4042

4143

42-
require JModuleHelper::getLayoutPath('mod_jtrackgallery_latest', $params->get('layout', 'default'));
44+
ModuleHelper::getLayoutPath('mod_jtrackgallery_latest', $params->get('layout', 'default'));

modules/mod_jtrackgallery_latest/tmpl/default.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616

1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
19+
20+
use Joomla\CMS\Factory;
21+
use Joomla\CMS\Language\Text;
22+
use Joomla\CMS\Router\Route;
23+
1924
$tcustom_enable = $params->get('tcustom_enable');
2025

2126
// Load english language file for 'com_jtg' component then override with current language file
22-
JFactory::getLanguage()->load('com_jtg_common', JPATH_SITE, null, true);
27+
Factory::getLanguage()->load('com_jtg_common', JPATH_SITE, null, true);
2328

2429
// Com_jtg_additional language files are in /images/jtrackgallery/language folder
25-
JFactory::getLanguage()->load('com_jtg_additional', JPATH_SITE . '/images/jtrackgallery', null, true);
30+
Factory::getLanguage()->load('com_jtg_additional', JPATH_SITE . '/images/jtrackgallery', null, true);
2631

2732
foreach ($tracks as $track)
2833
{
@@ -41,14 +46,14 @@
4146
if ($tcustom_enable)
4247
{
4348
$tcustom = $params->get('tcustom');
44-
$tcustom = str_replace('$cats', ($track->cat? JText::_($track->cat): '?'), $tcustom);
49+
$tcustom = str_replace('$cats', ($track->cat? Text::_($track->cat): '?'), $tcustom);
4550
$tcustom = str_replace('$distance_km', $distance_km, $tcustom);
4651
$tcustom = str_replace('$distance_mi', $distance_mi, $tcustom);
4752
}
4853

4954
if ($params->get('style') == 0)
5055
{
51-
$link = JRoute::_('index.php?option=com_jtg&view=track&id=' . $track->id);
56+
$link = Route::_('index.php?option=com_jtg&view=track&id=' . $track->id);
5257
echo '<div align="center" style="margin-bottom:20px;">';
5358
if ($map != 'none') {
5459
echo '<img src="https://maps.googleapis.com/maps/api/staticmap?center=' . $track->start_n . ',' .
@@ -66,7 +71,7 @@
6671
{
6772
if ( ($params->get('cats') != 0 ) and ($track->cat) )
6873
{
69-
echo '<div align="center">' . sprintf($params->get('tcats'), JText::_($track->cat)) . '</div>';
74+
echo '<div align="center">' . sprintf($params->get('tcats'), Text::_($track->cat)) . '</div>';
7075
}
7176

7277
if ($params->get('distance') != 0)
@@ -98,7 +103,7 @@
98103
{
99104
if ( ($params->get('cats') != 0 ) and ($track->cat) )
100105
{
101-
echo '<div align="center">' . sprintf($params->get('tcats'), JText::_($track->cat)) . '</div>';
106+
echo '<div align="center">' . sprintf($params->get('tcats'), Text::_($track->cat)) . '</div>';
102107
}
103108

104109
if ($params->get('distance') != 0)

modules/mod_jtrackgallery_stats/helper.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
1919

20+
use Joomla\CMS\Factory;
21+
2022
/**
21-
* ModjtrackgalleryLatestHelper class for Module JTrackGalleryStats
23+
* ModjtrackgalleryStatsHelper class for Module JTrackGalleryStats
2224
*
2325
* @package Comjtg
2426
* @subpackage Module JTrackGalleryStats
@@ -33,8 +35,7 @@ class ModjtrackgalleryStatsHelper
3335
*/
3436
public function countCats()
3537
{
36-
$mainframe = JFactory::getApplication();
37-
$db = JFactory::getDBO();
38+
$db = Factory::getDbo();
3839
$query = "SELECT COUNT(*) FROM #__jtg_cats WHERE published='1'";
3940
$db->setQuery($query);
4041
$result = $db->loadResult();
@@ -49,8 +50,7 @@ public function countCats()
4950
*/
5051
public function countTracks()
5152
{
52-
$mainframe = JFactory::getApplication();
53-
$db = JFactory::getDBO();
53+
$db = Factory::getDbo();
5454
$query = "SELECT COUNT(*) FROM #__jtg_files WHERE published='1'";
5555
$db->setQuery($query);
5656
$result = $db->loadResult();
@@ -65,9 +65,7 @@ public function countTracks()
6565
*/
6666
public function countDistance()
6767
{
68-
$mainframe = JFactory::getApplication();
69-
70-
$db = JFactory::getDBO();
68+
$db = Factory::getDbo();
7169

7270
$query = "SELECT SUM(distance) FROM #__jtg_files WHERE published='1'";
7371
$db->setQuery($query);
@@ -85,8 +83,7 @@ public function countDistance()
8583
*/
8684
public function countAscent()
8785
{
88-
$mainframe = JFactory::getApplication();
89-
$db = JFactory::getDBO();
86+
$db = Factory::getDbo();
9087
$query = "SELECT SUM(ele_asc) FROM #__jtg_files WHERE published='1'";
9188
$db->setQuery($query);
9289

@@ -103,8 +100,7 @@ public function countAscent()
103100
*/
104101
public function countDescent()
105102
{
106-
$mainframe = JFactory::getApplication();
107-
$db = JFactory::getDBO();
103+
$db = Factory::getDbo();
108104
$query = "SELECT SUM(ele_desc) FROM #__jtg_files WHERE published='1'";
109105
$db->setQuery($query);
110106

@@ -121,8 +117,7 @@ public function countDescent()
121117
*/
122118
public function countViews()
123119
{
124-
$mainframe = JFactory::getApplication();
125-
$db = JFactory::getDBO();
120+
$db = Factory::getDbo();
126121
$query = "SELECT SUM(hits) FROM #__jtg_files WHERE published='1'";
127122
$db->setQuery($query);
128123
$result = $db->loadResult();
@@ -137,8 +132,7 @@ public function countViews()
137132
*/
138133
public function countVotes()
139134
{
140-
$mainframe = JFactory::getApplication();
141-
$db = JFactory::getDBO();
135+
$db = Factory::getDbo();
142136
$query = "SELECT COUNT(*) FROM #__jtg_votes";
143137
$db->setQuery($query);
144138
$result = $db->loadResult();

modules/mod_jtrackgallery_stats/mod_jtrackgallery_stats.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
1919

20+
use Joomla\CMS\Helper\ModuleHelper;
21+
2022
require_once dirname(__FILE__) . '/helper.php';
2123
$stats = new ModjtrackgalleryStatsHelper;
2224

@@ -74,4 +76,4 @@
7476
$descent = str_replace('.', $decimalseparator, $descent);
7577
}
7678

77-
require JModuleHelper::getLayoutPath('mod_jtrackgallery_stats', $params->get('layout', 'default'));
79+
ModuleHelper::getLayoutPath('mod_jtrackgallery_stats', $params->get('layout', 'default'));

modules/mod_jtrackgallery_stats/tmpl/default.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
// No direct access
1818
defined('_JEXEC') or die('Restricted access');
19+
20+
use Joomla\CMS\Language\Text;
21+
1922
?>
2023
<div style="padding-left:10px">
2124
<?php
@@ -38,7 +41,7 @@
3841
if ($theado == "1")
3942
{
4043
echo "<div>";
41-
echo JText::_($thead);
44+
echo Text::_($thead);
4245
echo "</div>";
4346
}
4447

0 commit comments

Comments
 (0)