<?php


class Cmd_list
{
	public static function getinstance()
	{
		return new Cmd_list;
	}
	
	
	public function run()
	{
		$db = DataBase::getinstance();
		
		$query  = "SELECT pagename,timestamp FROM page";
		$query .= " WHERE (pagename not like ':%' AND pagename not like '%/:%')";
		$query .= " ORDER BY pagename ASC";
		$result = $db->query($query);
		$smarty = new CmdSmarty('list');
		while($row = $db->fetch($result)){
			$a['pagename'] = $row['pagename'];
			$a['old'] = getold($row['timestamp']);
			$smarty->append('list', $a);
		}
		$row = $db->fetch($db->query("SELECT count(pagename) FROM page"));
		$smarty->assign('total', $row[0]);
		$ret['title'] = 'ページ一覧';
		$ret['body'] = $smarty->fetch('list.tpl.htm');
		return $ret;
	}
}

?>