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

// Title для страницы
$form_params['title'] = $tag_id == 0
? $GLOBALS['MSG_tag']['form_edit_add_title_add']
: $GLOBALS['MSG_tag']['form_edit_add_title_edit'];

// Метод отправки данных
$form_params['form_attribs']['method'] = 'post';

// Адрес всех обработчиков модуля – главный файл формы
$form_params['form_attribs']['action'] = '/admin/tag/tag.php';

// Метод отправки данных
$form_params['form_attribs']['name'] = 'EditAddTag';

$admin_forms_fields = & singleton('admin_forms_fields');

$i = 0;

//Хлебные крошки
$new_path_array = array();
$new_path_array[$i]['name'] = $GLOBALS['MSG_tag']['title'];
$new_path_array[$i]['link'] = $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/tag/tag.php', '', 173, 'load_data');
$new_path_array[$i]['onclick'] = $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/tag/tag.php', '', 173, 'load_data');

$form_params['path_array'] = $new_path_array;

$admin_forms_fields->admin_forms_fields($form_params);

// Редактировние
if ($tag_id)
{
	$Tag = & singleton('Tag');
	$row = $Tag->GetTag($tag_id);
	
	$tag_name = $row['tag_name'];
	$users_id = $row['users_id'];
}
// Добавление
else
{
	$tag_name = '';
	$users_id = false;
}

$tab_id = $admin_forms_fields->AddTab('');

$param = array();

// Ключевое слово.
$param['tab_id'] = $tab_id;
$param['name'] = 'tag_name';
$param['caption'] = $GLOBALS['MSG_tag']['form_edit_add_tag_name'];
$param['type'] = 0; // Поле ввода
$param['value'] = $tag_name;
$param['attributes']['class'] = 'large';
$param['format']['minlen']['value'] = 1;
$param['format']['maxlen']['value'] = 255;

$admin_forms_fields->AddField($param);

// Если редактирование
if ($tag_id)
{
	$param = array();
	$param['tab_id'] = $tab_id;
	$param['name'] = 'tag_id';
	$param['caption'] = '';
	$param['type'] = 4; // hidden.
	$param['value'] = $tag_id;

	$admin_forms_fields->AddField($param);
}

$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'users_id';
$param['caption'] = '';
$param['type'] = 4; // hidden.
$param['value'] = $users_id;

$admin_forms_fields->AddField($param);

// Кнопка "Сохранить".
$param = array();
$param['name'] = 'save_tag';
$param['caption'] = $GLOBALS['MSG_tag']['button_save'];
$param['attributes']['onclick'] = "return doSendForm('{$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'] = 'apply_tag';
$param['caption'] = $GLOBALS['MSG_tag']['button_apply'];
$param['image'] = '/admin/images/add.gif';
$param['attributes']['onclick'] = "return doSendForm('{$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();
?>