<?php


class Plugin_bloginclude extends Plugin
{
	function do_block($pagename, $param1, $param2)
	{
		$a = array_map('trim', explode("\n", $param2));
		foreach($a as $item){
			if($item != ''){
				$ret[] = $this->includepage($item);
			}
		}
		
		$smarty = new PluginSmarty('bloginclude');
		$smarty->assign('title', $pagename);
		$smarty->assign('body', join("\n", $ret));
		return $smarty->fetch('bloginclude.tpl.htm');
	}
	
	
	protected function includepage($pagename)
	{
		$source = Page::getinstance($pagename)->getsource();
		$source = mb_ereg_replace('#blognavi', '', $source);
		$smarty = new PluginSmarty('bloginclude');
		$smarty->assign('title', $pagename);
		$smarty->assign('body', convert_block($source, $pagename));
		return $smarty->fetch('include.tpl.htm');
	}
}


?>