<?php
/**
* JComments - Joomla Comment System
*
* Show top comment posters for JComments
*
* @version 1.0
* @package JComments
* @filename mod_jcomments_top.php
* @author Sergey M. Litvinov (
smart@joomlatune.ru)
* @copyright (C) 2006-2008 by Sergey M. Litvinov (
http://www.joomlatune.ru)
* @license GNU/GPL:
http://www.gnu.org/copyleft/gpl.html *
* If you fork this to create your own project,
* please make a reference to JComments someplace in your code
* and provide a link to
http://www.joomlatune.ru **/
(defined('_VALID_MOS') OR defined('_JEXEC')) or die('Direct Access to this location is not allowed.');
global $database;
$count = intval( $params->get( 'count', 5 ) );
$avatar = intval( $params->get( 'avatar', 0 ) );
$profile_link = intval( $params->get( 'profile_link', 0 ) );
$display_name = $params->get('display_name', 'name');
$display_guests = intval( $params->get( 'display_guests', 1 ) );
$database =& JFactory::getDBO();
$query = "SELECT c.userid, c.email, c.name, c.username, '' as avatar, '' as profileLink, count(c.userid) AS cnt"
."\nFROM #__jcomments AS c"
."\nWHERE c.published = 1"
. (($display_guests == 0) ? "\nAND c.userid != 0" : '')
."\nGROUP BY c.userid, c.email, c.name, c.username, avatar, profileLink"
."\nORDER BY cnt DESC LIMIT $count "
;
$database->setQuery($query);
$rows = $database->loadObjectList();
$a=1;
if (count($rows)) {
if ($avatar == 1) {
JPluginHelper::importPlugin('jcomments');
if (!JPluginHelper::isEnabled('jcomments', 'jcomments.avatar')) {
$avatar = 0;
$profile_link = 0;
} else {
$dispatcher = & JDispatcher::getInstance();
$dispatcher->trigger('onPrepareAvatars', array ( &$rows ), false );
}
}
?>
<table border="0"><tr>
<style>
td.avatar img {
//width:40px;
height:40px;
}
</style>
<?php
foreach ($rows as $row) {
if ($avatar == 1) {
?>
<td align="center" width="20%" class="avatar"><?php echo $row->avatar; ?></td><td width="80%">
<?php
} else {
}
$name = $row->name;
if ( $row->userid && $display_name == 'username' && $row->username != '' ) {
$name = $row->username;
}
if ($profile_link && $row->profileLink != '') {
echo $a;
echo '. ';
?>
<a href="<?php echo $row->profileLink; ?>"><?php echo $name; ?></a>
<?php
} else {
echo $a;
echo '. ';
echo $name;
}
echo ' (' . $row->cnt . ')';
$a++;
echo '</td></tr>';
}
?>
</table>
<?php
}
?>