<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Форма добаления/редактирования информационной системы
 * 
 * Файл: /admin/InformationSystems/action/form_edit_add_information_system.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$form_params = array();
$form_params['title'] = $information_system_id == 0
? $GLOBALS['MSG_information_systems']['information_systems_add_form_title']
: $GLOBALS['MSG_information_systems']['information_systems_edit_form_title'];

$form_params['form_attribs']['method'] = 'post';
$form_params['form_attribs']['action'] = '/admin/InformationSystems/InformationSystems.php';
$form_params['form_attribs']['name'] = 'EditAddInformationSystem';

$admin_forms_fields = new admin_forms_fields();

$InformationSystem = & singleton('InformationSystem');

$current_dir_id = to_int($_REQUEST['information_systems_dir_parent_id']);

// Формируем "хлебные крошки"
$new_path_array = array();

$new_path_array[] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/InformationSystems/InformationSystems.php', '', 11, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/InformationSystems/InformationSystems.php', '', 11, 'load_data'),
'name' => $GLOBALS['MSG_information_systems']['show_information_systems_title']);

// Строим "хлебные крошки"
$path_array = $InformationSystem->GetInformationSystemsDirPathArray($current_dir_id);

// Меняем порядок следования элементов в массиве на обратный
$path_array = array_reverse($path_array, true);

// Преобразуем идентификаторы групп в ссылки на группы.
if ($path_array)
{
	foreach ($path_array as $key => $value)
	{
		$new_path_array[] = array (
		'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/InformationSystems/InformationSystems.php', "&information_systems_dir_parent_id={$key}", 11, 'load_data'),
		'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/InformationSystems/InformationSystems.php', "&information_systems_dir_parent_id={$key}", 11, 'load_data'),
		'name' => $value['information_systems_dir_name']);
	}
}

// Передаем в массив для констурктора хлебные крошки
$form_params['path_array'] = $new_path_array;

$admin_forms_fields->admin_forms_fields($form_params);

$DataBase = & singleton('DataBase');

