Translated using Weblate (Portuguese)
[phpmyadmin.git] / prefs_forms.php
blob5d8b787deeeb8e514fe7f614f05b007744fd4bf6
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_userprefsPageInit();
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(
46 $cfg['PmaAbsoluteUri'] . 'prefs_forms.php'
47 . PMA_URL_getCommon($url_params, '&')
49 exit;
52 $error = null;
53 if ($form_display->process(false) && !$form_display->hasErrors()) {
54 // save settings
55 $result = PMA_saveUserprefs(ConfigFile::getInstance()->getConfigArray());
56 if ($result === true) {
57 // reload config
58 $GLOBALS['PMA_Config']->loadUserPreferences();
59 $hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
60 PMA_userprefsRedirect(
61 'prefs_forms.php',
62 array('form' => $form_param),
63 $hash
65 exit;
66 } else {
67 $error = $result;
71 // display forms
72 $response = PMA_Response::getInstance();
73 $header = $response->getHeader();
74 $scripts = $header->getScripts();
75 $scripts->addFile('config.js');
77 require 'libraries/user_preferences.inc.php';
78 if ($error) {
79 $error->display();
81 if ($form_display->hasErrors()) {
82 // form has errors
84 <div class="error config-form">
85 <b><?php echo __('Cannot save settings, submitted form contains errors') ?></b>
86 <?php $form_display->displayErrors(); ?>
87 </div>
88 <?php
90 $form_display->display(true, true);