This repository was archived by the owner on Feb 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.statisticsfooter.plugin.php
More file actions
154 lines (113 loc) · 4.86 KB
/
class.statisticsfooter.plugin.php
File metadata and controls
154 lines (113 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php if (!defined('APPLICATION')) exit();
//Original Plugin by @peregrine, Redistributed by VrijVlinder with Peregrine's permission.
class StatisticsFooterPlugin extends Gdn_Plugin {
public function __construct() {
}
public function assetModel_styleCss_handler($sender) {
$sender->addCssFile('sfooter.css', 'plugins/StatisticsFooter');
}
/*public function DiscussionsController_Render_Before($sender) {
$sender->AddCssFile('/plugins/StatisticsFooter/design/sfooter.css');
}
*/
public function discussionsController_AfterRenderAsset_Handler($sender) {
$AssetName = GetValueR('EventArguments.AssetName', $sender);
if ($AssetName != "Content") return;
$CurTime = time();
$LastTime = Gdn::Get('TimeCheck',$LastTime );
$SFVcount = Gdn::Get('ViewCount',$SFVcount );
$SFUcount = Gdn::Get('UserCount',$SFUcount);
$SFDcount = Gdn::Get('DiscussionCount',$SFDcount);
$SFCcount = Gdn::Get('CommentCount',$SFCcount);
// refresh counts every 60 seconds unless config is set
// e.g. $Configuration['Plugins']['StatisticsFooter']['Refresh'] = '90';
$IncSec = c('Plugins.StatisticsFooter.Refresh', 60);
if ($CurTime > $LastTime) {
$LastTime= time() + $IncSec ;
Gdn::Set('TimeCheck',$LastTime);
$SFVcount = $this->GetViewCount();
Gdn::Set('ViewCount',$SFVcount);
$SFUcount = $this->GetUserCount();
Gdn::Set('UserCount',$SFUcount);
$SFDcount = $this->GetDiscussionCount();
Gdn::Set('DiscussionCount',$SFDcount);
$SFCcount = $this->GetCommentCount();
Gdn::Set('CommentCount',$SFCcount);
}
$SFPcount = $SFDcount + $SFCcount;
$ShowMe = c('Plugins.StatisticsFooter.Show');
if (strpos($ShowMe, "v") !== FALSE)
echo Wrap(Wrap(T('View Count')) . $SFVcount, 'div', array('class' => 'SFBox SFVCBox'));
if (strpos($ShowMe, "u") !== FALSE)
echo Wrap(Wrap(T('User Count')) . $SFUcount, 'div', array('class' => 'SFBox SFUBox'));
if (strpos($ShowMe, "t") !== FALSE)
echo Wrap(Wrap(T('Topic Count')) . $SFDcount, 'div', array('class' => 'SFBox SFTBox'));
if (strpos($ShowMe, "c") !== FALSE)
echo Wrap(Wrap(T('Post Count')) . $SFPcount, 'div', array('class' => 'SFBox SFPBox'));
/*
if (strpos($ShowMe, "v") !== FALSE)
echo Wrap(Wrap(T('View Count')) . Gdn_Format::BigNumber($SFVcount), 'div', array('class' => 'SFBox SFVCBox'));
if (strpos($ShowMe, "u") !== FALSE)
echo Wrap(Wrap(T('User Count')) . Gdn_Format::BigNumber($SFUcount), 'div', array('class' => 'SFBox SFUBox'));
if (strpos($ShowMe, "t") !== FALSE)
echo Wrap(Wrap(T('Topic Count')) . Gdn_Format::BigNumber($SFDcount), 'div', array('class' => 'SFBox SFTBox'));
if (strpos($ShowMe, "c") !== FALSE)
echo Wrap(Wrap(T('Post Count')) . Gdn_Format::BigNumber($SFPcount), 'div', array('class' => 'SFBox SFPBox'));
*/
}
public function GetUserCount(){
$UModel = new Gdn_Model('User');
return $UModel->SQL
->Where("Deleted <","1")
->GetCount('User');
}
public function GetViewCount(){
$DModel = new Gdn_Model('Discussion');
$sender->UserData = $DModel->SQL
->Select('Sum(CountViews) AS SumViewCount')
->From('Discussion')
->Get();
$Result = $sender->UserData->Result();
return current((array)$Result[0]);
}
public function GetDiscussionCount(){
$VModel = new Gdn_Model('Discussion');
return $VModel->SQL
->GetCount('Discussion');
}
public function GetCommentCount(){
$CModel = new Gdn_Model('Comment');
return $CModel->SQL
->GetCount('Comment');
}
/*public function CategoriesController_Render_Before($sender) {
$this->DiscussionsController_Render_Before($sender);
}
*/
public function CategoriesController_AfterRenderAsset_Handler($sender) {
$this->DiscussionsController_AfterRenderAsset_Handler($sender);
}
public function PluginController_StatisticsFooter_Create($sender) {
$sender->Title('Statistics Footer');
$sender->AddSideMenu('plugin/statisticsfooter');
$sender->Permission('Garden.Settings.Manage');
$sender->Form = new Gdn_Form();
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Plugins.StatisticsFooter.Show',
));
$sender->Form->SetModel($ConfigurationModel);
if ($sender->Form->AuthenticatedPostBack() === FALSE) {
$sender->Form->SetData($ConfigurationModel->Data);
} else {
$Data = $sender->Form->FormValues();
if ($sender->Form->Save() !== FALSE)
$sender->StatusMessage = T("Your settings have been saved.");
}
$sender->render('sf-settings', '', 'plugins/StatisticsFooter');
//$sender->Render($this->GetView('sf-settings.php'));
}
public function Setup() {
}
}