<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Обработчик добавления/редактирования сайта.
 * 
 * Файл: /admin/site/action/add_edit_site_form.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$site = & singleton ('site');

if (!isset($site_id))
{
	$site_id = 0;
}

$form_params = array();

$form_params['title'] = $site_id == 0
? $GLOBALS['MSG_site']['site_add_site_form_title']
: $GLOBALS['MSG_site']['site_edit_site_form_title'];

$form_params['form_attribs']['method'] = 'post';
$form_params['form_attribs']['action'] = '/admin/site/site.php';
$form_params['form_attribs']['ENCTYPE'] = 'multipart/form-data';
$form_params['form_attribs']['name'] = 'EditAddSite';

$admin_forms_fields = new admin_forms_fields();

$form_params['path_array'][] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/site/site.php', '', 42, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/site/site.php', '', 42, 'load_data'),
'name' => $GLOBALS['MSG_site']['site_link_sites']);

$admin_forms_fields->admin_forms_fields($form_params);

// Редактирование модуля
if ($site_id)
{
	$result = $site->GetSite($site_id, array('cache_off' => true));
	$site_name = $result['site_name'];
	$site_is_active = $result['site_is_active'];
	$site_coding = $result['site_coding'];
	$site_order = $result['site_order'];
	$site_locale = $result['site_locale'];
	$site_timezone = $result['site_timezone'];
	$site_max_size_load_image = $result['site_max_size_load_image'];
	$site_max_size_load_image_big = $result['site_max_size_load_image_big'];
	$site_admin_email = $result['site_admin_email'];
	$site_chmod =  $result['site_chmod'];
	$site_files_chmod = $result['site_files_chmod'];
	$site_date_format = $result['site_date_format'];
	$site_date_time_format = $result['site_date_time_format'];
	$site_error = $result['site_error'];
	$site_error404 = $result['site_error404'];
	$site_access_denied = $result['site_access_denied'];
	$site_robots = $result['site_robots'];
	$site_key = $result['site_key'];
	$site_robots = $result['site_robots'];
	$site_key = $result['site_key'];
	$site_is_close = to_int($result['site_is_close']);
	$site_safe_email = $result['site_safe_email'];
	$site_send_attendance_report = $result['site_send_attendance_report'];
	$site_html_cache_use = $result['site_html_cache_use'];
	$site_html_cache_with = $result['site_html_cache_with'];
	$site_html_cache_without = $result['site_html_cache_without'];
	$site_html_cache_clear_probability = $result['site_html_cache_clear_probability']; 
	$site_css_left = $result['site_css_left'];
	$site_css_right = $result['site_css_right'];
	$site_uploaddir = $result['site_uploaddir'];
	$site_nesting_level = $result['site_nesting_level'];
}
// Добавление модуля
else
{
	$site_name = '';
	$site_is_active = 1;
	$site_coding = 'UTF-8';
	$site_order = 0;
	$site_locale = 'ru_RU.utf8';
	$site_timezone = '';
	$site_max_size_load_image = 70;
	$site_max_size_load_image_big = 300;
	$site_admin_email = '';
	$site_send_attendance_report = 1;	
	$site_chmod = '0755';
	$site_files_chmod = '0644';
	$site_date_format = '%d.%m.%Y';
	$site_date_time_format = '%d.%m.%Y %H:%M:%S';
	$site_error = 'E_ALL';
	$site_error404 = 0;
	// ошибка 403
	$site_access_denied = 0;
	$site_robots = "User-agent: *\nDisallow: /admin";
	$site_key = '';
	$site_is_close = 0;
	$site_safe_email = 1;
	$site_html_cache_use = 0;
	$site_html_cache_with = '/*';
	$site_html_cache_without = '';
	$site_html_cache_clear_probability = 10000;
	$site_css_left = '';
	$site_css_right = '';
	$site_uploaddir = 'upload/';
	$site_nesting_level = 3;
}

