Translated using Weblate (Hindi)
[phpmyadmin.git] / prefs_forms.php
blobfdb62ac6c7e86541e5903c6b93d88b6d00160ddc
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 $userPreferences = new UserPreferences();
22 $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings);
23 $userPreferences->pageInit($cf);
25 // handle form processing
27 $form_param = isset($_GET['form']) ? $_GET['form'] : null;
28 $form_class = UserFormList::get($form_param);
29 if (is_null($form_class)) {
30 Core::fatalError(__('Incorrect form specified!'));
33 $form_display = new $form_class($cf, 1);
35 if (isset($_POST['revert'])) {
36 // revert erroneous fields to their default values
37 $form_display->fixErrors();
38 // redirect
39 $url_params = array('form' => $form_param);
40 Core::sendHeaderLocation(
41 './prefs_forms.php'
42 . Url::getCommonRaw($url_params)
44 exit;
47 $error = null;
48 if ($form_display->process(false) && !$form_display->hasErrors()) {
49 // save settings
50 $result = $userPreferences->save($cf->getConfigArray());
51 if ($result === true) {
52 // reload config
53 $GLOBALS['PMA_Config']->loadUserPreferences();
54 $tabHash = isset($_POST['tab_hash']) ? $_POST['tab_hash'] : null;
55 $hash = ltrim($tabHash, '#');
56 $userPreferences->redirect(
57 'prefs_forms.php',
58 array('form' => $form_param),
59 $hash
61 exit;
62 } else {
63 $error = $result;
67 // display forms
68 $response = Response::getInstance();
69 $header = $response->getHeader();
70 $scripts = $header->getScripts();
71 $scripts->addFile('config.js');
73 require 'libraries/user_preferences.inc.php';
74 if ($error) {
75 $error->display();
77 if ($form_display->hasErrors()) {
78 // form has errors
80 <div class="error config-form">
81 <b>
82 <?php echo __('Cannot save settings, submitted form contains errors!') ?>
83 </b>
84 <?php echo $form_display->displayErrors(); ?>
85 </div>
86 <?php
88 echo $form_display->getDisplay(true, true, true, 'prefs_forms.php?form=' . $form_param, array(
89 'server' => $GLOBALS['server']
90 ));
92 if ($response->isAjax()) {
93 $response->addJSON('_disableNaviSettings', true);
94 } else {
95 define('PMA_DISABLE_NAVI_SETTINGS', true);