<?php

class admin_config{

	public function __construct(){
	global $MAIN_PAGE;
		define('M_PATH',MAIN_SOURCE_PATH.'/modules/'.$MAIN_PAGE -> dirname() );
		define('M_URL',MAIN_SOURCE_URL.'/modules/'.$MAIN_PAGE -> dirname() );
		include_once(M_PATH.'/inc/url.php');
		include_once(MAIN_SOURCE_PATH.'/inc/class.config.php');
		include_once(MAIN_SOURCE_PATH.'/inc/class.html.php');
	}
	

	
	public function get(){
	global $MAIN_PAGE;
		if ( !empty($_REQUEST['send']) ){
			$this -> save();
				//	перезагружаем обновлённые переменные
		}
		$t = new PHPTAL( false);
		$t -> setSnippet('admin','admin_config');
		include(MAIN_PATH.'/tmp/config/system.php');
		$t -> sys_site_name = $MAIN_PAGE -> config('sys_site_name');
		$t -> sys_mail = $MAIN_PAGE -> config('sys_mail');
		$t -> sys_site_desc = $MAIN_PAGE -> config('sys_site_desc');
		$t -> sys_url_list = $MAIN_PAGE -> config('sys_url_list');
		$t -> sys_captcha = $MAIN_PAGE -> config('sys_captcha');
		$t -> sys_wysiwyg = $MAIN_PAGE -> config('sys_wysiwyg');
		$t -> sys_editor_upload_size = $MAIN_PAGE -> config('sys_editor_upload_size');
		$t -> sys_editor_image_width = $MAIN_PAGE -> config('sys_editor_image_width');
		$t -> sys_editor_image_height = $MAIN_PAGE -> config('sys_editor_image_height');
		
		
		$t -> sys_close_site = $MAIN_PAGE -> config('sys_close_site');
		$t -> sys_smtp_login = $MAIN_PAGE -> config('sys_smtp_login');
		$t -> sys_smtp_server = $MAIN_PAGE -> config('sys_smtp_server');
		$t -> sys_smtp_pass = $MAIN_PAGE -> config('sys_smtp_pass');
		$t -> sys_smtp_port = $MAIN_PAGE -> config('sys_smtp_port');
		$t -> sys_contacts_list = $MAIN_PAGE -> config('sys_contacts_list');

		
			//	список групп
		$gl = new group_select_box();
 		$t -> sys_gr_simple_wysywig = $gl -> group_list( $MAIN_PAGE -> config('sys_gr_simple_wysywig') );
 		
 		//$t -> URL_ADMIN_MAIN = sys_url(URL_ADMIN_MAIN);
		return $t -> execute();
	}
	
	private function save(){
	global $MAIN_PAGE;
		include_once(MAIN_SOURCE_PATH.'/inc/class.config.php');
		$c = new config(MAIN_PATH.'/tmp/config/system.php');
		$c -> set_str('sys_site_desc',$_REQUEST['sys_site_desc']);
		$c -> set_str('sys_site_name',$_REQUEST['sys_site_name']);
		$c -> set_str('sys_mail',$_REQUEST['sys_mail']);
		$c -> set_str('sys_cookie_name','hostel_session');
		$c -> set_str('sys_guest_name','guest');
		$c -> set_bin('sys_captcha',$_REQUEST['sys_captcha']);
		$c -> set_bin('sys_wysiwyg',$_REQUEST['sys_wysiwyg']);
		$c -> set_str('sys_editor_upload_size',$_REQUEST['sys_editor_upload_size']);
		$c -> set_str('sys_editor_image_width',$_REQUEST['sys_editor_image_width']);
		$c -> set_str('sys_editor_image_height',$_REQUEST['sys_editor_image_height']);
		
		$c -> set_bin('sys_close_site',$_REQUEST['sys_close_site']);
		$c -> set_array('sys_gr_simple_wysywig',$_REQUEST['sys_gr_simple_wysywig']);
		$c -> set_str('sys_url_list',$_REQUEST['sys_url_list']);
		$c -> set_str('sys_smtp_server',$_REQUEST['sys_smtp_server']);
		$c -> set_str('sys_smtp_login',$_REQUEST['sys_smtp_login']);
		$c -> set_str('sys_smtp_pass',$_REQUEST['sys_smtp_pass']);
		$c -> set_str('sys_smtp_port',$_REQUEST['sys_smtp_port']);
		$c -> set_str('sys_contacts_list',$_REQUEST['sys_contacts_list']);
		
		  //  скрытые
		$c -> set_str('sys_admin_mainpage',$MAIN_PAGE -> config('sys_admin_mainpage') ); 
	
			
		$c ->  save();
		
	}
	

	
}

?>