$kernel = & singleton('kernel');

// Параметры.
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_parameters']);

// название сайта
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_name';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_name'];
$param['type'] = 0; // textbox
$param['attributes']['class'] = 'large';
$param['value'] = $site_name;
$param['format']['minlen']['value'] = 1;
$param['format']['maxlen']['value'] = 255;
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

$array[0] = $GLOBALS['MSG_site']['site_add_edit_site_form_active_no'];
$array[1] = $GLOBALS['MSG_site']['site_add_edit_site_form_active_yes'];

// активность сайта
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_is_active';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_active'];
$param['type'] = 2;
$param['items'] = $array;
$param['value'] = $site_is_active;
$param['attributes']['style'] = 'width: 110px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// кодировка сайта
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_coding';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_coding'];
$param['type'] = 0; // textbox
$param['value'] = $site_coding;
$param['attributes']['style'] = 'width: 110px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// порядок сортировки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_order';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_order'];
$param['type'] = 0; // textbox
$param['value'] = $site_order;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 110px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// локаль
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_locale';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_locale'];
$param['type'] = 0; // textbox

// Список локалей, если доступен
if (mb_substr(php_uname(), 0, 7) != "Windows"
	&& $kernel->function_enabled('exec'))
{
	@exec("locale -a", $sys_result);
	
	if (isset($sys_result) && count($sys_result) > 0)
	{
		$param['type'] = 2;
		$param['items'] = array();
		
		foreach ($sys_result as $sLocale)
		{
			$sLocale = trim($sLocale);
			$param['items'][$sLocale] = $sLocale;
		}
		
		$param['format']['minlen']['value'] = 1;
	}
}

