Translated using Weblate (Korean)
[phpmyadmin.git] / prefs_forms.php
blob935b70083049fda3bf96478543f8e46b57698a66
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * User preferences page
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Config\ConfigFile;
9 use PhpMyAdmin\Config\FormDisplay;
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Response;
12 use PhpMyAdmin\Url;
14 /**
15 * Gets some core libraries and displays a top message if required
17 require_once 'libraries/common.inc.php';
18 require_once 'libraries/user_preferences.lib.php';
19 require_once 'libraries/config/config_functions.lib.php';
20 require_once 'libraries/config/messages.inc.php';
21 require 'libraries/config/user_preferences.forms.php';
23 $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
24 PMA_userprefsPageInit($cf);
26 // handle form processing
28 $form_param = isset($_GET['form']) ? $_GET['form'] : null;
29 if (! isset($forms[$form_param])) {
30 $forms_keys = array_keys($forms);
31 $form_param = array_shift($forms_keys);
34 $form_display = new FormDisplay($cf);
35 foreach ($forms[$form_param] as $form_name => $form) {
36 // skip Developer form if no setting is available
37 if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
38 continue;
40 $form_display->registerForm($form_name, $form, 1);
43 if (isset($_POST['revert'])) {
44 // revert erroneous fields to their default values
45 $form_display->fixErrors();
46 // redirect
47 $url_params = array('form' => $form_param);
48 Core::sendHeaderLocation(
49 './prefs_forms.php'
50 . Url::getCommonRaw($url_params)
52 exit;
55 $error = null;
56 if ($form_display->process(false) && !$form_display->hasErrors()) {
57 // save settings
58 $result = PMA_saveUserprefs($cf->getConfigArray());
59 if ($result === true) {
60 // reload config
61 $GLOBALS['PMA_Config']->loadUserPreferences();
62 $tabHash = isset($_POST['tab_hash']) ? $_POST['tab_hash'] : null;
63 $hash = ltrim($tabHash, '#');
64 PMA_userprefsRedirect(
65 'prefs_forms.php',
66 array('form' => $form_param),
67 $hash
69 exit;
70 } else {
71 $error = $result;
75 // display forms
76 $response = Response::getInstance();
77 $header = $response->getHeader();
78 $scripts = $header->getScripts();
79 $scripts->addFile('config.js');
81 require 'libraries/user_preferences.inc.php';
82 if ($error) {
83 $error->display();
85 if ($form_display->hasErrors()) {
86 // form has errors
88 <div class="error config-form">
89 <b>
90 <?php echo __('Cannot save settings, submitted form contains errors!') ?>
91 </b>
92 <?php echo $form_display->displayErrors(); ?>
93 </div>
94 <?php
96 echo $form_display->getDisplay(true, true);
98 if ($response->isAjax()) {
99 $response->addJSON('_disableNaviSettings', true);
100 } else {
101 define('PMA_DISABLE_NAVI_SETTINGS', true);