<?php

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

require_once XOOPS_ROOT_PATH . "/class/XCube_ActionForm.class.php";

/**
 * This class is generated by makeActionForm tool.
 */
class TplfileEditForm extends XCube_ActionForm
{
	function getTokenName()
	{
		return "module.legacyRender.TplfileEditForm.TOKEN." . $this->get('tpl_id');
	}

	function prepare()
	{
		//
		// Set form properties
		//
		$this->mFormProperties['tpl_id'] =& new XCube_IntProperty('tpl_id');
		$this->mFormProperties['tpl_desc'] =& new XCube_StringProperty('tpl_desc');
		$this->mFormProperties['tpl_source'] =& new XCube_TextProperty('tpl_source');

		//
		// Set field properties
		//
		$this->mFieldProperties['tpl_id'] =& new XCube_FieldProperty($this);
		$this->mFieldProperties['tpl_id']->setDependsByArray(array('required'));
		$this->mFieldProperties['tpl_id']->addMessage('required', _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_TPL_ID);

		$this->mFieldProperties['tpl_desc'] =& new XCube_FieldProperty($this);
		$this->mFieldProperties['tpl_desc']->setDependsByArray(array('maxlength'));
		$this->mFieldProperties['tpl_desc']->addMessage('maxlength', _AD_LEGACYRENDER_ERROR_MAXLENGTH, _AD_LEGACYRENDER_LANG_TPL_DESC, '255');
		$this->mFieldProperties['tpl_desc']->addVar('maxlength', 255);

		$this->mFieldProperties['tpl_source'] =& new XCube_FieldProperty($this);
		$this->mFieldProperties['tpl_source']->setDependsByArray(array('required'));
		$this->mFieldProperties['tpl_source']->addMessage('required', _AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_TPL_SOURCE);
	}

	function load(&$obj)
	{
		$obj->loadSource();
		
		$this->setVar('tpl_id', $obj->get('tpl_id'));
		$this->setVar('tpl_desc', $obj->get('tpl_desc'));
		$this->setVar('tpl_source', $obj->Source->get('tpl_source'));
	}

	function update(&$obj)
	{
		$obj->loadSource();

		$obj->setVar('tpl_id', $this->get('tpl_id'));
		$obj->setVar('tpl_desc', $this->get('tpl_desc'));

		$obj->setVar('tpl_lastmodified', time());

		$obj->Source->setVar('tpl_source', $this->get('tpl_source'));
	}
}

?>