$param['value'] = $site_locale;
$param['attributes']['style'] = 'width: 110px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Timezone
$aTimezone = array('Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa', 'Africa/Algiers', 'Africa/Asmara', 'Africa/Asmera', 'Africa/Bamako', 'Africa/Bangui', 'Africa/Banjul', 'Africa/Bissau', 'Africa/Blantyre', 'Africa/Brazzaville', 'Africa/Bujumbura', 'Africa/Cairo', 'Africa/Casablanca', 'Africa/Ceuta', 'Africa/Conakry', 'Africa/Dakar', 'Africa/Dar_es_Salaam', 'Africa/Djibouti', 'Africa/Douala', 'Africa/El_Aaiun', 'Africa/Freetown', 'Africa/Gaborone', 'Africa/Harare', 'Africa/Johannesburg', 'Africa/Kampala', 'Africa/Khartoum', 'Africa/Kigali', 'Africa/Kinshasa', 'Africa/Lagos', 'Africa/Libreville', 'Africa/Lome', 'Africa/Luanda', 'Africa/Lubumbashi', 'Africa/Lusaka', 'Africa/Malabo', 'Africa/Maputo', 'Africa/Maseru', 'Africa/Mbabane', 'Africa/Mogadishu', 'Africa/Monrovia', 'Africa/Nairobi', 'Africa/Ndjamena', 'Africa/Niamey', 'Africa/Nouakchott', 'Africa/Ouagadougou', 'Africa/Porto-Novo', 'Africa/Sao_Tome', 'Africa/Timbuktu', 'Africa/Tripoli', 'Africa/Tunis', 'Africa/Windhoek', 'America/Adak', 'America/Anchorage', 'America/Anguilla', 'America/Antigua', 'America/Araguaina', 'America/Argentina/Buenos_Aires', 'America/Argentina/Catamarca', 'America/Argentina/ComodRivadavia', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/La_Rioja', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Salta', 'America/Argentina/San_Juan', 'America/Argentina/San_Luis', 'America/Argentina/Tucuman', 'America/Argentina/Ushuaia', 'America/Aruba', 'America/Asuncion', 'America/Atikokan', 'America/Atka', 'America/Bahia', 'America/Barbados', 'America/Belem', 'America/Belize', 'America/Blanc-Sablon', 'America/Boa_Vista', 'America/Bogota', 'America/Boise', 'America/Buenos_Aires', 'America/Cambridge_Bay', 'America/Campo_Grande', 'America/Cancun', 'America/Caracas', 'America/Catamarca', 'America/Cayenne', 'America/Cayman', 'America/Chicago', 'America/Chihuahua', 'America/Coral_Harbour', 'America/Cordoba', 'America/Costa_Rica', 'America/Cuiaba', 'America/Curacao', 'America/Danmarkshavn', 'America/Dawson', 'America/Dawson_Creek', 'America/Denver', 'America/Detroit', 'America/Dominica', 'America/Edmonton', 'America/Eirunepe', 'America/El_Salvador', 'America/Ensenada', 'America/Fort_Wayne', 'America/Fortaleza', 'America/Glace_Bay', 'America/Godthab', 'America/Goose_Bay', 'America/Grand_Turk', 'America/Grenada', 'America/Guadeloupe', 'America/Guatemala', 'America/Guayaquil', 'America/Guyana', 'America/Halifax', 'America/Havana', 'America/Hermosillo', 'America/Indiana/Indianapolis', 'America/Indiana/Knox', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Tell_City', 'America/Indiana/Vevay', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indianapolis', 'America/Inuvik', 'America/Iqaluit', 'America/Jamaica', 'America/Jujuy', 'America/Juneau', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Knox_IN', 'America/La_Paz', 'America/Lima', 'America/Los_Angeles', 'America/Louisville', 'America/Maceio', 'America/Managua', 'America/Manaus', 'America/Marigot', 'America/Martinique', 'America/Matamoros', 'America/Mazatlan', 'America/Mendoza', 'America/Menominee', 'America/Merida', 'America/Mexico_City', 'America/Miquelon', 'America/Moncton', 'America/Monterrey', 'America/Montevideo', 'America/Montreal', 'America/Montserrat', 'America/Nassau', 'America/New_York', 'America/Nipigon', 'America/Nome', 'America/Noronha', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/Ojinaga', 'America/Panama', 'America/Pangnirtung', 'America/Paramaribo', 'America/Phoenix', 'America/Port-au-Prince', 'America/Port_of_Spain', 'America/Porto_Acre', 'America/Porto_Velho', 'America/Puerto_Rico', 'America/Rainy_River', 'America/Rankin_Inlet', 'America/Recife', 'America/Regina', 'America/Resolute', 'America/Rio_Branco', 'America/Rosario', 'America/Santa_Isabel', 'America/Santarem', 'America/Santiago', 'America/Santo_Domingo', 'America/Sao_Paulo', 'America/Scoresbysund', 'America/Shiprock', 'America/St_Barthelemy', 'America/St_Johns', 'America/St_Kitts', 'America/St_Lucia', 'America/St_Thomas', 'America/St_Vincent', 'America/Swift_Current', 'America/Tegucigalpa', 'America/Thule', 'America/Thunder_Bay', 'America/Tijuana', 'America/Toronto', 'America/Tortola', 'America/Vancouver', 'America/Virgin', 'America/Whitehorse', 'America/Winnipeg', 'America/Yakutat', 'America/Yellowknife', 'Antarctica/Casey', 'Antarctica/Davis', 'Antarctica/DumontDUrville', 'Antarctica/Macquarie', 'Antarctica/Mawson', 'Antarctica/McMurdo', 'Antarctica/Palmer', 'Antarctica/Rothera', 'Antarctica/South_Pole', 'Antarctica/Syowa', 'Antarctica/Vostok', 'Arctic/Longyearbyen', 'Asia/Aden', 'Asia/Almaty', 'Asia/Amman', 'Asia/Anadyr', 'Asia/Aqtau', 'Asia/Aqtobe', 'Asia/Ashgabat', 'Asia/Ashkhabad', 'Asia/Baghdad', 'Asia/Bahrain', 'Asia/Baku', 'Asia/Bangkok', 'Asia/Beirut', 'Asia/Bishkek', 'Asia/Brunei', 'Asia/Calcutta', 'Asia/Choibalsan', 'Asia/Chongqing', 'Asia/Chungking', 'Asia/Colombo', 'Asia/Dacca', 'Asia/Damascus', 'Asia/Dhaka', 'Asia/Dili', 'Asia/Dubai', 'Asia/Dushanbe', 'Asia/Gaza', 'Asia/Harbin', 'Asia/Ho_Chi_Minh', 'Asia/Hong_Kong', 'Asia/Hovd', 'Asia/Irkutsk', 'Asia/Istanbul', 'Asia/Jakarta', 'Asia/Jayapura', 'Asia/Jerusalem', 'Asia/Kabul', 'Asia/Kamchatka', 'Asia/Karachi', 'Asia/Kashgar', 'Asia/Kathmandu', 'Asia/Katmandu', 'Asia/Kolkata', 'Asia/Krasnoyarsk', 'Asia/Kuala_Lumpur', 'Asia/Kuching', 'Asia/Kuwait', 'Asia/Macao', 'Asia/Macau', 'Asia/Magadan', 'Asia/Makassar', 'Asia/Manila', 'Asia/Muscat', 'Asia/Nicosia', 'Asia/Novokuznetsk', 'Asia/Novosibirsk', 'Asia/Omsk', 'Asia/Oral', 'Asia/Phnom_Penh', 'Asia/Pontianak', 'Asia/Pyongyang', 'Asia/Qatar', 'Asia/Qyzylorda', 'Asia/Rangoon', 'Asia/Riyadh', 'Asia/Saigon', 'Asia/Sakhalin', 'Asia/Samarkand', 'Asia/Seoul', 'Asia/Shanghai', 'Asia/Singapore', 'Asia/Taipei', 'Asia/Tashkent', 'Asia/Tbilisi', 'Asia/Tehran', 'Asia/Tel_Aviv', 'Asia/Thimbu', 'Asia/Thimphu', 'Asia/Tokyo', 'Asia/Ujung_Pandang', 'Asia/Ulaanbaatar', 'Asia/Ulan_Bator', 'Asia/Urumqi', 'Asia/Vientiane', 'Asia/Vladivostok', 'Asia/Yakutsk', 'Asia/Yekaterinburg', 'Asia/Yerevan',	   'Atlantic/Azores', 'Atlantic/Bermuda', 'Atlantic/Canary', 'Atlantic/Cape_Verde', 'Atlantic/Faeroe', 'Atlantic/Faroe', 'Atlantic/Jan_Mayen', 'Atlantic/Madeira', 'Atlantic/Reykjavik', 'Atlantic/South_Georgia', 'Atlantic/St_Helena', 'Atlantic/Stanley',	  'Australia/ACT', 'Australia/Adelaide', 'Australia/Brisbane', 'Australia/Broken_Hill', 'Australia/Canberra', 'Australia/Currie', 'Australia/Darwin', 'Australia/Eucla', 'Australia/Hobart', 'Australia/LHI', 'Australia/Lindeman', 'Australia/Lord_Howe', 'Australia/Melbourne', 'Australia/North', 'Australia/NSW', 'Australia/Perth', 'Australia/Queensland', 'Australia/South', 'Australia/Sydney', 'Australia/Tasmania', 'Australia/Victoria', 'Australia/West', 'Australia/Yancowinna',	  'Europe/Amsterdam', 'Europe/Andorra', 'Europe/Athens', 'Europe/Belfast', 'Europe/Belgrade', 'Europe/Berlin', 'Europe/Bratislava', 'Europe/Brussels', 'Europe/Bucharest', 'Europe/Budapest', 'Europe/Chisinau', 'Europe/Copenhagen', 'Europe/Dublin', 'Europe/Gibraltar', 'Europe/Guernsey', 'Europe/Helsinki', 'Europe/Isle_of_Man', 'Europe/Istanbul', 'Europe/Jersey', 'Europe/Kaliningrad', 'Europe/Kiev', 'Europe/Lisbon', 'Europe/Ljubljana', 'Europe/London', 'Europe/Luxembourg', 'Europe/Madrid', 'Europe/Malta', 'Europe/Mariehamn', 'Europe/Minsk', 'Europe/Monaco', 'Europe/Moscow', 'Europe/Nicosia', 'Europe/Oslo', 'Europe/Paris', 'Europe/Podgorica', 'Europe/Prague', 'Europe/Riga', 'Europe/Rome', 'Europe/Samara', 'Europe/San_Marino', 'Europe/Sarajevo', 'Europe/Simferopol', 'Europe/Skopje', 'Europe/Sofia', 'Europe/Stockholm', 'Europe/Tallinn', 'Europe/Tirane', 'Europe/Tiraspol', 'Europe/Uzhgorod', 'Europe/Vaduz', 'Europe/Vatican', 'Europe/Vienna', 'Europe/Vilnius', 'Europe/Volgograd', 'Europe/Warsaw', 'Europe/Zagreb', 'Europe/Zaporozhye', 'Europe/Zurich', 'Indian/Antananarivo', 'Indian/Chagos', 'Indian/Christmas', 'Indian/Cocos', 'Indian/Comoro', 'Indian/Kerguelen', 'Indian/Mahe', 'Indian/Maldives', 'Indian/Mauritius', 'Indian/Mayotte', 'Indian/Reunion', 'Pacific/Apia', 'Pacific/Auckland', 'Pacific/Chatham', 'Pacific/Easter', 'Pacific/Efate', 'Pacific/Enderbury', 'Pacific/Fakaofo', 'Pacific/Fiji', 'Pacific/Funafuti', 'Pacific/Galapagos', 'Pacific/Gambier', 'Pacific/Guadalcanal', 'Pacific/Guam', 'Pacific/Honolulu', 'Pacific/Johnston', 'Pacific/Kiritimati', 'Pacific/Kosrae', 'Pacific/Kwajalein', 'Pacific/Majuro', 'Pacific/Marquesas', 'Pacific/Midway', 'Pacific/Nauru', 'Pacific/Niue', 'Pacific/Norfolk', 'Pacific/Noumea', 'Pacific/Pago_Pago', 'Pacific/Palau', 'Pacific/Pitcairn', 'Pacific/Ponape', 'Pacific/Port_Moresby', 'Pacific/Rarotonga', 'Pacific/Saipan', 'Pacific/Samoa', 'Pacific/Tahiti', 'Pacific/Tarawa', 'Pacific/Tongatapu', 'Pacific/Truk', 'Pacific/Wake', 'Pacific/Wallis', 'Pacific/Yap',	  'Brazil/Acre', 'Brazil/DeNoronha', 'Brazil/East', 'Brazil/West', 'Canada/Atlantic', 'Canada/Central', 'Canada/East-Saskatchewan', 'Canada/Eastern', 'Canada/Mountain', 'Canada/Newfoundland', 'Canada/Pacific', 'Canada/Saskatchewan', 'Canada/Yukon', 'CET', 'Chile/Continental', 'Chile/EasterIsland', 'CST6CDT', 'Cuba', 'EET', 'Egypt', 'Eire', 'EST', 'EST5EDT', 'Etc/GMT', 'Etc/GMT+0', 'Etc/GMT+1', 'Etc/GMT+2', 'Etc/GMT+3', 'Etc/GMT+4', 'Etc/GMT+5', 'Etc/GMT+6', 'Etc/GMT+7', 'Etc/GMT+8', 'Etc/GMT+9', 'Etc/GMT+10', 'Etc/GMT+11', 'Etc/GMT+12', 'Etc/GMT-0', 'Etc/GMT-1', 'Etc/GMT-2', 'Etc/GMT-3', 'Etc/GMT-4', 'Etc/GMT-5', 'Etc/GMT-6', 'Etc/GMT-7', 'Etc/GMT-8', 'Etc/GMT-9', 'Etc/GMT-10', 'Etc/GMT-11', 'Etc/GMT-12', 'Etc/GMT-13', 'Etc/GMT-14', 'Etc/GMT0', 'Etc/Greenwich', 'Etc/UCT', 'Etc/Universal', 'Etc/UTC', 'Etc/Zulu', 'Factory', 'GB', 'GB-Eire', 'GMT', 'GMT+0', 'GMT-0', 'GMT0', 'Greenwich', 'Hongkong', 'HST', 'Iceland', 'Iran', 'Israel', 'Jamaica', 'Japan', 'Kwajalein', 'Libya', 'MET', 'Mexico/BajaNorte', 'Mexico/BajaSur', 'Mexico/General', 'MST', 'MST7MDT', 'Navajo', 'NZ', 'NZ-CHAT', 'Poland', 'Portugal', 'PRC', 'PST8PDT', 'ROC', 'ROK', 'Singapore', 'Turkey', 'UCT', 'Universal', 'US/Alaska', 'US/Aleutian', 'US/Arizona', 'US/Central', 'US/East-Indiana', 'US/Eastern', 'US/Hawaii', 'US/Indiana-Starke', 'US/Michigan', 'US/Mountain', 'US/Pacific', 'US/Pacific-New', 'US/Samoa', 'UTC', 'W-SU', 'WET');

