<?php /** * This plugin can be used to display a list of articles that were recently commented on. skinvar plugin can have a blogname as second parameter, a list type as third parameter and the date as fourth parameter Updates and documentation can be found here on the Nucleus Wiky: http://wakka.xiffy.nl/latestdisc History: v0.1 - initial plugin made by Radek Hulan, http://hulan.info/blog v0.2 - options added by marza to: - display links in list form - make display of date optional - specify blog for which comment links must be displayed - display number of comments for each item Todo: - add support for fancier urls */ class NP_LatestDisc extends NucleusPlugin { function getEventList() { return array(); } function getName() { return 'Latest Discussion'; } function getAuthor() { return 'Radek HULAN, mod by Marza'; } function getURL() { return 'http://wakka.xiffy.nl/latestdisc'; } function getVersion() { return '0.2'; } function getDescription() { return 'This plugin can be used to display a list of x articles that were last commented on.'; } function doSkinVar($skinType) { global $manager, $blog, $displayForm, $displayNum, $displayDate, $CONF; $params = func_get_args(); $numberOfDiscs = 10; // default number of comments // how many comments will be shown? if ($params[1]) { $numberOfDiscs = $params[1]; } // show comments from all blogs if (!$params[2]) { $blogid = "";} // show comments from the actual blog else if ($params[2] == "actual") { $blogid = " WHERE cblog=".$blog->getID(); } // show comments from the default blog else if ($params[2] == "default") { $blogid = " WHERE cblog=".$CONF['DefaultBlog']; } // show comments from the selected blog id else { $blogid = " WHERE cblog=".($params[2]); } // do not put the links in a list if (!$params[3]) { $displayForm = "";} // use ul as list form else if ($params[3] == "ul") { $displayForm = ul; } // use ol as list form else if ($params[3] == "ol") { $displayForm = ol; } // do not display number of comments if (!$params[4]) { $displayNum = "";} // display number of comments else if ($params[4] == "num") { $displayNum = num; } // do not display date and time (default) if (!$params[5]) { $displayDate = "";} // display date and time else if ($params[5] == "date") { $displayDate = datetime; } if ($displayForm == 'ul'){ echo "<ul>";} if ($displayForm == 'ol'){ echo "<ol>";} $query = mysql_query("SELECT max(citem) as itemid, max(UNIX_TIMESTAMP(ctime)) as itime, COUNT(*) as commentcount FROM ".sql_table('comment')." ".$blogid." GROUP BY citem ORDER BY itime DESC LIMIT 0,".$numberOfDiscs); while ($msg = mysql_fetch_assoc ($query)) { $detail = mysql_query('SELECT ititle FROM nucleus_item WHERE inumber='.$msg['itemid']); if ($xdetail = mysql_fetch_assoc ($detail)) { $itemlink = createItemLink($msg['itemid'], ''); if ($displayForm == 'ul' or $displayForm == 'ol'){ echo "<li>";} echo "<a href=\"".$IndexURL.$itemlink."\">".strip_tags($xdetail['ititle'])."</a>"; if ($displayNum == 'num'){ echo " <span class=\"discussionnumber\">("; echo $msg['commentcount']; echo ")</span>";} if ($displayDate == 'datetime'){ echo "<span class=\"discussiondate\">"; echo " ".date("d-m-Y H:i",$msg['itime']); echo "</span>";} if ($displayForm == 'ul' or $displayForm == 'ol'){ echo "</li>";} else { echo "<br />"; } } } if ($displayForm == 'ul') { echo "</ul>";} if ($displayForm == 'ol'){ echo "</ol>";} } } ?>