-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stats.template.php
383 lines (331 loc) · 9.46 KB
/
Stats.template.php
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?php
/**
* @name ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause
*
* This software is a derived product, based on:
*
* Simple Machines Forum (SMF)
* copyright: 2011 Simple Machines (http://www.simplemachines.org)
* license: BSD, See included LICENSE.TXT for terms and conditions.
*
* @version 1.0
*
*/
/**
* Stats page.
*/
function template_statistics()
{
global $context;
echo '
<div id="statistics" class="forum_category">
<h2 class="category_header">
', $context['page_title'], '
</h2>
<ul class="statistics">';
foreach ($context['statistics_callbacks'] as $callback)
{
$function = 'template_' . $callback;
$function();
}
echo '
</ul>
</div>';
template_forum_history();
}
/**
* Used to show the general statistics blocks
*/
function template_general_statistics()
{
global $context, $settings, $txt;
// These two are special formatting strings for special elements of the statistics:
// The most_online value is an array composed of two elements: number and date,
// they will be replaced in the foreach below with the corresponding values.
// If you want to change the way to present the field, change this string,
// for example if you want to show it as: "123 members on the 20/01/2010" you could use:
// $settings['most_online'] = 'number members on the date';
$settings['most_online'] = 'number - date';
// Similarly to the previous one, this is a "template" for the latest_member stats
// The elements available to style this entry are: id, name, href, link.
// So, if you want to change it to the plain username you could use:
// $settings['latest_member'] = 'name';
$settings['latest_member'] = 'link';
echo '
<li class="flow_hidden" id="top_row">
<h3 class="category_header hdicon cat_img_stats_info">
', $txt['general_stats'], '
</h3>
<dl class="stats floatleft">';
foreach ($context['general_statistics']['left'] as $key => $value)
{
if (is_array($value))
{
if (isset($settings[$key]))
$value = strtr($settings[$key], $value);
else
continue;
}
echo '
<dt>', $txt[$key], ':</dt>
<dd>', $value, '</dd>';
}
echo '
</dl>
<dl class="stats">';
foreach ($context['general_statistics']['right'] as $key => $value)
{
if (is_array($value))
{
if (isset($settings[$key]))
$value = strtr($settings[$key], $value);
else
continue;
}
echo '
<dt>', $txt[$key], ':</dt>
<dd>', $value, '</dd>';
}
echo '
</dl>
</li>';
}
/**
* Shows "top" statistics, like top posters, top boards, top replies, etc
*/
function template_top_statistics()
{
global $context, $txt;
echo '
<li class="flow_hidden">
<h3 class="category_header floatleft hdicon cat_img_star">
', $txt['top_posters'], '
</h3>
<dl class="stats floatleft">';
foreach ($context['top']['posters'] as $poster)
{
echo '
<dt>
', $poster['link'], '
</dt>
<dd class="statsbar">
<div class="bar" style="width: ', !empty($poster['post_percent']) ? $poster['post_percent'] : '0', 'px;"></div>
<span class="righttext">', $poster['num_posts'], '</span>
</dd>';
}
echo '
</dl>
<h3 class="category_header hdicon cat_img_topics">
', $txt['top_boards'], '
</h3>
<dl class="stats">';
foreach ($context['top']['boards'] as $board)
{
echo '
<dt>
', $board['link'], '
</dt>
<dd class="statsbar">
<div class="bar" style="width: ', !empty($board['post_percent']) ? $board['post_percent'] : '0', 'px;"></div>
<span class="righttext">', $board['num_posts'], '</span>
</dd>';
}
echo '
</dl>
</li>
<li class="flow_hidden">
<h3 class="category_header floatleft hdicon cat_img_talk">
', $txt['top_topics_replies'], '
</h3>
<dl class="stats floatleft">';
foreach ($context['top']['topics_replies'] as $topic)
{
echo '
<dt>
', $topic['link'], '
</dt>
<dd class="statsbar">
<div class="bar" style="width: ', !empty($topic['post_percent']) ? $topic['post_percent'] : '0', 'px;"></div>
<span class="righttext">' . $topic['num_replies'] . '</span>
</dd>';
}
echo '
</dl>
<h3 class="category_header hdicon cat_img_eye">
', $txt['top_topics_views'], '
</h3>
<dl class="stats">';
foreach ($context['top']['topics_views'] as $topic)
{
echo '
<dt>', $topic['link'], '</dt>
<dd class="statsbar">
<div class="bar" style="width: ', !empty($topic['post_percent']) ? $topic['post_percent'] : '0', 'px;"></div>
<span class="righttext">' . $topic['num_views'] . '</span>
</dd>';
}
echo '
</dl>
</li>
<li class="flow_hidden">
<h3 class="category_header floatleft hdicon cat_img_write">
', $txt['top_starters'], '
</h3>
<dl class="stats floatleft">';
foreach ($context['top']['starters'] as $poster)
{
echo '
<dt>
', $poster['link'], '
</dt>
<dd class="statsbar">
<div class="bar" style="width: ', !empty($poster['post_percent']) ? $poster['post_percent'] : '0', 'px;"></div>
<span class="righttext">', $poster['num_topics'], '</span>
</dd>';
}
echo '
</dl>
<h3 class="category_header hdicon cat_img_clock">
', $txt['most_time_online'], '
</h3>
<dl class="stats">';
foreach ($context['top']['time_online'] as $poster)
{
echo '
<dt>
', $poster['link'], '
</dt>
<dd class="statsbar">
<div class="bar" style="width: ', !empty($poster['time_percent']) ? $poster['time_percent'] : '0', 'px;"></div>
<span class="righttext">', $poster['time_online'], '</span>
</dd>';
}
echo '
</dl>
</li>';
}
/**
* Shows the forum history, year/month breakdown of activity such as topics, posts, members, etc
*/
function template_forum_history()
{
global $context, $settings, $txt, $modSettings;
echo '
<div id="forum_history" class="forum_category">
<h2 class="category_header hdicon cat_img_clock">
', $txt['forum_history'], '
</h2>
<div class="flow_hidden">';
if (!empty($context['yearly']))
{
echo '
<table class="table_grid" id="stats">
<thead>
<tr>
<th class="history_head lefttext">', $txt['yearly_summary'], '</th>
<th class="history_head">', $txt['stats_new_topics'], '</th>
<th class="history_head">', $txt['stats_new_posts'], '</th>
<th class="history_head">', $txt['stats_new_members'], '</th>
<th class="history_head">', $txt['most_online'], '</th>';
if (!empty($modSettings['hitStats']))
echo '
<th class="history_head">', $txt['page_views'], '</th>';
echo '
</tr>
</thead>
<tbody>';
foreach ($context['yearly'] as $id => $year)
{
echo '
<tr id="year_', $id, '">
<th class="stats_year lefttext">
<img id="year_img_', $id, '" src="', $settings['images_url'], '/selected_open.png" alt="*" /> <a href="#year_', $id, '" id="year_link_', $id, '">', $year['year'], '</a>
</th>
<th>', $year['new_topics'], '</th>
<th>', $year['new_posts'], '</th>
<th>', $year['new_members'], '</th>
<th>', $year['most_members_online'], '</th>';
if (!empty($modSettings['hitStats']))
echo '
<th>', $year['hits'], '</th>';
echo '
</tr>';
foreach ($year['months'] as $month)
{
echo '
<tr id="tr_month_', $month['id'], '">
<th class="stats_month lefttext">
<img src="', $settings['images_url'], '/', $month['expanded'] ? 'selected_open.png' : 'selected.png', '" alt="" id="img_', $month['id'], '" /> <a id="m', $month['id'], '" href="', $month['href'], '">', $month['month'], ' ', $month['year'], '</a>
</th>
<th>', $month['new_topics'], '</th>
<th>', $month['new_posts'], '</th>
<th>', $month['new_members'], '</th>
<th>', $month['most_members_online'], '</th>';
if (!empty($modSettings['hitStats']))
echo '
<th>', $month['hits'], '</th>';
echo '
</tr>';
if ($month['expanded'])
{
foreach ($month['days'] as $day)
{
echo '
<tr id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
<td class="stats_day lefttext">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td>', $day['new_topics'], '</td>
<td>', $day['new_posts'], '</td>
<td>', $day['new_members'], '</td>
<td>', $day['most_members_online'], '</td>';
if (!empty($modSettings['hitStats']))
echo '
<td>', $day['hits'], '</td>';
echo '
</tr>';
}
}
}
}
echo '
</tbody>
</table>
</div>
</div>
<script><!-- // --><![CDATA[
var oStatsCenter = new elk_StatsCenter({
sTableId: \'stats\',
reYearPattern: /year_(\d+)/,
sYearImageCollapsed: \'selected.png\',
sYearImageExpanded: \'selected_open.png\',
sYearImageIdPrefix: \'year_img_\',
sYearLinkIdPrefix: \'year_link_\',
reMonthPattern: /tr_month_(\d+)/,
sMonthImageCollapsed: \'selected.png\',
sMonthImageExpanded: \'selected_open.png\',
sMonthImageIdPrefix: \'img_\',
sMonthLinkIdPrefix: \'m\',
reDayPattern: /tr_day_(\d+-\d+-\d+)/,
sDayRowClassname: \'windowbg2\',
sDayRowIdPrefix: \'tr_day_\',
aCollapsedYears: [';
foreach ($context['collapsed_years'] as $id => $year)
{
echo '
\'', $year, '\'', $id != count($context['collapsed_years']) - 1 ? ',' : '';
}
echo '
],
aDataCells: [
\'date\',
\'new_topics\',
\'new_posts\',
\'new_members\',
\'most_members_online\'', empty($modSettings['hitStats']) ? '' : ',
\'hits\'', '
]
});
// ]]></script>';
}
}