Perfekt!
Denke es ist ein wenig umständlich die DB Verbindung in jede Funktion einer Klasse einzubinden....aber da bin ich bei weitem zu wenig Programmierer, um hier Kritik üben zu dürfen...
Hier mal der Code in einer /modules/wbstats/widgets/test.php
Das klappt wunderbar....wenn ich Zeit habe noch die Languagefiles laden und fertig ist das Counterwidget....das ist genial einfach!
Mein Kompliment - jetzt braucht es noch eine ähnliche Liste wie für die Blöcke bei den Seiten zum Hinzufügen und jeweils ein X zum entfernen....Rechte werden durch das Addon erteilt...habe ich Rechte das Addon zu sehen - dann wohl auch das Widget...wäre logisch...?
(Probiere das gleich mal mit der Anzeige der RSS Statistik des Topics Modules, die Ralf eingebaut hat...auch eine coole Sache fürs Dashboard.)
Gruß mr-fan
Code: Alles auswählen
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* @author Black Cat Development
* @copyright 2013, Black Cat Development
* @link http://blackcat-cms.org
* @license http://www.gnu.org/licenses/gpl.html
* @category CAT_Modules
* @package blackcat
*
*/
// include class.secure.php to protect this file and the whole CMS!
if (defined('CAT_PATH')) {
include(CAT_PATH.'/framework/class.secure.php');
} else {
$oneback = "../";
$root = $oneback;
$level = 1;
while (($level < 10) && (!file_exists($root.'/framework/class.secure.php'))) {
$root .= $oneback;
$level += 1;
}
if (file_exists($root.'/framework/class.secure.php')) {
include($root.'/framework/class.secure.php');
} else {
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
}
}
// end include class.secure.php
$widget_name = 'Seitenstatistik';
//DB Verbindung und Klasse laden
global $database, $table_day, $table_ips, $table_pages, $table_ref, $table_key, $table_lang;
include_once (WB_PATH.'/modules/wbstats/class.stats.php');
$stats = new stats();
$websitestats = $stats->getStats();
echo "Total visitors: " . $websitestats['visitors'];
echo "<br/>Pageviews: " . $websitestats['visits'];
echo "<br/>Currently Online: " . $websitestats['online'];
echo "<br/>";