<?php
/**
* @author:  Bunzia Alexander <nifus@mail.ru> <http://www.weblancer.net/users/nifus/>
* @copyright: Copyright (c) 2010, Bunzia Alexander
* @version: 1.0
* @license: http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @package: ПоРемонту.Ру
*/

function news_most_comments($options){
	$t = new PHPTAL( false );
	$t -> setSource(TMPL_NEWS_MOSTCOMMENTS_BLOCK);
	include_once(MAIN_SOURCE_PATH.'/modules/news/inc/url.php');
	include_once(MAIN_SOURCE_PATH.'/modules/news/inc/class.news.php');
	$n = new news_q('n');
	$n -> orderby_count_comments('DESC');
	$n -> set_page(1);
	$n -> set_count_rows(8);
	$n -> where_active(1);
	//$n -> set_debug(1);
	$n -> get('n_title,n_alias as news_url',false);
	$rows = array();
	while( $row = $n -> row() ){
		$rows[]=$row;
	}
	$t -> rows  = $rows;
	$t -> URL_NEWS_MCOMMENTS_LISTING = URL_NEWS_MCOMMENTS_LISTING;
  return $t -> execute();
}

define('TMPL_NEWS_MOSTCOMMENTS_BLOCK','
	<h3><a href="${URL_NEWS_MCOMMENTS_LISTING}">${B_NEWS_MCOMMENTS_LISTING}</a></h3>
	<ul>
	  <li tal:condition="rows" tal:repeat="r rows"><a target="_blank" href="${r/news_url}">${r/n_title}</a></li>
	</ul>
'
);


?>
