Skip to content

Commit

Permalink
namespace mod_stats_admin
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed Jul 26, 2017
1 parent c21ddbf commit d11ec99
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Module\StatsAdmin\Administrator\Helper;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;

/**
* Helper class for admin stats module
*
* @since 3.0
*/
class ModStatsHelper
class StatsAdminHelper
{
/**
* Method to retrieve information about the site
Expand All @@ -27,8 +32,8 @@ class ModStatsHelper
*/
public static function getStats(&$params)
{
$app = JFactory::getApplication();
$db = JFactory::getDbo();
$app = Factory::getApplication();
$db = Factory::getDbo();
$rows = array();
$query = $db->getQuery(true);

Expand All @@ -39,28 +44,28 @@ public static function getStats(&$params)

if ($serverinfo)
{
$rows[$i] = new stdClass;
$rows[$i]->title = JText::_('MOD_STATS_PHP');
$rows[$i] = new \stdClass;
$rows[$i]->title = \JText::_('MOD_STATS_PHP');
$rows[$i]->icon = 'cogs';
$rows[$i]->data = phpversion();
$i++;

$rows[$i] = new stdClass;
$rows[$i]->title = JText::_($db->name);
$rows[$i] = new \stdClass;
$rows[$i]->title = \JText::_($db->name);
$rows[$i]->icon = 'database';
$rows[$i]->data = $db->getVersion();
$i++;

$rows[$i] = new stdClass;
$rows[$i]->title = JText::_('MOD_STATS_CACHING');
$rows[$i] = new \stdClass;
$rows[$i]->title = \JText::_('MOD_STATS_CACHING');
$rows[$i]->icon = 'dashboard';
$rows[$i]->data = $app->get('caching') ? JText::_('JENABLED') : JText::_('JDISABLED');
$rows[$i]->data = $app->get('caching') ? \JText::_('JENABLED') : \JText::_('JDISABLED');
$i++;

$rows[$i] = new stdClass;
$rows[$i]->title = JText::_('MOD_STATS_GZIP');
$rows[$i] = new \stdClass;
$rows[$i]->title = \JText::_('MOD_STATS_GZIP');
$rows[$i]->icon = 'bolt';
$rows[$i]->data = $app->get('gzip') ? JText::_('JENABLED') : JText::_('JDISABLED');
$rows[$i]->data = $app->get('gzip') ? \JText::_('JENABLED') : \JText::_('JDISABLED');
$i++;
}

Expand All @@ -73,7 +78,7 @@ public static function getStats(&$params)
{
$users = $db->loadResult();
}
catch (RuntimeException $e)
catch (\RuntimeException $e)
{
$users = false;
}
Expand All @@ -87,34 +92,34 @@ public static function getStats(&$params)
{
$items = $db->loadResult();
}
catch (RuntimeException $e)
catch (\RuntimeException $e)
{
$items = false;
}

if ($users)
{
$rows[$i] = new stdClass;
$rows[$i]->title = JText::_('MOD_STATS_USERS');
$rows[$i] = new \stdClass;
$rows[$i]->title = \JText::_('MOD_STATS_USERS');
$rows[$i]->icon = 'users';
$rows[$i]->data = $users;
$i++;
}

if ($items)
{
$rows[$i] = new stdClass;
$rows[$i]->title = JText::_('MOD_STATS_ARTICLES');
$rows[$i] = new \stdClass;
$rows[$i]->title = \JText::_('MOD_STATS_ARTICLES');
$rows[$i]->icon = 'file';
$rows[$i]->data = $items;
$i++;
}
}

// Include additional data defined by published system plugins
JPluginHelper::importPlugin('system');
PluginHelper::importPlugin('system');

$app = JFactory::getApplication();
$app = Factory::getApplication();
$arrays = (array) $app->triggerEvent('onGetStats', array('mod_stats_admin'));

foreach ($arrays as $response)
Expand All @@ -124,7 +129,7 @@ public static function getStats(&$params)
// We only add a row if the title and data are given
if (isset($row['title']) && isset($row['data']))
{
$rows[$i] = new stdClass;
$rows[$i] = new \stdClass;
$rows[$i]->title = $row['title'];
$rows[$i]->icon = isset($row['icon']) ? $row['icon'] : 'info';
$rows[$i]->data = $row['data'];
Expand Down
8 changes: 4 additions & 4 deletions administrator/modules/mod_stats_admin/mod_stats_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

defined('_JEXEC') or die;

// Include the mod_stats functions only once
JLoader::register('ModStatsHelper', __DIR__ . '/helper.php');
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\Module\StatsAdmin\Administrator\Helper\StatsAdminHelper;

$serverinfo = $params->get('serverinfo');
$siteinfo = $params->get('siteinfo');
$list = ModStatsHelper::getStats($params);
$list = StatsAdminHelper::getStats($params);
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');

require JModuleHelper::getLayoutPath('mod_stats_admin', $params->get('layout', 'default'));
require ModuleHelper::getLayoutPath('mod_stats_admin', $params->get('layout', 'default'));

0 comments on commit d11ec99

Please sign in to comment.