// Редактирование информационной системы
if ($information_system_id)
{
	$type = 1;

	// Получаем данные о пользователе системы администрирования из БД
	$information_system_row = $InformationSystem->GetInformationSystem($information_system_id, false, array('cache_off' => true));

	$information_system_name = $information_system_row['information_systems_name'];
	$information_systems_dir_id = $information_system_row['information_systems_dir_id'];
	$information_system_description = $information_system_row['information_systems_description'];
	$site_id = $information_system_row['site_id'];
	$information_system_access = $information_system_row['information_systems_access'];
	$information_system_add_form_captcha_used = $information_system_row['information_systems_captcha_used'];
	$information_system_watermark_file = $information_system_row['information_systems_watermark_file'];
	$information_system_watermark_default_used = $information_system_row['information_systems_default_used_watermark'];
	$information_system_watermark_default_used_small = $information_system_row['information_systems_default_used_small_watermark'];
	$information_system_watermark_default_position_x = $information_system_row['information_systems_watermark_default_position_x'];
	$information_system_watermark_default_position_y = $information_system_row['information_systems_watermark_default_position_y'];
	$structure_id = $information_system_row['structure_id'];
	$items_on_page = $information_system_row['information_systems_items_on_page'];

	// Картинки.
	$information_system_image_big_max_width = $information_system_row['information_systems_image_big_max_width'];
	$information_system_image_big_max_height = $information_system_row['information_systems_image_big_max_height'];
	$information_system_image_small_max_width = $information_system_row['information_systems_image_small_max_width'];
	$information_system_image_small_max_height = $information_system_row['information_systems_image_small_max_height'];

	// Сортировка.
	$information_system_items_order_field = to_int($information_system_row['information_systems_items_order_field']);
	$information_system_items_order_type = to_int($information_system_row['information_systems_items_order_type']);
	$information_system_group_items_order_type = to_int($information_system_row['information_systems_group_items_order_type']);
	$information_system_group_items_order_field = to_int($information_system_row['information_systems_group_items_order_field']);

	// Формат даты.
	$information_system_format_date = to_str($information_system_row['information_systems_format_date']);
	$information_system_format_datetime = to_str($information_system_row['information_systems_format_datetime']);

	$information_systems_url_type = $information_system_row['information_systems_url_type'];

	$information_systems_typograph_item = $information_system_row['information_systems_typograph_item'];
	$information_systems_typograph_group = $information_system_row['information_systems_typograph_group'];
	
	$information_system_apply_tags_automatic = $information_system_row['information_systems_apply_tags_automatic'];
	$information_systems_file_name_conversion = $information_system_row['information_systems_file_name_conversion'];
	$information_systems_apply_keywords_automatic = $information_system_row['information_systems_apply_keywords_automatic'];
	
	$information_systems_image_big_max_width_group = $information_system_row['information_systems_image_big_max_width_group'];
	$information_systems_image_big_max_height_group = $information_system_row['information_systems_image_big_max_height_group'];
	$information_systems_image_small_max_width_group = $information_system_row['information_systems_image_small_max_width_group'];
	$information_systems_image_small_max_height_group = $information_system_row['information_systems_image_small_max_height_group'];
	
	// Сохранение пропорций картинок
	$information_systems_default_save_proportions = $information_system_row['information_systems_default_save_proportions'];
}
// Добавления информационной системы
else
{
	$type = 0;
	$site_id = CURRENT_SITE;
	$information_systems_dir_id = $current_dir_id;
	$information_system_add_form_captcha_used = 1;
	$information_system_watermark_file = '';
	$information_system_watermark_default_used = 1;
	$information_system_watermark_default_used_small = 1;
	$items_on_page = 10;
	$structure_id = 0;

	// Формат даты.
	$information_system_format_date = '%d.%m.%Y';
	$information_system_format_datetime = '%d.%m.%Y %H:%M:%S';

	// Картинки.
	$information_system_image_big_max_width = 300;
	$information_system_image_big_max_height = 300;
	$information_system_image_small_max_width = 70;
	$information_system_image_small_max_height = 70;

	$information_systems_url_type = 0;

	$information_systems_typograph_item = 1;
	$information_systems_typograph_group = 1;
	$information_system_apply_tags_automatic = 1;	
	$information_systems_file_name_conversion = 1;
	$information_systems_apply_keywords_automatic = 1;
	
	$information_systems_image_big_max_width_group = 300;
	$information_systems_image_big_max_height_group = 300;
	$information_systems_image_small_max_width_group = 70;
	$information_systems_image_small_max_height_group = 70;
	
	$information_systems_default_save_proportions = 1;
}

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

// Название информационной системы.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_name';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_name'];
$param['type'] = 0; // Поле ввода.
$param['attributes']['class'] = 'large';
$param['value'] = to_str($information_system_name);
$param['format']['minlen']['value'] = 1;
$param['format']['maxlen']['value'] = 255;
$admin_forms_fields->AddField($param);

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

// Список разделов информационных систем
$param = array ();
$param['tab_id'] = $tab_id;
$param['name'] = 'current_information_systems_dir_id';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_dirs_add_form_group'];
$param['type'] = 2; // Выпадающий список.
$param['value'] = $information_systems_dir_id;

$items = array ();
$mas = array ();

$param_dirs = array();
$param_dirs['information_systems_dir_parent_id'] = 0;
$param_dirs['site_id'] = CURRENT_SITE;
//$param_dirs['separator'] = ''; 

$mas = $InformationSystem->GetInformationSystemsDirs($param_dirs);

$items[0] = '..';
$count_dirs = count($mas);

for ($i = 0; $i < $count_dirs; $i++)
{
    $items[$mas[$i]['information_systems_dir_id']] = $mas[$i]['separator'] . $mas[$i]['information_systems_dir_name'];
}

$param['items'] = $items;

$param['div_attributes']['style'] = '';
$param['attributes']['style'] = 'width: 320px; float: left;';
$param['apply_filter'] = true;

$admin_forms_fields->AddField($param);

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


// Описание информационной системы.

// Определим $template_id для визуального редактора, для этого узнаем параметры у структуры
$structure = & singleton('Structure');

$structure_row = $structure->GetStructureItem($structure_id);

$template_id = to_int($structure_row['templates_id']);

