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

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

if ($admin_language_id && $row_admin_language = $admin_forms->GetLanguage($admin_language_id))
{
	$admin_language_name = $row_admin_language['admin_language_name'];
	$admin_language_short_name = $row_admin_language['admin_language_short_name'];
	$admin_language_active = $row_admin_language['admin_language_active'];
	$admin_language_order = $row_admin_language['admin_language_order'];
}
else
{
	$admin_language_name = '';
	$admin_language_short_name = '';
	$admin_language_active = 0;
	$admin_language_order = 0;
}

$form_params = array();

$form_params['title'] = $admin_language_id == 0
? $GLOBALS['MSG_admin_forms']['form_add_forms_add_language_title']
: $GLOBALS['MSG_admin_forms']['form_add_forms_edit_language_title'];

$form_params['form_attribs']['method'] = 'post';
$form_params['form_attribs']['action'] = '/admin/admin_forms/admin_forms.php';
$form_params['form_attribs']['enctype'] = 'multipart/form-data';
$form_params['form_attribs']['name'] = 'EditAddAdminLanguage';

$admin_forms_fields = new admin_forms_fields();

// Формируем "хлебные крошки"
$new_path_array[] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/admin_forms/admin_forms.php', '', 1, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/admin_forms/admin_forms.php', '', 1, 'load_data'),
'name' => $GLOBALS['MSG_admin_forms']['show_form_fields_menu_admin_forms']);

$new_path_array[] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/admin_forms/admin_forms.php', '', 93, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/admin_forms/admin_forms.php', '', 93, 'load_data'),
'name' => $GLOBALS['MSG_admin_forms']['show_form_fields_menu_admin_languages']);

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

$admin_forms_fields->admin_forms_fields($form_params);

$admin_forms = & singleton('admin_forms');

// Закладка с названием/описанием.
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_admin_forms']['form_language_tab_1']);

// Название языка.
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'admin_language_name';
$param['caption'] = $GLOBALS['MSG_admin_forms']['form_language_name'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $admin_language_name;
$param['attributes']['class'] = 'large';
$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'] = 'admin_language_short_name';
$param['caption'] = $GLOBALS['MSG_admin_forms']['form_language_short_name'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $admin_language_short_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['type'] = 1;
$param['name'] = 'admin_language_active';
$param['html_id'] = 'id_admin_language_active';
$param['value'] = $admin_language_active;
$param['caption'] = $GLOBALS['MSG_admin_forms']['form_language_active'];

$admin_forms_fields->AddField($param);

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

// Порядок сортировки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'admin_language_order';
$param['caption'] = $GLOBALS['MSG_admin_forms']['form_language_order'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $admin_language_order;

$admin_forms_fields->AddField($param);

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

// Кнопка "Сохранить".
$param = array();
$param['name'] = 'save_admin_language';
$param['caption'] = $GLOBALS['MSG_admin_forms']['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_admin_language';
$param['caption'] = $GLOBALS['MSG_admin_forms']['apply'];
$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();
?>