$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_timezone';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_timezone'];
$param['type'] = 2;
$param['value'] = $site_timezone;

// As default
$param['items'] = array(
	'' => $GLOBALS['MSG_site']['default']
);
// Ключи должны быть равны значениям
foreach ($aTimezone as $value)
{
	$param['items'][$value] = $value;
}
$param['attributes']['style'] = 'width: 110px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// максимальный размер маленькой картинки при преобразовании
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_max_size_load_image';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_max_size_load_image'];
$param['type'] = 0; // textbox
$param['value'] = $site_max_size_load_image;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Максимальный размер большой картинки при преобразовании
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_max_size_load_image_big';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_max_size_load_image_big'];
$param['type'] = 0; // textbox
$param['value'] = $site_max_size_load_image_big;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// e-mail
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_admin_email';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_email'];
$param['type'] = 0; // textbox
$param['value'] = $site_admin_email;
$param['format']['lib']['value'] = 'email';
$param['format']['lib']['message'] = $GLOBALS['MSG_site']['site_add_edit_site_form_email_message'];
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// директория хранения загруженных файлов
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_upload_dir';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_upload_dir'];
$param['type'] = 0; // textbox
$param['value'] = $site_uploaddir;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Уровень вложенности директорий для хранения файлов сущностей системы
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_nesting_level';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_nesting_level'];
$param['type'] = 0; // textbox
$param['value'] = $site_nesting_level;
$param['attributes']['style'] = 'width: 110px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Защищать e-mail на страницах сайта.
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'site_safe_email';
$param['html_id'] = 'id_site_safe_email';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_email_safe'];
$param['value'] = $site_safe_email;

