Translated using Weblate (Ukrainian)
[phpmyadmin.git] / prefs_forms.php
blobd596c999e15b0846d2e12a0d8abdd916dc556637
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\Forms\User\UserFormList;
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Response;
12 use PhpMyAdmin\Url;
13 use PhpMyAdmin\UserPreferences;
15 /**
16 * Gets some core libraries and displays a top message if required
18 require_once 'libraries/common.inc.php';
20 $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
21 UserPreferences::pageInit($cf);
23 // handle form processing
25 $form_param = isset($_GET['form']) ? $_GET['form'] : null;
26 $form_class = UserFormList::get($form_param);
27 if (is_null($form_class)) {
28 Core::fatalError(__('Incorrect form specified!'));
31 $form_display = new $form_class($cf, 1);
33 if (isset($_POST['revert'])) {
34 // revert erroneous fields to their default values
35 $form_display->fixErrors();
36 // redirect
37 $url_params = array('form' => $form_param);
38 Core::sendHeaderLocation(
39 './prefs_forms.php'
40 . Url::getCommonRaw($url_params)
42 exit;
45 $error = null;
46 if ($form_display->process(false) && !$form_display->hasErrors()) {
47 // save settings
48 $result = UserPreferences::save($cf->getConfigArray());
49 if ($result === true) {
50 // reload config
51 $GLOBALS['PMA_Config']->loadUserPreferences();
52 $tabHash = isset($_POST['tab_hash']) ? $_POST['tab_hash'] : null;
53 $hash = ltrim($tabHash, '#');
54 UserPreferences::redirect(
55 'prefs_forms.php',
56 array('form' => $form_param),
57 $hash
59 exit;
60 } else {
61 $error = $result;
65 // display forms
66 $response = Response::getInstance();
67 $header = $response->getHeader();
68 $scripts = $header->getScripts();
69 $scripts->addFile('config.js');
71 require 'libraries/user_preferences.inc.php';
72 if ($error) {
73 $error->display();
75 if ($form_display->hasErrors()) {
76 // form has errors
78 <div class="error config-form">
79 <b>
80 <?php echo __('Cannot save settings, submitted form contains errors!') ?>
81 </b>
82 <?php echo $form_display->displayErrors(); ?>
83 </div>
84 <?php
86 echo $form_display->getDisplay(true, true);
88 if ($response->isAjax()) {
89 $response->addJSON('_disableNaviSettings', true);
90 } else {
91 define('PMA_DISABLE_NAVI_SETTINGS', true);