import v2.0.0.0_RC3 | 2012-07-01

https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
2019-07-17 22:31:04 +02:00
parent 38c146901c
commit 2f397f01f7
2677 changed files with 296182 additions and 45159 deletions

View File

@ -1,106 +0,0 @@
<?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 CommunityID_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_Model_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_Model_Stats::$weekDays[date('w', $time)];
if (isset($authorizations[$date])) {
$datay[] = $authorizations[$date]['entry'];
} else {
$datay[] = 0;
}
}
}
private function _populateYearData(&$labelsy, &$datay)
{
$stats = new Stats_Model_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_Model_Stats::$months[$monthNumber];
if (isset($authorizations[$monthNumber])) {
$datay[] = $authorizations[$monthNumber]['entry'];
} else {
$datay[] = 0;
}
}
}
}

View File

@ -1,7 +1,7 @@
<?php
/*
* @copyright Copyright (C) 2005-2009 Keyboard Monkeys Ltd. http://www.kb-m.com
* @copyright Copyright (C) 2005-2010 Keyboard Monkeys Ltd. http://www.kb-m.com
* @license http://creativecommons.org/licenses/BSD/ BSD License
* @author Keyboard Monkey Ltd
* @since CommunityID 0.9
@ -11,9 +11,52 @@
class Stats_IndexController extends CommunityID_Controller_Action
{
const LOCATION_LEFT = 0;
const LOCATION_RIGHT = 1;
protected $_numCols = 1;
public function indexAction()
{
$statPlugins = array();
$this->view->pluginsLeft = array();
$this->view->pluginsRight = array();
$dir = dir(APP_DIR . Stats_Model_Report::STATS_PLUGIN_DIR);
$i = 0;
while (false !== ($entry = $dir->read())) {
if (in_array($entry, array('.', '..'))
|| substr($entry, -4) != '.php') {
continue;
}
try {
$reportName = substr($entry, 0, -4);
$statPlugins[$i] = Stats_Model_Report::getReportInstance($reportName);
$statPlugins[$i]->setView($this->view);
} catch (Monkeys_AccessDeniedException $ex) {
Zend_Registry::get('logger')->log("Unable to open Stats plugin: $entry", Zend_Log::WARN);
continue;
}
$i++;
}
$dir->close();
usort($statPlugins, array($this, '_sortPlugins'));
$location = self::LOCATION_LEFT;
foreach ($statPlugins as $statPlugin) {
if ($location == self::LOCATION_LEFT) {
$this->view->pluginsLeft[] = $statPlugin;
$location = self::LOCATION_RIGHT;
} else {
$this->view->pluginsRight[] = $statPlugin;
$location = self::LOCATION_LEFT;
}
}
}
private function _sortPlugins(Stats_Model_Report $pluginA, Stats_Model_Report $pluginB)
{
return $pluginA->getPriority() - $pluginB->getPriority();
}
}

View File

@ -1,130 +0,0 @@
<?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 CommunityID_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_Model_Stats();
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-1 week'), time(), true);
for ($i = -7; $i < 0; $i++) {
$time = strtotime("$i days");
$date = date('Y-m-d', $time);
$labelsy[] = Stats_Model_Stats::$weekDays[date('w', $time)];
if (isset($registeredUsers[$date])) {
$datay[] = $registeredUsers[$date]['users'];
} else {
$datay[] = 0;
}
}
}
private function _populateMonthData(&$labelsy, &$datay)
{
$stats = new Stats_Model_Stats();
$registeredUsers = $stats->getNumRegisteredUsersDays(strtotime('-30 days'), strtotime('-1 week'), true);
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_Model_Stats();
$firstDayOfMonth = date('Y-' . date('m') . '-01');
$registeredUsers = $stats->getNumRegisteredUsersYear(strtotime('-11 months', strtotime($firstDayOfMonth)), time(), true);
for ($i = -11; $i <= 0; $i++) {
$time = strtotime("$i months");
$monthNumber = date('n', $time);
$labelsy[] = Stats_Model_Stats::$months[$monthNumber];
if (isset($registeredUsers[$monthNumber])) {
$datay[] = $registeredUsers[$monthNumber]['users'];
} else {
$datay[] = 0;
}
}
}
}

View File

@ -0,0 +1,50 @@
<?php
/*
* @copyright Copyright (C) 2005-2010 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_ReportsController extends CommunityID_Controller_Action
{
public function indexAction()
{
$statPlugin = $this->_getPlugin();
$statPlugin->setTemplateVars();
$pluginView = clone $this->view;
$pluginView->plugin = $statPlugin;
$pluginView->setScriptPath(APP_DIR . Stats_Model_Report::STATS_PLUGIN_DIR);
$this->view->reportTitle = $statPlugin->getTitle();
$this->view->content = $pluginView->render($statPlugin->getClassName().'.phtml');
}
public function graphAction()
{
$this->_helper->viewRenderer->setNeverRender(true);
$this->_helper->layout->disableLayout();
$statPlugin = $this->_getPlugin();
$statPlugin->renderGraph();
}
private function _getPlugin()
{
$reportName = $this->_getParam('report');
try {
$statPlugin = Stats_Model_Report::getReportInstance($reportName);
} catch (Monkeys_AccessDeniedException $ex) {
throw new Exception("Unable to open Stats plugin: $entry");
}
$statPlugin->setControllerAction($this);
$statPlugin->setView($this->view);
return $statPlugin;
}
}

View File

@ -1,168 +0,0 @@
<?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 CommunityID_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_Model_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_Model_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_Model_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_Model_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);
}
}
}

View File

@ -1,19 +0,0 @@
<?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 CommunityID_Controller_Action
{
public function indexAction()
{
$stats = new Stats_Model_Stats();
$this->view->sites = $stats->getTopTenSites();
}
}