<?php

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

class LegacyRender_TplfileViewAction extends LegacyRender_Action
{
	var $mObject = null;
	
	function getDefaultView(&$controller, &$xoopsUser)
	{
		$id = isset($_REQUEST['tpl_id']) ? intval($_REQUEST['tpl_id']) : 0;
		
		$handler =& xoops_getmodulehandler('tplfile');
		$this->mObject =& $handler->get($id);
		
		if (!is_object($this->mObject)) {
			return LEGACYRENDER_FRAME_VIEW_ERROR;
		}
		
		return LEGACYRENDER_FRAME_VIEW_SUCCESS;
	}

	function executeViewSuccess(&$controller, &$xoopsUser, &$render)
	{
		$this->mObject->loadSource();

		$render->setTemplateName("tplfile_view.html");
		$render->setAttribute('object', $this->mObject);
	}

	function executeViewError(&$controller, &$xoopsUser, &$render)
	{
		redirect_header("./index.php?action=TplsetList", 1, _AD_LEGACYRENDER_ERROR_OBJECT_IS_NOT_EXIST);
	}
}

?>