$admin_forms_fields->AddField($param);

// Отправлять отчет о посещаемости сайта
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'site_send_attendance_report';
$param['html_id'] = 'id_site_send_attendance_report';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_attendance_report'];
$param['value'] = $site_send_attendance_report;

$admin_forms_fields->AddField($param);


// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_ico_image';
$param['caption'] = $GLOBALS['MSG_site']['ico_files_uploaded'];
$param['type'] = 9; // file

// Параметры
$param['options']['make_small_image_from_big_show'] = 0; // отображать ли checkbox с подписью "Создать малое изображение из большого" (1 -  отображать (по умолчанию), 0 - не отображать);
$param['options']['make_small_image_from_big_checked'] = 0; // вид отображения checkbox'а с подписью "Создать малое изображение из большого" выбранным (1 -  отображать выбранным (по умолчанию), 0 - невыбранным);

$param['options']['load_small_image_show'] = 0; //- отображать ли поле загрузки малого изображения (1 -  отображать (по умолчанию), 0 - не отображать);

$param['options']['image_big_max_width'] = 0; // значение максимальной ширины большого изображения;
$param['options']['image_big_max_height'] = 0; // значение максимальной высоты большого изображения;

$param['options']['image_small_max_width'] = 0; // значение максимальной ширины малого изображения;
$param['options']['image_small_max_height'] = 0; // значение максимальной высоты малого изображения;

