first commit
This commit is contained in:
22
administrator/modules/mod_stats_admin/mod_stats_admin.php
Normal file
22
administrator/modules/mod_stats_admin/mod_stats_admin.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_stats_admin
|
||||
*
|
||||
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ModuleHelper;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Module\StatsAdmin\Administrator\Helper\StatsAdminHelper;
|
||||
|
||||
$serverinfo = $params->get('serverinfo');
|
||||
$siteinfo = $params->get('siteinfo');
|
||||
$list = StatsAdminHelper::getStats($params, $app, Factory::getContainer()->get(DatabaseInterface::class));
|
||||
|
||||
require ModuleHelper::getLayoutPath('mod_stats_admin', $params->get('layout', 'default'));
|
||||
99
administrator/modules/mod_stats_admin/mod_stats_admin.xml
Normal file
99
administrator/modules/mod_stats_admin/mod_stats_admin.xml
Normal file
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="module" client="administrator" method="upgrade">
|
||||
<name>mod_stats_admin</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2004-07</creationDate>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>MOD_STATS_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\StatsAdmin</namespace>
|
||||
<files>
|
||||
<filename module="mod_stats_admin">mod_stats_admin.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/mod_stats.ini</language>
|
||||
<language tag="en-GB">language/en-GB/mod_stats.sys.ini</language>
|
||||
</languages>
|
||||
<help key="Site_Modules:_Statistics" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="serverinfo"
|
||||
type="radio"
|
||||
label="MOD_STATS_FIELD_SERVERINFO_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="siteinfo"
|
||||
type="radio"
|
||||
label="MOD_STATS_FIELD_SITEINFO_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
rows="3"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cache"
|
||||
type="list"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
default="1"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="cache_time"
|
||||
type="number"
|
||||
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
|
||||
default="900"
|
||||
filter="integer"
|
||||
min="1"
|
||||
validate="number"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="cachemode"
|
||||
type="hidden"
|
||||
default="static"
|
||||
>
|
||||
<option value="static"></option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_stats_admin
|
||||
*
|
||||
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Module\StatsAdmin\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper class for admin stats module
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
class StatsAdminHelper
|
||||
{
|
||||
/**
|
||||
* Method to retrieve information about the site
|
||||
*
|
||||
* @param Registry $params The module parameters
|
||||
* @param CMSApplication $app The application
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return array Array containing site information
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public static function getStats(Registry $params, CMSApplication $app, DatabaseInterface $db)
|
||||
{
|
||||
$user = $app->getIdentity();
|
||||
|
||||
$rows = [];
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$serverinfo = $params->get('serverinfo', 0);
|
||||
$siteinfo = $params->get('siteinfo', 0);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ($serverinfo) {
|
||||
$rows[$i] = new \stdClass();
|
||||
$rows[$i]->title = Text::_('MOD_STATS_PHP');
|
||||
$rows[$i]->icon = 'cogs';
|
||||
$rows[$i]->data = PHP_VERSION;
|
||||
$i++;
|
||||
|
||||
$rows[$i] = new \stdClass();
|
||||
$rows[$i]->title = Text::_($db->name);
|
||||
$rows[$i]->icon = 'database';
|
||||
$rows[$i]->data = $db->getVersion();
|
||||
$i++;
|
||||
|
||||
$rows[$i] = new \stdClass();
|
||||
$rows[$i]->title = Text::_('MOD_STATS_CACHING');
|
||||
$rows[$i]->icon = 'tachometer-alt';
|
||||
$rows[$i]->data = $app->get('caching') ? Text::_('JENABLED') : Text::_('JDISABLED');
|
||||
$i++;
|
||||
|
||||
$rows[$i] = new \stdClass();
|
||||
$rows[$i]->title = Text::_('MOD_STATS_GZIP');
|
||||
$rows[$i]->icon = 'bolt';
|
||||
$rows[$i]->data = $app->get('gzip') ? Text::_('JENABLED') : Text::_('JDISABLED');
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($siteinfo) {
|
||||
$query->select('COUNT(id) AS count_users')
|
||||
->from('#__users');
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$users = $db->loadResult();
|
||||
} catch (\RuntimeException $e) {
|
||||
$users = false;
|
||||
}
|
||||
|
||||
$query->clear()
|
||||
->select('COUNT(id) AS count_items')
|
||||
->from('#__content')
|
||||
->where('state = 1');
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$items = $db->loadResult();
|
||||
} catch (\RuntimeException $e) {
|
||||
$items = false;
|
||||
}
|
||||
|
||||
if ($users) {
|
||||
$rows[$i] = new \stdClass();
|
||||
$rows[$i]->title = Text::_('MOD_STATS_USERS');
|
||||
$rows[$i]->icon = 'users';
|
||||
$rows[$i]->data = $users;
|
||||
|
||||
if ($user->authorise('core.manage', 'com_users')) {
|
||||
$rows[$i]->link = Route::_('index.php?option=com_users');
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($items) {
|
||||
$rows[$i] = new \stdClass();
|
||||
$rows[$i]->title = Text::_('MOD_STATS_ARTICLES');
|
||||
$rows[$i]->icon = 'file';
|
||||
$rows[$i]->data = $items;
|
||||
$rows[$i]->link = Route::_('index.php?option=com_content&view=articles&filter[published]=1');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Include additional data defined by published system plugins
|
||||
PluginHelper::importPlugin('system');
|
||||
|
||||
$arrays = (array) $app->triggerEvent('onGetStats', ['mod_stats_admin']);
|
||||
|
||||
foreach ($arrays as $response) {
|
||||
foreach ($response as $row) {
|
||||
// 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]->title = $row['title'];
|
||||
$rows[$i]->icon = $row['icon'] ?? 'info';
|
||||
$rows[$i]->data = $row['data'];
|
||||
$rows[$i]->link = $row['link'] ?? null;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
49
administrator/modules/mod_stats_admin/tmpl/default.php
Normal file
49
administrator/modules/mod_stats_admin/tmpl/default.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_stats_admin
|
||||
*
|
||||
* @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
\Joomla\CMS\Factory::getApplication()->getDocument()->addScriptDeclaration('
|
||||
(function() {
|
||||
document.addEventListener(\'DOMContentLoaded\', function() {
|
||||
var elms = document.querySelectorAll("a.js-revert");
|
||||
|
||||
if (elms.length) {
|
||||
elms.forEach(function(el) {
|
||||
el.addEventListener("click", function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var activeTab = [];
|
||||
activeTab.push("#" + e.target.href.split("#")[1]);
|
||||
var path = window.location.pathname;
|
||||
localStorage.removeItem(e.target.href.replace(/&return=[a-zA-Z0-9%]+/, "").replace(/&[a-zA-Z-_]+=[0-9]+/, ""));
|
||||
localStorage.setItem(path + e.target.href.split("index.php")[1].split("#")[0], JSON.stringify(activeTab));
|
||||
return window.location.href = e.target.href.split("#")[0];
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
');
|
||||
?>
|
||||
<ul class="list-group list-group-flush stats-module">
|
||||
<?php foreach ($list as $item) : ?>
|
||||
<li class="list-group-item">
|
||||
<span class="me-2 icon-<?php echo $item->icon; ?> icon-fw" aria-hidden="true"></span> <?php echo $item->title; ?>
|
||||
|
||||
<?php if (isset($item->link)) : ?>
|
||||
<a class="btn btn-info btn-sm js-revert" href="<?php echo $item->link; ?>"><?php echo $item->data; ?></a>
|
||||
<?php else : ?>
|
||||
<?php echo $item->data; ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user