Commit c3c79536 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Move secondary stats and graph off admin home page


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 28b3bca3
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* 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/>.
*
* @package mahara
* @subpackage admin
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('ADMIN', 1);
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
require(dirname(dirname(__FILE__)).'/init.php');
require(get_config('libroot') . 'registration.php');
define('TITLE', get_string('sitestatistics', 'admin'));
$sitedata = site_statistics(true);
if (!empty($sitedata['weekly'])) {
$jsfiles = array('js/PlotKit/excanvas.js', 'js/PlotKit/PlotKit.js');
$sitedata['dataarray'] = json_encode(array($sitedata['weekly']['view-count'], $sitedata['weekly']['user-count'], $sitedata['weekly']['group-count']));
}
$smarty = smarty($jsfiles);
$smarty->assign('PAGEHEADING', hsc(TITLE));
if (isset($sitedata)) {
$smarty->assign('sitedata', $sitedata);
}
$smarty->display('admin/statistics.tpl');
?>
......@@ -146,6 +146,8 @@ $string['reopensite'] = 'Reopen Site';
$string['reopensitedetail'] = 'Your site is closed. Site administrators may stay logged in until an upgrade is detected.';
// Statistics
$string['siteinformation'] = 'Site Information';
$string['viewfullsitestatistics'] = 'View Full Site Statistics';
$string['sitestatistics'] = 'Site Statistics';
$string['siteinstalled'] = 'Site Installed';
$string['databasesize'] = 'Database Size';
......
......@@ -181,31 +181,35 @@ function registration_data() {
function site_data_current() {
return array(
'name' => get_config('sitename'),
'users' => count_records_select('usr', 'id > 0 AND deleted = 0'),
'groups' => count_records('group', 'deleted', 0),
'views' => count_records_select('view', 'owner <> 0'),
);
}
function site_statistics() {
$data = site_data_current();
$lastyear = db_format_timestamp(time() - 60*60*12*365);
$values = array($lastyear, 'view-count', 'user-count', 'group-count');
$weekly = get_records_sql_array('
SELECT ctime, type, value, ' . db_format_tsfield('ctime', 'ts') . '
FROM {site_data}
WHERE ctime >= ? AND type IN (?,?,?)
ORDER BY ctime, type', $values);
if ($weekly) {
$data['weekly'] = array('user-count' => array(), 'group-count' => array(), 'view-count' => array());
$keys = array('user-count' => 0, 'group-count' => 0, 'view-count' => 0);
foreach ($weekly as &$r) {
$data['weekly'][$r->type][$keys[$r->type]++] = array($keys[$r->type], $r->value);
function site_statistics($full=false) {
if ($full) {
$data = site_data_current();
$lastyear = db_format_timestamp(time() - 60*60*12*365);
$values = array($lastyear, 'view-count', 'user-count', 'group-count');
$weekly = get_records_sql_array('
SELECT ctime, type, value, ' . db_format_tsfield('ctime', 'ts') . '
FROM {site_data}
WHERE ctime >= ? AND type IN (?,?,?)
ORDER BY ctime, type', $values);
if ($weekly) {
$data['weekly'] = array('user-count' => array(), 'group-count' => array(), 'view-count' => array());
$keys = array('user-count' => 0, 'group-count' => 0, 'view-count' => 0);
foreach ($weekly as &$r) {
$data['weekly'][$r->type][$keys[$r->type]++] = array($keys[$r->type], $r->value);
}
}
}
else {
$data = array();
}
$data['name'] = get_config('sitename');
$data['release'] = get_config('release');
$data['version'] = get_config('version');
$data['installdate'] = format_date(strtotime(get_config('installation_time')), 'strftimedate');
......
......@@ -156,13 +156,16 @@ input#register_register {
}
.site-stats {
margin: 0 0 1em 0;
padding: 1em 1.5em;
margin: 1.5em 0 1em 0;
padding: 0 1em 0 0;
text-align: left;
}
.site-stats h5 {
margin-bottom: .25em;
.message.site-stats {
margin: 0 0 1em 0;
padding: 1em 1.5em;
}
.site-stats p:first-child,
.site-stats p:last-child,
.site-stats p {
margin: .1em;
}
......
......@@ -36,10 +36,6 @@
</div>
{/if}
{if $sitedata}
{include file='admin/stats.tpl' cron=1}
{/if}
{if $register}
<div class="message" id="register-site">
<h3>{str tag=registeryourmaharasite section=admin}</h3>
......@@ -47,6 +43,15 @@
</div>
{/if}
{if $sitedata}
<div class="message site-stats">
<div class="fl"><h3>{$sitedata.name}: {str tag=siteinformation section=admin}</h3></div>
<div class="fr"><a href="{$WWWROOT}admin/statistics.php">{str tag=viewfullsitestatistics section=admin}</a></div>
<div class="cb"></div>
{include file='admin/stats.tpl' full=0}
</div>
{/if}
</div>
......
{include file='header.tpl'}
{if $sitedata}
<div class="site-stats">
{include file='admin/stats.tpl' cron=1}
</div>
{/if}
{include file='footer.tpl'}
<div class="message site-stats">
{if $sitedata.weekly}
<div id="site-stats-graph" class="fr" width="300" height="200"></div>
<script type="text/javascript">
<div class="fr">
<div id="site-stats-graph" class="fr" width="300" height="200"></div>
<script type="text/javascript">
addLoadEvent(function () {literal}{{/literal}
EasyPlot('line', {literal}{}{/literal}, $('site-stats-graph'), {$sitedata.dataarray});
{literal}}{/literal});
</script>
</script>
</div>
{/if}
<div class="fl">
<h3>{$sitedata.name}: {str tag=sitestatistics section=admin}</h3>
<p><strong>{str tag=siteinstalled section=admin}:</strong> {$sitedata.installdate}</p>
{if $sitedata.users}
<p><strong>{str tag=users}:</strong> {$sitedata.users}{if $sitedata.rank.users} ({str tag=Rank section=admin}: $sitedata.rank.users}){/if}</p>
<p>&nbsp;{str tag=activeusers section=admin}: {$sitedata.usersloggedin}</p>
{/if}
{if $sitedata.groups}
<p><strong>{str tag=groups}:</strong> {$sitedata.groups}{if $sitedata.rank.groups} ({str tag=Rank section=admin}: $sitedata.rank.groups}){/if}</p>
<p>&nbsp;{$sitedata.groupmemberaverage}</p>
{/if}
{if $sitedata.views}
<p><strong>{str tag=views}:</strong> {$sitedata.views}{if $sitedata.rank.views} ({str tag=Rank section=admin}: $sitedata.rank.views}){/if}</p>
<p>&nbsp;{$sitedata.viewsperuser}</p>
{/if}
<p><strong>{str tag=databasesize section=admin}:</strong> {$sitedata.dbsize|display_size}</p>
<p><strong>{str tag=diskusage section=admin}:</strong> {$sitedata.diskusage|display_size}</p>
<p><strong>{str tag=maharaversion section=admin}:</strong> {$sitedata.release}</p>
<p><strong>{str tag=Cron section=admin}:</strong> {if $sitedata.cronrunning}{str tag=runningnormally section=admin}{else}{str tag=cronnotrunning section=admin}{/if}</p>
</div>
<div class="cb"></div>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment