Translated using Weblate (Greek)
[phpmyadmin.git] / prefs_forms.php
blobd0c09b0b6190edab71b733f3115bfd2da6056038
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 $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
22 PMA_userprefsPageInit($cf);
24 // handle form processing
26 $form_param = filter_input(INPUT_GET, 'form');
27 if (! isset($forms[$form_param])) {
28 $forms_keys = array_keys($forms);
29 $form_param = array_shift($forms_keys);
32 $form_display = new FormDisplay($cf);
33 foreach ($forms[$form_param] as $form_name => $form) {
34 // skip Developer form if no setting is available
35 if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
36 continue;
38 $form_display->registerForm($form_name, $form, 1);
41 if (isset($_POST['revert'])) {
42 // revert erroneous fields to their default values
43 $form_display->fixErrors();
44 // redirect
45 $url_params = array('form' => $form_param);
46 PMA_sendHeaderLocation(
47 $cfg['PmaAbsoluteUri'] . 'prefs_forms.php'
48 . PMA_URL_getCommon($url_params, 'text')
50 exit;
53 $error = null;
54 if ($form_display->process(false) && !$form_display->hasErrors()) {
55 // save settings
56 $result = PMA_saveUserprefs($cf->getConfigArray());
57 if ($result === true) {
58 // reload config
59 $GLOBALS['PMA_Config']->loadUserPreferences();
60 $hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
61 PMA_userprefsRedirect(
62 'prefs_forms.php',
63 array('form' => $form_param),
64 $hash
66 exit;
67 } else {
68 $error = $result;
72 // display forms
73 $response = PMA_Response::getInstance();
74 $header = $response->getHeader();
75 $scripts = $header->getScripts();
76 $scripts->addFile('config.js');
78 require 'libraries/user_preferences.inc.php';
79 if ($error) {
80 $error->display();
82 if ($form_display->hasErrors()) {
83 // form has errors
85 <div class="error config-form">
86 <b><?php echo __('Cannot save settings, submitted form contains errors!') ?></b>
87 <?php $form_display->displayErrors(); ?>
88 </div>
89 <?php
91 $form_display->display(true, true);