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

// Title страницы
$form_params['title'] = $edit_position_search_id == 0
? $GLOBALS['MSG_seo']['position_query_add_form_title']
: $GLOBALS['MSG_seo']['position_query_edit_form_title'];

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

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

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

$admin_forms_fields = new admin_forms_fields();

//Хлебные крошки
$form_params['path_array'] = array(
array (
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/seo/seo.php', '', 141, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/seo/seo.php', '', 141, 'load_data'),
'name' => $GLOBALS['MSG_seo']['header_admin_characteristic_forms']),
array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/seo/seo.php', '', 142, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/seo/seo.php', '', 142, 'load_data'),
'name' => $GLOBALS['MSG_seo']['menu_search_query']),
array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/seo/seo.php', '', 144, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/seo/seo.php', '', 144, 'load_data'),
'name' => $GLOBALS['MSG_seo']['menu_statistic']));

$admin_forms_fields->admin_forms_fields($form_params);

$row = false;

// Редактировние GetPositionSearch
if ($edit_position_search_id)
{
	$DateClass = new DateClass();
	$seo = new seo();
	
	$row = $seo->GetPositionSearch($edit_position_search_id);
	
	$seo_search_query_id = $row['seo_search_query_id'];
	$users_id = $row['users_id'];
	$seo_position_search_query_id = $row['seo_position_search_query_id'];	
	$seo_position_search_query_date_time = $DateClass->datetime_format($row['seo_position_search_query_date_time']);
	$seo_position_search_query_yandex = $row['seo_position_search_query_yandex'];
	$seo_position_search_query_rambler = $row['seo_position_search_query_rambler'];
	$seo_position_search_query_google = $row['seo_position_search_query_google'];
	$seo_position_search_query_aport = $row['seo_position_search_query_aport'];
	$seo_position_search_query_gogo = $row['seo_position_search_query_gogo'];
	$seo_position_search_query_yahoo = $row['seo_position_search_query_yahoo'];
	$seo_position_search_query_livesearch = $row['seo_position_search_query_livesearch'];
}
// Добавление
else
{	
	$seo_position_search_query_date_time = date("d.m.Y H:i:s");
	$users_id = 0;
	$seo_position_search_query_yandex = 0;
	$seo_position_search_query_rambler = 0;
	$seo_position_search_query_google = 0;
	$seo_position_search_query_aport = 0;
	$seo_position_search_query_gogo = 0;
	$seo_position_search_query_yahoo = 0;
	$seo_position_search_query_livesearch = 0;
}

// Параметры.

//Вкладка
$tab_id = $admin_forms_fields->AddTab('');

//Дата
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_date_time';
$param['caption'] = $GLOBALS['MSG_seo']['seo_add_edit_characteristic_caption_date'];
$param['type'] = 11; // Дата.
$param['value'] = $seo_position_search_query_date_time;

$admin_forms_fields->AddField($param);

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

//Яндекс
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_yandex';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_yandex'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_yandex;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

//Rambler
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_rambler';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_rambler'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_rambler;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

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

//Google
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_google';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_google'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_google;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

//Aport
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_aport';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_aport'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_aport;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

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

//GoGo
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_gogo';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_gogo'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_gogo;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

//Yahoo
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_yahoo';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_yahoo'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_yahoo;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

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

// Bing
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'seo_position_search_query_livesearch';
$param['caption'] = $GLOBALS['MSG_seo']['position_search_livesearch'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $seo_position_search_query_livesearch;
$param['format']['minlen']['value'] = 0;
$param['format']['maxlen']['value'] = 2;
$param['format']['lib']['value'] = "integer";
$param['attributes']['style'] = 'width: 300px;';
$param['div_attributes']['style'] = 'float: left;';
$admin_forms_fields->AddField($param);

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

// Добавляем скрытое поле с идентификатором сущности, т.к. идет редактирование.
	$param = array();
	$param['tab_id'] = $tab_id;
	$param['name'] = 'seo_search_query_id';
	$param['type'] = 4; // Скрытое поле.
	$param['value'] = to_int($row['seo_search_query_id']);
	
	$admin_forms_fields->AddField($param);

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


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