$param['options']['used_watermark_big_image_show'] = 0; // отображать ли checkbox с подписью "Наложить водяной знак на большое изображение" (1 -  отображать (по умолчанию), 0 - не отображать);
$param['options']['used_watermark_big_image_checked'] = 0; // вид ображения checkbox'а с подписью "Наложить водяной знак на большое изображение" (1 -  отображать выбранным (по умолчанию), 0 - невыбранным);

$param['options']['watermark_position_x'] = '50%'; //значение поля ввода с подписью "По оси X"
$param['options']['watermark_position_y'] = '100%'; // значение поля ввода с подписью "По оси Y"

if ($site_id) 
{
	if (file_exists(CMS_FOLDER . UPLOADDIR . 'favicon/site_' . $site_id . '.ico')) 
	{
		$param['options']['big_image_path'] = '/' . UPLOADDIR . 'favicon/site_' . $site_id . '.ico'; // адрес большого загруженного изображения
		$param['options']['href_delete_big_image'] = "javascript:void(0)";
		// Значение для onclick
		$param['options']['onclick_delete_big_image'] = "sendRequest('/admin/site/site.php?action=delete_ico_file&site_id=$site_id', 'get', callback_function_exec_from_return); return false;";
	}
}

$admin_forms_fields->AddField($param);
//
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_chmod']);

