<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Форма редактирования файлов.
 * 
 * Файл: /admin/wysiwyg/fm/action/edit_file_form.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$form_params = array();
$form_params['title'] = sprintf($GLOBALS['MSG_wysiwyg_fm']['fm_edit_file_form_title'], basename($file_path));
$form_params['form_attribs']['method'] = 'post';
$form_params['form_attribs']['action'] = '/admin/wysiwyg/fm/fm.php?cdir='. rawurlencode($current_dir);
$form_params['form_attribs']['name'] = 'EditFile';

$admin_forms_fields = new admin_forms_fields();

$new_path_array[] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/wysiwyg/fm/fm.php', '&cdir=' . rawurlencode($current_dir), 130, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/wysiwyg/fm/fm.php', '&cdir=' . rawurlencode($current_dir), 130, 'load_data'),
'name' => $GLOBALS['MSG_wysiwyg_fm']['fm_title']);

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

$admin_forms_fields->admin_forms_fields($form_params);

$File = new File();
$file_path = $File->PathCorrection($file_path);

if (is_file($file_path))
{
	$text_file = file_get_contents($file_path);
}
else
{
	$text_file = '';
}

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

// Текст файла
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'text_file';
$param['caption'] = $GLOBALS['MSG_wysiwyg_fm']['fm_edit_file_form_file_text'];
$param['type'] = 5; // Поле ввода.
$param['attributes'] = array();
$param['attributes']['cols'] = 60;
$param['attributes']['rows'] = 20;
$param['value'] = $text_file;

$admin_forms_fields->AddField($param);

// Скрытое поле с полным путем к файлу
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'filepath';
$param['type'] = 4; // Скрытое поле.
$param['value'] = $file_path;

$admin_forms_fields->AddField($param);

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

// Кнопка "Сохранить".
$param = array();
$param['name'] = 'save_file';
$param['caption'] = $GLOBALS['MSG_wysiwyg_fm']['fm_edit_file_form_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_file';
$param['caption'] = $GLOBALS['MSG_wysiwyg_fm']['fm_apply_file_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();

?>