<?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>
');

?>
