import v1.0.0-RC4 | 2009-05-20
This commit is contained in:
106
modules/stats/controllers/AuthorizationsController.php
Normal file
106
modules/stats/controllers/AuthorizationsController.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_AuthorizationsController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->weekSelected = '';
|
||||
$this->view->yearSelected = '';
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->view->yearSelected = 'selected="true"';
|
||||
$this->view->type = 'year';
|
||||
break;
|
||||
default:
|
||||
$this->view->weekSelected = 'selected="true"';
|
||||
$this->view->type = 'week';
|
||||
}
|
||||
|
||||
$this->view->rand = rand(0, 1000);
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
require_once 'libs/jpgraph/jpgraph.php';
|
||||
require_once 'libs/jpgraph/jpgraph_bar.php';
|
||||
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$graph = new Graph(300,200 ,'auto');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->img->SetMargin(0,30,20,40);
|
||||
$graph->yaxis->scale->SetGrace(20);
|
||||
$graph->yaxis->HideLabels();
|
||||
$graph->yaxis->HideTicks();
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
|
||||
|
||||
$labelsy = array();
|
||||
$datay = array();
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->_populateYearData($labelsy, $datay);
|
||||
break;
|
||||
default:
|
||||
$this->_populateWeekData($labelsy, $datay);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetTickLabels($labelsy);
|
||||
$bplot = new BarPlot($datay);
|
||||
|
||||
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFormat('%d');
|
||||
$graph->Add($bplot);
|
||||
|
||||
$graph->Stroke();
|
||||
}
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$authorizations = $stats->getNumAuthorizationsDays(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
if (isset($authorizations[$date])) {
|
||||
$datay[] = $authorizations[$date]['entry'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$firstDayOfMonth = date('Y-' . date('m') . '-01');
|
||||
$authorizations = $stats->getNumAuthorizationsYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time());
|
||||
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
if (isset($authorizations[$monthNumber])) {
|
||||
$datay[] = $authorizations[$monthNumber]['entry'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
modules/stats/controllers/IndexController.php
Normal file
19
modules/stats/controllers/IndexController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_IndexController extends Monkeys_Controller_Action
|
||||
{
|
||||
protected $_numCols = 1;
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
}
|
||||
}
|
130
modules/stats/controllers/RegistrationsController.php
Normal file
130
modules/stats/controllers/RegistrationsController.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_RegistrationsController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->weekSelected = '';
|
||||
$this->view->yearSelected = '';
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'month':
|
||||
$this->view->monthSelected = 'selected="true"';
|
||||
$this->view->type = 'month';
|
||||
break;
|
||||
case 'year':
|
||||
$this->view->yearSelected = 'selected="true"';
|
||||
$this->view->type = 'year';
|
||||
break;
|
||||
default:
|
||||
$this->view->weekSelected = 'selected="true"';
|
||||
$this->view->type = 'week';
|
||||
}
|
||||
|
||||
$this->view->rand = rand(0, 1000);
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
require_once 'libs/jpgraph/jpgraph.php';
|
||||
require_once 'libs/jpgraph/jpgraph_bar.php';
|
||||
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$graph = new Graph($this->_getParam('type') == 'month'? 400 : 300, 200 ,'auto');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->img->SetMargin(0,30,20,40);
|
||||
$graph->yaxis->scale->SetGrace(20);
|
||||
$graph->yaxis->HideLabels();
|
||||
$graph->yaxis->HideTicks();
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
|
||||
|
||||
$labelsy = array();
|
||||
$datay = array();
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'month':
|
||||
$this->_populateMonthData($labelsy, $datay);
|
||||
break;
|
||||
case 'year':
|
||||
$this->_populateYearData($labelsy, $datay);
|
||||
break;
|
||||
default:
|
||||
$this->_populateWeekData($labelsy, $datay);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetTickLabels($labelsy);
|
||||
$bplot = new BarPlot($datay);
|
||||
|
||||
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFormat('%d');
|
||||
$graph->Add($bplot);
|
||||
|
||||
$graph->Stroke();
|
||||
}
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
if (isset($registeredUsers[$date])) {
|
||||
$datay[] = $registeredUsers[$date]['users'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateMonthData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-30 days'), strtotime('-1 week'));
|
||||
|
||||
for ($i = -30; $i < -7; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = date('j', $time);
|
||||
if (isset($registeredUsers[$date])) {
|
||||
$datay[] = $registeredUsers[$date]['users'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$firstDayOfMonth = date('Y-' . date('m') . '-01');
|
||||
$registeredUsers = $stats->getNumRegisteredUsersYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time());
|
||||
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
if (isset($registeredUsers[$monthNumber])) {
|
||||
$datay[] = $registeredUsers[$monthNumber]['users'];
|
||||
} else {
|
||||
$datay[] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
168
modules/stats/controllers/SitesController.php
Normal file
168
modules/stats/controllers/SitesController.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_SitesController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->weekSelected = '';
|
||||
$this->view->yearSelected = '';
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->view->yearSelected = 'selected="true"';
|
||||
$this->view->type = 'year';
|
||||
break;
|
||||
default:
|
||||
$this->view->weekSelected = 'selected="true"';
|
||||
$this->view->type = 'week';
|
||||
}
|
||||
|
||||
$this->view->rand = rand(0, 1000);
|
||||
}
|
||||
|
||||
public function graphAction()
|
||||
{
|
||||
require_once 'libs/jpgraph/jpgraph.php';
|
||||
require_once 'libs/jpgraph/jpgraph_bar.php';
|
||||
require_once 'libs/jpgraph/jpgraph_line.php';
|
||||
|
||||
$this->_helper->viewRenderer->setNeverRender(true);
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$graph = new Graph(300,200 ,'auto');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->SetY2Scale("lin");
|
||||
$graph->img->SetMargin(0,30,20,50);
|
||||
$graph->yaxis->HideLabels();
|
||||
$graph->yaxis->HideTicks();
|
||||
$graph->yaxis->scale->SetGrace(20);
|
||||
$graph->y2axis->SetColor("black","red");
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
|
||||
|
||||
$labelsy = array();
|
||||
$datay = array();
|
||||
$datay2 = array();
|
||||
|
||||
switch ($this->_getParam('type')) {
|
||||
case 'year':
|
||||
$this->_populateYearData($labelsy, $datay, $datay2);
|
||||
break;
|
||||
default:
|
||||
$this->_populateWeekData($labelsy, $datay, $datay2);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetTickLabels($labelsy);
|
||||
|
||||
$bplot = new BarPlot($datay);
|
||||
$bplot->setLegend(utf8_decode($this->view->translate('Trusted sites')));
|
||||
$bplot->SetFillGradient("navy","lightsteelblue",GRAD_WIDE_MIDVER);
|
||||
$bplot->value->Show();
|
||||
$bplot->value->SetFormat('%d');
|
||||
|
||||
$p1 = new LinePlot($datay2);
|
||||
$p1->SetColor("red");
|
||||
$p1->SetLegend(utf8_decode($this->view->translate('Sites per user')));
|
||||
|
||||
$graph->Add($bplot);
|
||||
$graph->AddY2($p1);
|
||||
|
||||
$graph->legend->SetLayout(LEGEND_HOR);
|
||||
$graph->legend->Pos(0.5,0.99,"center","bottom");
|
||||
|
||||
$graph->Stroke();
|
||||
}
|
||||
|
||||
private function _populateWeekData(&$labelsy, &$datay, &$datay2)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$initialTrustedSites = $stats->getNumTrustedSites(strtotime('-1 week'));
|
||||
$initialRegisteredUsers = $stats->getNumRegisteredUsers(strtotime('-1 week'));
|
||||
|
||||
$sites = $stats->getNumTrustedSitesDays(strtotime('-1 week'), time());
|
||||
$numUsers = $stats->getNumRegisteredUsersDays(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -7; $i < 0; $i++) {
|
||||
$time = strtotime("$i days");
|
||||
$date = date('Y-m-d', $time);
|
||||
$labelsy[] = Stats::$weekDays[date('w', $time)];
|
||||
|
||||
if (isset($sites[$date])) {
|
||||
$sitesPeriod = $sites[$date]['site'];
|
||||
} else {
|
||||
$sitesPeriod = 0;
|
||||
}
|
||||
|
||||
if (isset($numUsers[$date])) {
|
||||
$usersPeriod = $numUsers[$date]['users'];
|
||||
} else {
|
||||
$usersPeriod = 0;
|
||||
}
|
||||
|
||||
if ($i > -7) {
|
||||
$datay[] = $datay[$i + 6] + $sitesPeriod;
|
||||
$datay2[] = $datay2[$i + 6] + $usersPeriod;
|
||||
} else {
|
||||
$datay[] = $initialTrustedSites + $sitesPeriod;
|
||||
$datay2[] = $initialRegisteredUsers + $usersPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($datay2); $i++) {
|
||||
$datay2[$i] = round($datay[$i] / $datay2[$i], 2);
|
||||
}
|
||||
}
|
||||
|
||||
private function _populateYearData(&$labelsy, &$datay, &$datay2)
|
||||
{
|
||||
$stats = new Stats();
|
||||
$initialTrustedSites = $stats->getNumTrustedSites(strtotime('-1 week'));
|
||||
$initialRegisteredUsers = $stats->getNumRegisteredUsers(strtotime('-1 week'));
|
||||
|
||||
$firstDayOfMonth = date('Y-' . date('m') . '-01');
|
||||
|
||||
$sites = $stats->getNumTrustedSitesYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time());
|
||||
$numUsers = $stats->getNumRegisteredUsersYear(strtotime('-1 week'), time());
|
||||
|
||||
for ($i = -11; $i <= 0; $i++) {
|
||||
$time = strtotime("$i months");
|
||||
$monthNumber = date('n', $time);
|
||||
$labelsy[] = Stats::$months[$monthNumber];
|
||||
|
||||
if (isset($sites[$monthNumber])) {
|
||||
$sitesPeriod = $sites[$monthNumber]['site'];
|
||||
} else {
|
||||
$sitesPeriod = 0;
|
||||
}
|
||||
|
||||
if (isset($numUsers[$monthNumber])) {
|
||||
$usersPeriod = $numUsers[$monthNumber]['users'];
|
||||
} else {
|
||||
$usersPeriod = 0;
|
||||
}
|
||||
|
||||
if ($i > -11) {
|
||||
$datay[] = $datay[$i + 10] + $sitesPeriod;
|
||||
$datay2[] = $datay2[$i + 10] + $usersPeriod;
|
||||
} else {
|
||||
$datay[] = $initialTrustedSites + $sitesPeriod;
|
||||
$datay2[] = $initialRegisteredUsers + $usersPeriod;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($datay2); $i++) {
|
||||
$datay2[$i] = round($datay[$i] / $datay2[$i], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
modules/stats/controllers/TopController.php
Normal file
19
modules/stats/controllers/TopController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkey Ltd
|
||||
* @since CommunityID 0.9
|
||||
* @package CommunityID
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
class Stats_TopController extends Monkeys_Controller_Action
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$stats = new Stats();
|
||||
$this->view->sites = $stats->getTopTenSites();
|
||||
}
|
||||
}
|
161
modules/stats/models/Stats.php
Normal file
161
modules/stats/models/Stats.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
|
||||
* @license http://creativecommons.org/licenses/BSD/ BSD License
|
||||
* @author Keyboard Monkeys Ltd.
|
||||
* @since Textroller 0.9
|
||||
* @package TextRoller
|
||||
* @packager Keyboard Monkeys
|
||||
*/
|
||||
|
||||
|
||||
class Stats
|
||||
{
|
||||
private $_db;
|
||||
|
||||
static public $weekDays = array('S', 'M', 'T', 'W', 'T', 'F', 'S');
|
||||
static public $months = array(1 => 'J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D');
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_db = Zend_Registry::get('db');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumRegisteredUsersDays($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('users', array('registration_date' => 'registration_date', 'users' => 'COUNT(registration_date)'))
|
||||
->where('registration_date >= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('registration_date < ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('registration_date')
|
||||
->order('registration_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumRegisteredUsersYear($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('users', array('registration_date' => 'MONTH(registration_date)', 'users' => 'COUNT(MONTH(registration_date))'))
|
||||
->where('registration_date >= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('registration_date <= ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('MONTH(registration_date)')
|
||||
->order('registration_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumRegisteredUsers($unixDate)
|
||||
{
|
||||
$select = $this->_db->select()->from('users')
|
||||
->where('registration_date < ?', strftime('%Y-%m-%d', $unixDate));
|
||||
|
||||
|
||||
$statement = $this->_db->prepare($select);
|
||||
$statement->execute();
|
||||
|
||||
return $statement->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getAllTestUsersIds()
|
||||
{
|
||||
$select = $this->_db->select()->from('users', 'id');
|
||||
|
||||
return $this->_db->fetchAll($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumAuthorizationsDays($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('history', array('date' => 'DATE(date)', 'entry' => 'COUNT(DATE(date))'))
|
||||
->where('date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('date< ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('DATE(date)')
|
||||
->order('date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumAuthorizationsYear($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('history', array('date' => 'MONTH(date)', 'entry' => 'COUNT(MONTH(date))'))
|
||||
->where('date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('date<= ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('MONTH(date)')
|
||||
->order('date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumTrustedSites($unixDate)
|
||||
{
|
||||
$select = $this->_db->select()->from('sites')
|
||||
->where('creation_date < ?', strftime('%Y-%m-%d', $unixDate));
|
||||
|
||||
|
||||
$statement = $this->_db->prepare($select);
|
||||
$statement->execute();
|
||||
|
||||
return $statement->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumTrustedSitesDays($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('sites', array('creation_date' => 'creation_date', 'site' => 'COUNT(creation_date)'))
|
||||
->where('creation_date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('creation_date< ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('creation_date')
|
||||
->order('creation_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getNumTrustedSitesYear($unixDateStart, $unixDateEnd)
|
||||
{
|
||||
$select = $this->_db->select()->from('sites', array('creation_date' => 'MONTH(creation_date)', 'site' => 'COUNT(MONTH(creation_date))'))
|
||||
->where('creation_date>= ?', strftime('%Y-%m-%d', $unixDateStart))
|
||||
->where('creation_date<= ?', strftime('%Y-%m-%d', $unixDateEnd))
|
||||
->group('MONTH(creation_date)')
|
||||
->order('creation_date');
|
||||
|
||||
return $this->_db->fetchAssoc($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Array
|
||||
*/
|
||||
public function getTopTenSites()
|
||||
{
|
||||
$select = $this->_db->select()->from('sites', array('num' => 'COUNT(site)', 'site' => 'site'))
|
||||
->group('site')
|
||||
->order('num DESC')
|
||||
->limit(10);
|
||||
|
||||
return $this->_db->fetchAll($select);
|
||||
}
|
||||
}
|
10
modules/stats/views/scripts/authorizations/index.phtml
Normal file
10
modules/stats/views/scripts/authorizations/index.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<h3><?= $this->translate('Authorizations per day') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<select name="view" onchange="COMMID.stats.loadReport('authorizations', 'statsAuths', 'type=' + this.value)">
|
||||
<option value="week" <?= $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="year" <?= $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/authorizations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
||||
|
24
modules/stats/views/scripts/index/index.phtml
Normal file
24
modules/stats/views/scripts/index/index.phtml
Normal file
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
COMMID.loader.insert(
|
||||
["connection"],
|
||||
function() {
|
||||
COMMID.stats.loadReport("registrations", "statsRegs");
|
||||
COMMID.stats.loadReport("authorizations", "statsAuths");
|
||||
COMMID.stats.loadReport("sites", "statsNumTrustedSites");
|
||||
COMMID.stats.loadReport("top", "statsTopTen");
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="yui-g">
|
||||
<div class="yui-u first">
|
||||
<div id="statsRegs"></div>
|
||||
<div id="statsNumTrustedSites"></div>
|
||||
</div>
|
||||
<div class="yui-u">
|
||||
<div id="statsAuths"></div>
|
||||
<div id="statsTopTen"></div>
|
||||
</div>
|
||||
</div>
|
10
modules/stats/views/scripts/registrations/index.phtml
Normal file
10
modules/stats/views/scripts/registrations/index.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<h3><?= $this->translate('Registrations per day') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<select name="view" onchange="COMMID.stats.loadReport('registrations', 'statsRegs', 'type=' + this.value)">
|
||||
<option value="week" <?= $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="month" <?= $this->monthSelected ?>><?= $this->translate('Last Month') ?></option>
|
||||
<option value="year" <?= $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/registrations/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
9
modules/stats/views/scripts/sites/index.phtml
Normal file
9
modules/stats/views/scripts/sites/index.phtml
Normal file
@ -0,0 +1,9 @@
|
||||
<h3><?= $this->translate('Trusted Sites') ?></h3>
|
||||
<div>
|
||||
<?= $this->translate('Select view') ?>:
|
||||
<select name="view" onchange="COMMID.stats.loadReport('sites', 'statsNumTrustedSites', 'type=' + this.value)">
|
||||
<option value="week" <?= $this->weekSelected ?>><?= $this->translate('Last Week') ?></option>
|
||||
<option value="year" <?= $this->yearSelected ?>><?= $this->translate('Last Year') ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<img src="<?= $this->base ?>/stats/sites/graph?rand=<?= $this->rand ?>&type=<?= $this->type ?>" />
|
10
modules/stats/views/scripts/top/index.phtml
Normal file
10
modules/stats/views/scripts/top/index.phtml
Normal file
@ -0,0 +1,10 @@
|
||||
<h3><?= $this->translate('Top 10 Trusted Sites') ?></h3>
|
||||
<table id="topTenTable">
|
||||
<? foreach ($this->sites as $num => $siteInfo): ?>
|
||||
<tr>
|
||||
<td><?= $num + 1 ?></td>
|
||||
<td><?= $siteInfo['site'] ?></td>
|
||||
<td>(<?= $this->translate('%s users', $siteInfo['num']) ?>)</td>
|
||||
</tr>
|
||||
<? endforeach ?>
|
||||
</table>
|
Reference in New Issue
Block a user