<?php
class MyWeb_File_Form_EditIni extends MyWeb_File_Form_AbstractIni
{
	private $_addContent;
	
	/**
	 * 
	 * 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_ini);
		$this->set_typeFile('ini');
		$this->_currentPrefix = 2;
		if (0 === strcmp($this->_filename, 'none')){
			$this->_filename = $this->_dbTable->get_modelName();
		}
	}
	
	
	public function createContent()
	{
		$stringFile = "\n";
		$actualIndexColumn = 0;
		for ($actualIndexColumn;$actualIndexColumn<count($this->_describeTable);$actualIndexColumn++){
			// hodnota tabulky neni klicem
			$value = '';
			if(($this->_describeTable[$actualIndexColumn]['Key'] == 'PRI') || (($this->_describeTable[$actualIndexColumn]['Key'] == 'MUL'))){
				$value = 'Value';
			}
			$stringFile .= $this->addValidators($this->_describeTable[$actualIndexColumn]['Type'],$this->_describeTable[$actualIndexColumn]['Field'],$value);
			$stringFile .= "\n\n";
		}
		$stringFile .= $this->_addContent . "\n";
		$stringFile .= "\n";
		$this->set_contentFile($stringFile);
	}
}