<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: comments_panel_inclide
| Author: Paslaptinga
| Web : http://*a?*/
+--------------------------------------------------------+*/

if (!defined("IN_FUSION")) { die("Access Denied"); }
if (file_exists(INFUSIONS."comments_panel_include/locale/".$settings['locale'].".php")) {
   include INFUSIONS."comments_panel_include/locale/".$settings['locale'].".php";
} else {
   include INFUSIONS."comments_panel_include/locale/Lithuanian.php";
}

$com_per_page = "5"; // Number of comments to show

openside("".$locale['c100'].""); 
include_once INCLUDES."bbcode_include.php";
$i = 0;
$result = dbquery(
"SELECT * FROM ".DB_COMMENTS." LEFT JOIN ".DB_USERS."
ON ".DB_COMMENTS.".comment_name=".DB_USERS.".user_id
ORDER BY comment_datestamp DESC LIMIT $com_per_page"
);
if (dbrows($result)) {
echo "<table width='100%' cellpadding='0' cellspacing='0'>";

while ($data = dbarray($result)) {
echo "<tr>\n<td class='".($i% 2==0?"tbl1":"tbl2")."'>";
echo "<span class='side-small'>";
echo ($data['user_avatar'] ? "<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' ><img width='30' height='30' src='".BASEDIR."images/avatars/".$data['user_avatar']."' alt='' style='float: left; padding: 0 4px 4px 0;' border='0'/></a>" : "<a href='".BASEDIR."profile.php?lookup=".$data['user_id']."' ><img width='30' height='30' src='".INFUSIONS."comments_panel_include/images/no-avatar.jpg' alt='' style='float: left;padding: 0 4px 4px 0;' border='0'/></a>");
echo ($data['user_name'] ? " <a href='".BASEDIR."profile.php?lookup=".$data['comment_name']."'>".$data['user_name']."</a>" : $data['comment_name']."");

$comment_message = trimlink($data['comment_message'], 55);
$comment_item_id = $data['comment_item_id'];
$comment_type = $data['comment_type'];
$comment_message = parseubb(parsesmileys($comment_message), "thanks|b|i|u|url|color|quote|code|blink|leech"); // b|i|u|url|color = bbcodes to be parsed

echo " ".$locale['global_071'].showdate("longdate", $data['comment_datestamp'])."<br />".$comment_message."";

// Default PHP-Fusion Comment types
if ($data['comment_type'] == "N") {
echo " <a class='side' href='".BASEDIR."news.php?readmore=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
else if ($data['comment_type'] == "A") {
echo " <a class='side' href='".BASEDIR."articles.php?article_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}

else if ($data['comment_type'] == "C") {
echo " <a class='side' href='".BASEDIR."viewpage.php?page_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}

else if ($data['comment_type'] == "P") {
echo " <a class='side' href='".BASEDIR."photogallery.php?photo_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}

//Custom Comment types
else if ($data['comment_type'] == "U") {
echo " <a class='side' href='".BASEDIR."profile.php?lookup=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
//Custom siunntimu types
else if ($data['comment_type'] == "F") {
echo " <a class='side' href='".BASEDIR."downloads.php?page_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
//Custom balsavimas types
else if ($data['comment_type'] == "PK") {
echo " <a class='side' href='".INFUSIONS."member_poll_panel/polls_comments.php?viewpoll_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
//Projektas types
else if ($data['comment_type'] == "TD") {
echo " <a class='side' href='".BASEDIR."todo.php?todo_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
//Custom balsavimas types
else if ($data['comment_type'] == "") {
echo " <a class='side' href='".INFUSIONS."member_poll_panel/polls_comments.php?viewpoll_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
//Projektas types
else if ($data['comment_type'] == "") {
echo " <a class='side' href='".INFUSIONS."member_poll_panel/polls_comments.php?viewpoll_id=".$data['comment_item_id']."#c".$data['comment_id']."'> <strong>".$locale['global_072']."</strong></a>";
}
else { //If it can't figure out what comment type this is
   echo " <strong>(N/N)</strong>";
}
echo "</span>";
echo "</td>\n</tr>\n";
$i++;
}

echo "</table>";
} else {
echo "<center><br />".$locale['c101']."<br /><br /></center>\n";
}
closeside();

?>
