<?php
/**
 * @package legacyRender
 * @version $Id: Cacheclear.class.php,v 1.1.2.2 2006/07/27 06:11:56 minahito Exp $
 */

if (!defined('XOOPS_ROOT_PATH')) exit();

class legacyRender_Cacheclear extends XCube_ActionFilter {
    function preBlockFilter()
    {
		$this->mController->mRoot->mDelegateManager->add('Legacy_ModuleInstallAction.InstallSuccess', 'legacyRender_Cacheclear::cacheClear');
		$this->mController->mRoot->mDelegateManager->add('Legacy_ModuleUpdateAction.UpdateSuccess', 'legacyRender_Cacheclear::cacheClear');
    }
    
    function cacheClear(&$module)
	{
		$handler =& xoops_getmodulehandler('tplfile', 'legacyRender');
		
		$criteria =& new Criteria('tpl_module', $module->get('dirname'));
		$tplfileArr = $handler->getObjects($criteria);
		
		$xoopsTpl =& new XoopsTpl();
		foreach (array_keys($tplfileArr) as $key) {
			$xoopsTpl->clear_cache('db:' . $tplfileArr[$key]->get('tpl_file'));
			$xoopsTpl->clear_compiled_tpl('db:' . $tplfileArr[$key]->get('tpl_file'));
		}
    }
}
?>
