Translation update done using Pootle.
[phpmyadmin.git] / prefs_forms.php
blob1f6fb79c939cefa3df3bd7bafc0d2b6f7ca8297c
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';
19 require './libraries/config/user_preferences.forms.php';
21 PMA_userprefs_pageinit();
23 // handle form processing
25 $form_param = filter_input(INPUT_GET, 'form');
26 if (! isset($forms[$form_param])) {
27 $forms_keys = array_keys($forms);
28 $form_param = array_shift($forms_keys);
31 $form_display = new FormDisplay();
32 foreach ($forms[$form_param] as $form_name => $form) {
33 // skip Developer form if no setting is available
34 if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
35 continue;
37 $form_display->registerForm($form_name, $form, 1);
40 if (isset($_POST['revert'])) {
41 // revert erroneous fields to their default values
42 $form_display->fixErrors();
43 // redirect
44 $url_params = array('form' => $form_param);
45 PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'prefs_forms.php'
46 . PMA_generate_common_url($url_params, '&'));
47 exit;
50 $error = null;
51 if ($form_display->process(false) && !$form_display->hasErrors()) {
52 // save settings
53 $old_settings = PMA_load_userprefs();
54 $result = PMA_save_userprefs(ConfigFile::getInstance()->getConfigArray());
55 if ($result === true) {
56 // reload config
57 $GLOBALS['PMA_Config']->loadUserPreferences();
58 $hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
59 PMA_userprefs_redirect($forms, $old_settings, 'prefs_forms.php', array(
60 'form' => $form_param), $hash);
61 exit;
62 } else {
63 $error = $result;
67 // display forms
68 $GLOBALS['js_include'][] = 'config.js';
69 require './libraries/header.inc.php';
70 require './libraries/user_preferences.inc.php';
71 if ($error) {
72 $error->display();
74 if ($form_display->hasErrors()) {
75 // form has errors
77 <div class="error config-form">
78 <b><?php echo __('Cannot save settings, submitted form contains errors') ?></b>
79 <?php $form_display->displayErrors(); ?>
80 </div>
81 <?php
83 $form_display->display(true, true);
85 /**
86 * Displays the footer
88 require './libraries/footer.inc.php';