$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_description';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_description'];
if (!defined('ALLOW_WYSIWYG_DESCRIPTION_IS') || ALLOW_WYSIWYG_DESCRIPTION_IS)
{
	$param['type'] = 7; // Визуальный редактор.
	$param['template'] = $template_id;
}
else
{
	$param['type'] = 5; // textarea
	$param['attributes'] = array ();
	$param['attributes']['rows'] = 7;
	$param['attributes']['style'] = 'width: 100%;';
}
$param['value'] = to_str($information_system_description);

$admin_forms_fields->AddField($param);

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

// Сайт
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'site_id';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_site'];
$param['type'] = 2; // Выпадающий список.
$value = $site_id;

$param['value'] = $value;

$items = array();

// Получаем список сайтов
$site = & singleton ('site');

// Получаем данные о пользователе
$UserAccess = new user_access();
$user_row = $UserAccess->GetUserByName($_SESSION['valid_user']);

// Выбираем доступные сайты
$res = $site->SelectSites(array('users_type_id' => to_int($user_row['users_type_id'])));

while ($rows = mysql_fetch_assoc($res))
{
	$sites_array[$rows['site_id']] = $rows['site_name'];
}

$param['items'] = $sites_array;

$admin_forms_fields->AddField($param);

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

// Узел структуры.
$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'structure_id';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_structure'];
$param['type'] = 2; // Выпадающий список.

$value = to_int($structure_id);

$param['value'] = $value;

$items = array();

// Выбираем все элементы структуры для данного сайта
$Structure = & singleton('Structure');

$result_structure = $Structure->GetStructure("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $site_id, 0, -1, 0);

$items[0] = "..";

// Проверяем наличие узлов структуры
if (count($result_structure) > 0)
{
	foreach ($result_structure as $key => $value)
	{
		$items[$value['structure_id']] = $value['name_with_separator'];
	}
}

$param['items'] = $items;

$admin_forms_fields->AddField($param);

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

// Группа доступа
$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_access';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_access'];
$param['type'] = 2; // Выпадающий список.

$value = to_int($information_system_access);

$param['value'] = $value;

$items = array();

if (class_exists('SiteUsers'))
{
	$site_users = & singleton('SiteUsers');

	$param_site_users_group['order_field'] = 'site_users_group_name';

	$result = $site_users->SelectSiteUsersGroups($param_site_users_group);

	$count_site_users_groups = mysql_num_rows($result);
}
else
{
	$count_site_users_groups = 0;
}

for ($i = -2; $i < $count_site_users_groups - 1; $i++)
{
	switch ($i)
	{
		case -2:
			{
				$option_text = $GLOBALS['MSG_information_systems']['information_all'];
				$option_value = 0;
				break;
			}
		default:
			{
				$row = mysql_fetch_assoc($result);
				$option_text = $row["site_users_group_name"];
				$option_value = $row["site_users_group_id"];
			}
	}

	$items[$option_value] = $option_text;
}

$param['items'] = $items;

$admin_forms_fields->AddField($param);

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

// Число элементов на странице
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_items_on_page';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_items_on_page'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($items_on_page);

$admin_forms_fields->AddField($param);

// Тип формирования URL для информационных элементов
$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_url_type';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_create_url_type'];
$param['type'] = 2; // Выпадающий список.

$value = $information_systems_url_type;

$param['value'] = $value;

$items = array();

$items[0] = $GLOBALS['MSG_information_systems']['information_systems_add_form_create_url_type_identificater'];
$items[1] = $GLOBALS['MSG_information_systems']['information_systems_add_form_create_url_type_transliteration'];

$param['items'] = $items;

$admin_forms_fields->AddField($param);

// Автоматически применять тэги
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_apply_tags_automatic';
$param['html_id'] = 'id_apply_tags_automatic';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_apply_tags_automatic'];
$param['value'] = to_int($information_system_apply_tags_automatic);

$admin_forms_fields->AddField($param);

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

// Преобразовывать названия загружаемых файлов  
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_file_name_conversion';
$param['html_id'] = 'id_add_form_file_name_conversion';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_file_name_conversion'];
$param['value'] = to_int($information_systems_file_name_conversion);

$admin_forms_fields->AddField($param);

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

// Автоматическая генерация ключевых слов
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_apply_keywords_automatic';
$param['html_id'] = 'id_apply_keywords_automatic';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_apply_keywords_automatic'];
$param['value'] = to_int($information_systems_apply_keywords_automatic);