// CHMOD для директорий
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_chmod';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_chmod'];
$param['type'] = 0; // textbox
$param['value'] = $site_chmod;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// CHMOD для файлов
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_files_chmod';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_chmod_files'];
$param['type'] = 0; // textbox
$param['value'] = $site_files_chmod;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_dates']);

// формат даты
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_date_format';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_date_format'];
$param['type'] = 0; // textbox
$param['value'] = $site_date_format;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// формат даты и времени
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_date_time_format';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_date_time_format'];
$param['type'] = 0; // textbox
$param['value'] = $site_date_time_format;
$param['format']['minlen']['value'] = 1;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// CSS left
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_css_left';
$param['caption'] = $GLOBALS['MSG_site']['site_css_left'];
$param['type'] = 0; // textbox
$param['value'] = $site_css_left;
$param['format']['maxlen']['value'] = 20;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

// CSS right
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_css_right';
$param['caption'] = $GLOBALS['MSG_site']['site_css_right'];
$param['type'] = 0; // textbox
$param['value'] = $site_css_right;
$param['format']['maxlen']['value'] = 20;
$param['attributes']['style'] = 'width: 320px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_errors']);

// Поле ошибок сайта
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_error';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_error'];
$param['type'] = 0; // textbox
$param['value'] = $site_error;
$param['format']['minlen']['value'] = 5;
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

$array = array();

$structure = & singleton ('structure');

$mass = $structure->GetStructure('&nbsp;&nbsp;&nbsp;', ($site_id == 0) ? -1 : $site_id, false, -1,0);

$array[0] = $GLOBALS['MSG_site']['site_add_edit_site_form_error404_not_specified'];

foreach ($mass as $key => $value)
{
	$array[$value['structure_id']] = $value['separator'].$value['structure_menu_name'];
}

// error 404
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_error404';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_error404'];
$param['type'] = 2; // выпадающий список
$param['items'] = $array;
$param['value'] = $site_error404;

