2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * User preferences page
8 declare(strict_types
=1);
10 use PhpMyAdmin\Config\ConfigFile
;
11 use PhpMyAdmin\Config\Forms\BaseForm
;
12 use PhpMyAdmin\Config\Forms\User\UserFormList
;
14 use PhpMyAdmin\Response
;
15 use PhpMyAdmin\Template
;
17 use PhpMyAdmin\UserPreferences
;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
24 * Gets some core libraries and displays a top message if required
26 require_once ROOT_PATH
. 'libraries/common.inc.php';
28 $template = new Template();
29 $userPreferences = new UserPreferences();
31 $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings
);
32 $userPreferences->pageInit($cf);
34 // handle form processing
36 $form_param = isset($_GET['form']) ?
$_GET['form'] : null;
37 $form_class = UserFormList
::get($form_param);
38 if (is_null($form_class)) {
39 Core
::fatalError(__('Incorrect form specified!'));
42 /** @var BaseForm $form_display */
43 $form_display = new $form_class($cf, 1);
45 if (isset($_POST['revert'])) {
46 // revert erroneous fields to their default values
47 $form_display->fixErrors();
49 $url_params = ['form' => $form_param];
50 Core
::sendHeaderLocation(
52 . Url
::getCommonRaw($url_params)
58 if ($form_display->process(false) && ! $form_display->hasErrors()) {
60 $result = $userPreferences->save($cf->getConfigArray());
61 if ($result === true) {
63 $GLOBALS['PMA_Config']->loadUserPreferences();
64 $tabHash = isset($_POST['tab_hash']) ?
$_POST['tab_hash'] : null;
65 $hash = ltrim($tabHash, '#');
66 $userPreferences->redirect(
68 ['form' => $form_param],
78 $response = Response
::getInstance();
79 $header = $response->getHeader();
80 $scripts = $header->getScripts();
81 $scripts->addFile('config.js');
83 require ROOT_PATH
. 'libraries/user_preferences.inc.php';
85 if ($form_display->hasErrors()) {
86 $formErrors = $form_display->displayErrors();
89 echo $template->render('preferences/forms/main', [
90 'error' => $error ?
$error->getDisplay() : '',
91 'has_errors' => $form_display->hasErrors(),
92 'errors' => $formErrors ??
null,
93 'form' => $form_display->getDisplay(true, true),
96 if ($response->isAjax()) {
97 $response->addJSON('_disableNaviSettings', true);
99 define('PMA_DISABLE_NAVI_SETTINGS', true);