$admin_forms_fields->AddField($param);

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


// Сортировка.
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_information_systems']['information_systems_form_tab_2']);

// Поле сортировки элементов.
$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_items_order_field';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_order_field'];
$param['type'] = 2; // Выпадающий список.

$value = to_int($information_system_items_order_field);

$param['value'] = $value;

$items = array();

$items[0] = $GLOBALS['MSG_information_systems']['information_date'];
$items[1] = $GLOBALS['MSG_information_systems']['show_information_groups_name'];
$items[2] = $GLOBALS['MSG_information_systems']['show_information_propertys_order'];

$param['items'] = $items;

$admin_forms_fields->AddField($param);

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

// Направление сортировки элементов.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_items_order_type';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_order_type'];
$param['type'] = 2; // Выпадающий список.

$value = to_int($information_system_items_order_type);

$param['value'] = $value;

$items = array();

$items[0] = $GLOBALS['MSG_information_systems']['sort_to_increase'];
$items[1] = $GLOBALS['MSG_information_systems']['sort_to_decrease'];

$param['items'] = $items;

$admin_forms_fields->AddField($param);

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

// Поле сортировки групп.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_group_items_order_field';
$param['caption'] = $GLOBALS['MSG_information_systems']['is_sort_field_group_title'];
$param['type'] = 2; // Выпадающий список.

$value = to_int($information_system_group_items_order_field);

$param['value'] = $value;

$items = array();

$items[0] = $GLOBALS['MSG_information_systems']['show_information_groups_name'];
$items[1] = $GLOBALS['MSG_information_systems']['show_information_propertys_order'];

$param['items'] = $items;

$admin_forms_fields->AddField($param);

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

// Направление сортировки групп.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_group_items_order_type';
$param['caption'] = $GLOBALS['MSG_information_systems']['is_sort_order_group_type'];
$param['type'] = 2; // Выпадающий список.

$value = to_int($information_system_group_items_order_type);

$param['value'] = $value;

$items = array();

$items[0] = $GLOBALS['MSG_information_systems']['sort_to_increase'];
$items[1] = $GLOBALS['MSG_information_systems']['sort_to_decrease'];

$param['items'] = $items;

$admin_forms_fields->AddField($param);

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

// Форматы.
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_information_systems']['information_systems_form_tab_3']);

// Формат даты.
$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_format_date';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_format_date'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_str($information_system_format_date);
$param['format']['minlen']['value'] = 1;
$param['format']['maxlen']['value'] = 255;
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

// Формат даты.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_format_datetime';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_format_datetime'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_str($information_system_format_datetime);
$param['format']['minlen']['value'] = 1;
$param['format']['maxlen']['value'] = 255;
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

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

// Максимальная ширина большой картинки.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_big_max_width';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_big_max_width'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_system_image_big_max_width);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

// Максимальная высота большой картинки.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_big_max_height';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_big_max_height'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_system_image_big_max_height);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

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

// Максимальная ширина малой картинки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_small_max_width';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_small_max_width'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_system_image_small_max_width);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

// Максимальная высота малой картинки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_small_max_height';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_small_max_height'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_system_image_small_max_height);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

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

// Максимальная ширина большой картинки.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_big_max_width_group';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_big_max_width_group'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_systems_image_big_max_width_group);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

// Максимальная высота большой картинки.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_big_max_height_group';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_big_max_height_group'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_systems_image_big_max_height_group);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

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

// Максимальная ширина малой картинки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_small_max_width_group';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_small_max_width_group'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_systems_image_small_max_width_group);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

// Максимальная высота малой картинки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_image_small_max_height_group';
$param['caption'] = $GLOBALS['MSG_information_systems']['info_sys_form_small_max_height_group'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_int($information_systems_image_small_max_height_group);
$param['format']['lib']['value'] = 'integer';
$param['div_attributes']['style'] = 'float: left; margin-right: 10px; width: 300px';
$admin_forms_fields->AddField($param);

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

// Использовать CAPTCHA
$param = array();

$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_captcha_used';
$param['html_id'] = 'id_captcha_used';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_captcha_used'];
$param['value'] = to_int($information_system_add_form_captcha_used);

$admin_forms_fields->AddField($param);

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

// Типографировать элементы
$param = array();

$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_typograph_item';
$param['html_id'] = 'id_typograph_item';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_typograph_item'];
$param['value'] = to_int($information_systems_typograph_item);

$admin_forms_fields->AddField($param);

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

// Типографировать группы
$param = array();

$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_typograph_group';
$param['html_id'] = 'id_typograph_group';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_typograph_group'];
$param['value'] = to_int($information_systems_typograph_group);

$admin_forms_fields->AddField($param);

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

// Водяной знак
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_information_systems']['information_systems_form_tab_4']);

$param = array();

$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_watermark_file';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_watermark_file'];
$param['type'] = 9; // Поле загрузки файла.

