<?php

	class HelpEventHandler extends kDBEventHandler
	{

		/**
		 * Saves help file or created new one
		 *
		 * @param kEvent $event
		 */
		function OnSaveHelp(&$event)
		{
			$new_content = $this->Application->GetVar('HelpContent');

			$module = $this->Application->GetVar('h_module');
			$title_preset = $this->Application->GetVar('h_title_preset');

			$sql = 'SELECT Path FROM '.TABLE_PREFIX.'Modules WHERE LOWER(Name)='.$this->Conn->qstr( strtolower($module) );
			$module_path = $this->Conn->GetOne($sql);

			$help_file = FULL_PATH.'/'.$module_path.'module_help/'.$title_preset.'.txt';
			$help_data = $this->Application->GetVar('HelpContent');

			$fp = fopen($help_file,'w');
			fwrite($fp,$help_data);
			fclose($fp);
		}
	}

?>