<?php
/* 
 * $Id: diff.inc.php,v 1.2 2004/09/23 09:31:33 youka Exp $
 */



class Cmd_diff
{
	public static function getinstance()
	{
		return new Cmd_diff;
	}
	
	
	public function run()
	{
		$get = KinoWiki::getinstance()->getGET();
		if(!isset($get['page'])){
			return $this->error('パラメータが足りません。');
		}
		
		$page = Page::getinstance($get['page']);
		$diff = $page->diff(0, 1);
		$renderer = new DiffRenderer($diff);
		
		$ret['title'] = htmlspecialchars($page->getpagename()) . " の変更点";
		$smarty = new CmdSmarty('diff');
		$smarty->assign('diff', $renderer->render());
		$ret['body'] = $smarty->fetch('diff.tpl.htm');
		$ret['pagename'] = $page->getpagename();
		return $ret;
	}
	
	
	protected function error($str)
	{
		$ret['title'] = 'error';
		$ret['body'] = '<p class="error">' . $str . '</p>';
		return $ret;
	}
}




?>
