<?php
	if (!isset($gCms)) exit;

	$query = "SELECT comment_id, comment_author, comment_data, comment_date FROM ".cms_db_prefix()."module_comments WHERE page_id = ".$returnid." ORDER BY comment_date desc";
	if (isset($params["number"]))
	{
		$dbresult = $db->SelectLimit($query, $params['number']);
	}
	$dbresult = $db->Execute($query);

	$dateformat = "F j, Y, g:i a";
	if (isset($params['dateformat']))
	{
		$dateformat = $params['dateformat'];
	}
	
	#function CreateLink($id, $action, $returnid='', $contents='', $params=array(), $warn_message='', $onlyhref=false, $inline=false, $addttext='', $targetcontentonly=false)
	echo $this->CreateLink($id, 'addcomment', $returnid, $this->Lang('addacomment'), $params, '', false, true);

	if ($dbresult && $dbresult->RowCount())
	{
		while ($row = $dbresult->FetchRow())
		{
			echo "<div class=\"modulecommentsentry\">\n";
			echo "<div class=\"modulecommentsentryheader\">\n";
			echo "<span class=\"modulecommentsentrydate\">".date($dateformat, $db->UnixTimeStamp($row['comment_date']))."</span>";
			echo " - ";
			echo "<span class=\"modulecommentsentryauthor\">".$row['comment_author']."</span>\n";
			echo "</div>\n";
			echo "<div class=\"modulecommentsentrybody\">".nl2pnbr($row["comment_data"])."</div>\n";
			echo "</div>\n";
		}
	}


# vim:ts=4 sw=4 noet
?>
