Display forms

This commit is contained in:
Crack
2010-06-11 17:11:15 +02:00
parent 3ed3539958
commit 03e66cd0d4

View File

@@ -11,7 +11,10 @@
*/
require_once './libraries/common.inc.php';
require_once './libraries/user_preferences.lib.php';
require_once './libraries/config/config_functions.lib.php';
require_once './libraries/config/messages.inc.php';
require_once './libraries/config/ConfigFile.class.php';
require_once './libraries/config/Form.class.php';
require_once './libraries/config/FormDisplay.class.php';
$GLOBALS['js_include'][] = 'js/settings_forms.js';
@@ -24,18 +27,16 @@ if (! empty($message)) {
unset($message);
}
$common_url_query = PMA_generate_common_url('', '');
$tabs = array();
$active_formset = filter_input(INPUT_GET, 'form');
if (!isset($forms[$active_formset])) {
$active_formset = array_shift(array_keys($forms));
$form_param = filter_input(INPUT_GET, 'form');
if (!isset($forms[$form_param])) {
$form_param = array_shift(array_keys($forms));
}
foreach (array_keys($forms) as $form) {
$tabs[] = array(
'link' => 'user_preferences.php',
'text' => PMA_ifSetOr($GLOBALS['strSetupForm_' . $form], $form), // TODO: remove ifSetOr
'active' => $form == $active_formset,
'active' => $form == $form_param,
'url_params' => array('form' => $form)
);
}
@@ -43,10 +44,47 @@ foreach (array_keys($forms) as $form) {
echo PMA_generate_html_tabs($tabs, array());
$form_display = new FormDisplay();
foreach ($forms[$active_formset] as $form_name => $form) {
foreach ($forms[$form_param] as $form_name => $form) {
$form_display->registerForm($form_name, $form);
}
if (filter_input(INPUT_GET, 'mode') == 'revert') {
// revert erroneous fields to their default values
$form_display->fixErrors();
// redirect
$url_params = array('form' => $form_param);
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'user_preferences.php'
. PMA_generate_common_url($url_params, '&'));
exit;
}
if (!$form_display->process(false)) {
// handle form view and failed POST
$form_display->display(true, true);
} else {
// check for form errors
if ($form_display->hasErrors()) {
// form has errors, show warning
$separator = PMA_get_arg_separator('html');
?>
<div class="warning">
<h4><?php echo __('Warning') ?></h4>
<?php echo PMA_lang('error_form') ?><br />
<a href="?form=<?php echo $form_param ?>&amp;mode=revert"><?php echo PMA_lang('RevertErroneousFields') ?></a>
</div>
<?php $form_display->displayErrors() ?>
<a class="btn" href="user_preferences.php"><?php echo PMA_lang('IgnoreErrors') ?></a>
&nbsp;
<a class="btn" href="?form=<?php echo $form_param ?>&amp;mode=edit"><?php echo PMA_lang('ShowForm') ?></a>
<?php
} else {
// redirect
$url_params = array('form' => $form_param);
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'user_preferences.php'
. PMA_generate_common_url($url_params, '&'));
exit;
}
}
/**
* Displays the footer
*/