<?php
class MyWeb_File_Form_Logout extends MyWeb_File_Form_Abstract
{
	private $_addContent;
	
	
	
		protected $_user = 'user';			//user	-	jmeno tridy modelu
		protected $_submitLogout = 'submit_logout';
		protected $_logout = 'logout';			//logout	-	jmeno formulare
		
		
		
		
	/**
	 * 
	 * Metoda prida retezec do vysledneho souboru
	 * @param $content
	 */
	public function add_contentFile($content)
	{
		$this->_addContent = $content;
	}
	
	private function defaultSettings()
	{
		if (is_null($this->_describeTable)){
			$this->_describeTable = $this->_dbTable->get_describeTable();
		}
	}
	
	
	
	
	public function __construct($dbTable,$path = null)
	{
		$this->_dbTable = $dbTable;
		$this->defaultSettings();
		$this->_path = $path;	//*** pridano zajistuje pouziti nove cesty od uzivatele misto default
		$this->defaultSettingsPath($this->_default_path_form_php);
		$this->set_typeFile('php');
		$this->_currentPrefix = 0;
		if (0 === strcmp($this->_filename, 'none')){
			$this->_filename = $this->_dbTable->get_modelName().ucfirst($this->_logout);
		}
	}
	
	
	
	public function createContent()
	{
		
		$methodInit = new Zend_CodeGenerator_Php_Method();
		$methodInit	->setName('init');
		$methodInit->setBody(
			'$request = Zend_Controller_Front::getInstance()->getRequest();'								. "\n" .
			'ZendX_JQuery::enableForm($this);	// zapnuti jQuery'											. "\n" .
			'$getValue = $request->getParams();'															. "\n" .
			'$translate = Zend_Registry::get(\'Zend_Translate\');'											. "\n\n" .
		
			'$url = $request->getRequestUri();'																. "\n\n" .
		
			'// nastaví atributy formuláře'																	. "\n" .
			'$this->setAction($this->createPath($url, \''.$this->_user.'\', \''.$this->_logout.'\', null));'	. "\n" .
			'$this->setMethod("post");'																		. "\n" .
			'$this->setAttrib("id", "form_'.$this->_dbTable->get_modelName()."_".$this->_logout.'");'		. "\n" .
																											  "\n" .
			$this->_stringAddsLink																			. "\n" .
																											  "\n" .
			'// vytvoří formulářový prvek odesílací tlačítko'												. "\n" .
			'$submit'.ucfirst($this->_submitLogout).' = 
												new Zend_Form_Element_Submit(
																	"'.$this->_submitLogout.'",
																	array("label" => $translate->translate(\'Logout\')'.
														'));'												. "\n" .		
			'// přidá formulářové prvky do formuláře' . "\n" .
			'$this->addElements(array($submit'.ucfirst($this->_submitLogout).'));'							. "\n"
		);
		
		
		$class = new Zend_CodeGenerator_Php_Class();
		$class	->setName('Application_Model_Form_'.ucfirst($this->_dbTable->get_modelName()).ucfirst($this->_logout).' extends MyWeb_Form')
				->setMethod($methodInit);
					
		$stringFile = "<?php \n ".$class;
		$this->set_contentFile($stringFile);
	}
}