<?php
// Show latest AkoComments 
// Author : Nils Feberwee - mambo@feberwee.de

// Modulsettings
  $titlelenght = "15"; 		// If the title is longer than the value, it will be cut
  $titlecut = "15"; 		// The titlelenght after cutting
  $commentlenght = "100"; 	// If the comment is longer than the value, it will be cut
  $commentcut = "100";  	// The commentlenght after cutting
  $showname = true;    		// Should postername be displayed (true / false )
  $date = true; 			// Creation date is shown (true / false)
  $number = "4";			// The number of shown comments

// Don't allow direct access to the file
  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

// Clear content
  $content = "";

// Set up database query
  $query = "SELECT contentid, name, title, comment, date FROM #__akocomment "
         . "WHERE published='1' "
         . "ORDER BY date DESC LIMIT ".$number."";
       
// Start database query        
  $database->setQuery($query);
  $rows =$database->loadObjectList();

// Display the stuff on screen
  $content .="<table cellpadding='1' cellspacing ='0 'border='0'>";
  
  foreach($rows as $row) {
  
 	  // Checking titlelenght 
 	  if(strlen($row->title) > $titlelenght) {
      $row->title  = substr($row->title,0,$titlecut);
      $row->title .= "...";
      }	 
  
      // Checking commentlenght
      if(strlen($row->comment) > $commentlenght) {
      $row->comment  = substr($row->comment,0,$commentcut);
      $row->comment .= "...";
      }
	
	$content .= "<tr><td valign='top'><img src='modules/mod_latestcomments/bullet.gif' alt=' '/><a href=\"index.php?option=content&task=view&id=".$row->contentid."\"> <b>".stripslashes($row->title)."</b></a>";
    $content .= "<br /><font class='smalldark'>".stripslashes($row->comment)."</font>";
    if ($showname) $content .= "<br /><b>Posted by: </b><font class='smalldark'>".stripslashes($row->name)."</font>";
	if ($date) $content.= "<br />[".$row->date."]";
    $content .= "</td></tr>";
  }
   $content .="</table>";
?>