$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// error 403
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_access_denied';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_access_denied'];
$param['type'] = 2; // выпадающий список
$param['items'] = $array;
$param['value'] = $site_access_denied;

$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// идентификатор структуры сайта, отображающийся при статусе сайта "Закрыт"
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_is_close';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_error_site_is_close'];
$param['type'] = 2; // Поле ввода.
$param['items'] = $array;
$param['value'] = $site_is_close;

$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_robots_txt']);

// robots.txt
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_robots';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_robots'];
$param['type'] = 5; // textarea
$param['attributes']['cols'] = 50;
$param['attributes']['rows'] = 10;
$param['value'] = $site_robots;

$admin_forms_fields->AddField($param);


$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_licence']);

// лицензионный ключ
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_key';
$param['caption'] = $GLOBALS['MSG_site']['site_add_edit_site_form_key'];
$param['type'] = 5; // textarea
$param['attributes']['cols'] = 50;
$param['attributes']['rows'] = 5;
$param['value'] = $site_key;

$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Кэширование.
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_site']['site_cache_options']);

// Кэшировать страницы в статичные файлы
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_html_cache_use';
$param['caption'] = $GLOBALS['MSG_site']['cache_pages_in_static_files'];
$param['type'] = 1; // Флажок
$param['value'] = $site_html_cache_use;

$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Страницы, которые должны кэшироваться
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_html_cache_with';
$param['caption'] = $GLOBALS['MSG_site']['pages_in_cache'];
$param['type'] = 5; // Текстовое поле
$param['value'] = $site_html_cache_with;
$param['attributes']['rows'] = 5;
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Страницы, которые НЕ должны кэшироваться
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_html_cache_without';
$param['caption'] = $GLOBALS['MSG_site']['pages_out_cache'];
$param['type'] = 5; // Текстовое поле
$param['value'] = $site_html_cache_without;
$param['attributes']['rows'] = 5;
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Параметр, определяющий вероятность очистки кэша
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_html_cache_clear_probability';
$param['caption'] = $GLOBALS['MSG_site']['site_html_cache_clear_probability'];
$param['type'] = 0; 
$param['value'] = $site_html_cache_clear_probability;
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// передеам скрытое поле с идентификатором адреса если он есть
if ($site_id)
{
	$param = array();
	$param['tab_id'] = $tab_id;
	$param['name'] = 'site_id';
	$param['caption'] = '';
	$param['type'] = 4; // hidden.
	$param['value'] = $site_id;

	$admin_forms_fields->AddField($param);
}

// Кнопка "Сохранить".
$param = array();
$param['name'] = 'save_site';
$param['caption'] = $GLOBALS['MSG_site']['site_save'];
$param['attributes']['onclick'] = "return SendForm('{$admin_forms_fields->GetWindowId()}', '{$admin_forms_fields->AAction}', '{$admin_forms_fields->AAdditionalParams}', this, ".to_int($_REQUEST['admin_forms_id']).", 'load_data', " . to_int($admin_forms_fields->form_params['current_page']) . ", " . to_int($admin_forms_fields->form_params['on_page']) . " )";
$param['attributes']['type'] = 'button';
$admin_forms_fields->AddButton($param);

// Кнопка "Применить".
$param = array();
$param['name'] = 'add_site';
$param['caption'] = $GLOBALS['MSG_site']['site_apply'];
$param['attributes']['onclick'] = "return SendForm('{$admin_forms_fields->GetWindowId()}', '{$admin_forms_fields->AAction}', '{$admin_forms_fields->AAdditionalParams}', this, ".to_int($_REQUEST['admin_forms_id']).", 'load_data', " . to_int($admin_forms_fields->form_params['current_page']) . ", " . to_int($admin_forms_fields->form_params['on_page']) . " )";
$param['attributes']['type'] = 'submit';
$admin_forms_fields->AddButton($param);

// Отображение формы.
$admin_forms_fields->ShowForm();
?>