$param['options'] = array();

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

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

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

// Заголовок поля загрузки малого изображения
$param['options']['load_small_image_caption'] = '';

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

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

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

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

// Параметр, определяющий отображать ли настройки большого изображения
$param['options']['show_big_image_params'] = 0;

$information_system_dir = UPLOADDIR . 'information_system_' . $information_system_id . '/';

// Задано большое изображение
if ($information_system_watermark_file != '')
{
	// Адрес большого загруженного изображения
	$param['options']['big_image_path'] = '/' . $information_system_dir . rawurlencode($information_system_watermark_file);

	$param['options']['href_delete_big_image'] = "/admin/InformationSystems/InformationSystems.php?delete_information_system_watermark={$information_system_id}";

	// Значение для onclick
	$param['options']['onclick_delete_big_image'] = "sendRequest('{$param['options']['href_delete_big_image']}', 'get', callback_function_exec_from_return); return false;";
}
else
{
	$param['options']['big_image_path'] = '';
	$param['options']['href_delete_big_image'] = '';
	$param['options']['onclick_delete_big_image'] = '';
}

$param['options']['small_image_path'] = '';
$param['attributes']['size'] = '80%;';

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

// Использовать сохранение пропорций изображения по умолчанию
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_default_save_proportions';
$param['html_id'] = 'id_information_systems_default_save_proportions';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_default_save_proportions'];
$param['value'] = to_int($information_systems_default_save_proportions);

$admin_forms_fields->AddField($param);

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

//Использовать watermark по умолчанию
$param = array();
$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_default_used_watermark';
$param['html_id'] = 'id_captcha_default_used';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_watermark_default_used'];
$param['value'] = to_int($information_system_watermark_default_used);

$admin_forms_fields->AddField($param);

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

// Использовать watermark по умолчанию для малых изображений
$param = array();

$param['tab_id'] = $tab_id;
$param['type'] = 1;
$param['name'] = 'information_systems_default_used_small_watermark';
$param['html_id'] = 'id_captcha_default_used_small';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_watermark_default_used_small'];
$param['value'] = to_int($information_system_watermark_default_used_small);

$admin_forms_fields->AddField($param);

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

// Позиция по оси X по умолчанию
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_watermark_default_position_x';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_watermark_default_position_x'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_str($information_system_watermark_default_position_x);

$admin_forms_fields->AddField($param);

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

// Позиция по оси Y по умолчанию
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_watermark_default_position_y';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_watermark_default_position_y'];
$param['type'] = 0; // Поле ввода.
$param['value'] = to_str($information_system_watermark_default_position_y);

$admin_forms_fields->AddField($param);

// Добавляем скрытое поле с идентификатором родительского раздела
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'information_systems_dir_parent_id';
$param['type'] = 4; // Скрытое поле.
$param['value'] = $current_dir_id;
$admin_forms_fields->AddField($param);

// Редактирование данных об информационной системе
if ($information_system_id)
{
	// Добавляем скрытое поле с идентификатором пользователя.
	$param = array();

	$param['tab_id'] = $tab_id;
	$param['name'] = 'information_system_id';
	$param['type'] = 4; // Скрытое поле.
	$param['value'] = $information_system_id;
	$admin_forms_fields->AddField($param);
}

// Кнопка "Сохранить".
$param = array();
$param['name'] = 'save_information_system';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_save_form_button_name'];
$param['image'] = '/admin/images/add.gif';
$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_information_system';
$param['caption'] = $GLOBALS['MSG_information_systems']['information_systems_add_form_button_name'];
$param['image'] = '/admin/images/add.gif';
$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();
?>