Configuration forms styling
[phpmyadmin.git] / user_preferences.php
blob1241b3a8a9eefa554cb93904f3dd94fbe4f216ae
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * User preferences page
6 * @package phpMyAdmin
7 */
9 /**
10 * Gets some core libraries and displays a top message if required
12 require_once './libraries/common.inc.php';
13 require_once './libraries/user_preferences.lib.php';
14 require_once './libraries/config/config_functions.lib.php';
15 require_once './libraries/config/messages.inc.php';
16 require_once './libraries/config/ConfigFile.class.php';
17 require_once './libraries/config/Form.class.php';
18 require_once './libraries/config/FormDisplay.class.php';
20 $GLOBALS['js_include'][] = 'config.js';
22 require_once './libraries/header.inc.php';
24 // Any message to display?
25 if (! empty($message)) {
26 PMA_showMessage($message);
27 unset($message);
30 $tabs = array();
31 $form_param = filter_input(INPUT_GET, 'form');
32 if (!isset($forms[$form_param])) {
33 $form_param = array_shift(array_keys($forms));
35 foreach (array_keys($forms) as $form) {
36 $tabs[] = array(
37 'link' => 'user_preferences.php',
38 'text' => PMA_ifSetOr($GLOBALS['strSetupForm_' . $form], $form), // TODO: remove ifSetOr
39 'active' => $form == $form_param,
40 'url_params' => array('form' => $form)
44 echo PMA_generate_html_tabs($tabs, array());
46 $form_display = new FormDisplay();
47 foreach ($forms[$form_param] as $form_name => $form) {
48 $form_display->registerForm($form_name, $form);
51 if (filter_input(INPUT_GET, 'mode') == 'revert') {
52 // revert erroneous fields to their default values
53 $form_display->fixErrors();
54 // redirect
55 $url_params = array('form' => $form_param);
56 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'user_preferences.php'
57 . PMA_generate_common_url($url_params, '&'));
58 exit;
60 if (!$form_display->process(false)) {
61 // handle form view and failed POST
62 $form_display->display(true, true);
63 } else {
64 // check for form errors
65 if ($form_display->hasErrors()) {
66 // form has errors, show warning
67 $separator = PMA_get_arg_separator('html');
69 <div class="warning">
70 <h4><?php echo __('Warning') ?></h4>
71 <?php echo PMA_lang('error_form') ?><br />
72 <a href="?form=<?php echo $form_param ?>&amp;mode=revert"><?php echo PMA_lang('RevertErroneousFields') ?></a>
73 </div>
74 <?php $form_display->displayErrors() ?>
75 <a class="btn" href="user_preferences.php"><?php echo PMA_lang('IgnoreErrors') ?></a>
76 &nbsp;
77 <a class="btn" href="?form=<?php echo $form_param ?>&amp;mode=edit"><?php echo PMA_lang('ShowForm') ?></a>
78 <?php
79 } else {
80 // redirect
81 $url_params = array('form' => $form_param);
82 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'user_preferences.php'
83 . PMA_generate_common_url($url_params, '&'));
84 exit;
88 /**
89 * Displays the footer
91 require_once './libraries/footer.inc.php';