<?php

class Plugin_recent extends Plugin
{
	function do_block($pagename, $param1, $param2)
	{
		$num = (int)trim($param1);
		
		$db = DataBase::getinstance();
		$query  = "SELECT pagename,timestamp FROM page";
		$query .= " WHERE (pagename not like ':%' AND pagename not like '%/:%')";
		$query .= " ORDER BY timestamp DESC LIMIT $num";
		$result = $db->query($query);
		
		$list = array();
		while($row = $db->fetch($result)){
			$list[date('Y-m-d', $row['timestamp'])][] = makelink($row['pagename']);
		}
		
		$smarty = new PluginSmarty('recent');
		$smarty->assign('list', $list);
		return $smarty->fetch('recent.tpl.htm');
	}
}

?>