comments_admin_statistic.php
1.87 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
<?php
// блок статистики
function comments_admin_statistic($options){
global $MAIN_DB;
// Рефакторинг
$MAIN_DB -> set_prefix('lc');
// -- -- --
include_once(MAIN_SOURCE_PATH.'/modules/admin/inc/class.modules.php');
include_once(MAIN_SOURCE_PATH.'/modules/admin/inc/url.php');
include_once(MAIN_SOURCE_PATH.'/inc/class.comments.php');
$c_modules = array();
$count_all = $count_on_day = $count_wait = 0;
$m = new modulesQuery('m');
$m -> get('m.m_path,m.m_name',false);
while( $row = $m -> row() ){
$mod = modules::load_path($row['m_path']);
// модуль загрузить не удалось
if (false===$mod){
continue;
$path = $mod -> path();
}
// модуль не поддерживает работу с комментариями
if ( false===$mod -> exists_comments() ){
continue;
}
include_once(MAIN_SOURCE_PATH.'/modules/'.$row['m_path'].'/inc/class.comments.php');
$class = $row['m_path'].'_comments_q';
$s = $class::create();
$count_all+=$s -> count_all();
$count_on_day+=$s -> count_on_day();
$count_wait+=$s -> count_wait();
}
$t = new PHPTAL( false );
$t -> setSource(TMPL_COMMENTS_ADMIN_STAT);
$t -> count_all = $count_all;
$t -> count_on_day = $count_on_day;
$t -> count_wait = $count_wait;
$t -> comments_control_url = sys_url(URL_ADMIN_COMMENTS);
$t -> comments_control_wait_url = sys_url(URL_ADMIN_COMMENTS_FILTER_URL,0,0,0,0,0);
return $t -> execute();
}
define("TMPL_COMMENTS_ADMIN_STAT",
'
<div style="margin:5px;width:30%;border:1px solid gray;float:left">
<h3>${B_COMMENTS_NAME}</h3>
<p>${B_COMMENTS_ALL_ARTICLES}: <a href="${comments_control_url}">${count_all}</a></p>
<p>${B_COMMENTS_NEW_ON_DAY}: ${count_on_day}</p>
<p tal:condition="count_wait" style="color:red">${B_COMMENTS_WAIT}: <a href="${comments_control_wait_url}">${count_wait}</a></p>
</div>
');
?>