diff --git a/libraries/classes/Controllers/Preferences/ExportController.php b/libraries/classes/Controllers/Preferences/ExportController.php index 621665045f53..46a19d7ee987 100644 --- a/libraries/classes/Controllers/Preferences/ExportController.php +++ b/libraries/classes/Controllers/Preferences/ExportController.php @@ -47,7 +47,7 @@ public function __construct( public function index(): void { global $cfg, $cf, $error, $tabHash, $hash; - global $server, $PMA_Config; + global $server, $PMA_Config, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -90,7 +90,13 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - $this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation)); + $cfgRelation = $this->relation->getRelationsParam(); + + $this->response->addHTML($this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ])); if ($formDisplay->hasErrors()) { $formErrors = $formDisplay->displayErrors(); diff --git a/libraries/classes/Controllers/Preferences/FeaturesController.php b/libraries/classes/Controllers/Preferences/FeaturesController.php index ee1e8f04f377..8a0c0a7d41d2 100644 --- a/libraries/classes/Controllers/Preferences/FeaturesController.php +++ b/libraries/classes/Controllers/Preferences/FeaturesController.php @@ -47,7 +47,7 @@ public function __construct( public function index(): void { global $cfg, $cf, $error, $tabHash, $hash; - global $server, $PMA_Config; + global $server, $PMA_Config, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -90,7 +90,13 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - $this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation)); + $cfgRelation = $this->relation->getRelationsParam(); + + $this->response->addHTML($this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ])); if ($formDisplay->hasErrors()) { $formErrors = $formDisplay->displayErrors(); diff --git a/libraries/classes/Controllers/Preferences/ImportController.php b/libraries/classes/Controllers/Preferences/ImportController.php index b3f7017f0237..78af26afe576 100644 --- a/libraries/classes/Controllers/Preferences/ImportController.php +++ b/libraries/classes/Controllers/Preferences/ImportController.php @@ -47,7 +47,7 @@ public function __construct( public function index(): void { global $cfg, $cf, $error, $tabHash, $hash; - global $server, $PMA_Config; + global $server, $PMA_Config, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -90,7 +90,13 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - $this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation)); + $cfgRelation = $this->relation->getRelationsParam(); + + $this->response->addHTML($this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ])); if ($formDisplay->hasErrors()) { $formErrors = $formDisplay->displayErrors(); diff --git a/libraries/classes/Controllers/Preferences/MainPanelController.php b/libraries/classes/Controllers/Preferences/MainPanelController.php index 1b36a180a469..cabd999843c6 100644 --- a/libraries/classes/Controllers/Preferences/MainPanelController.php +++ b/libraries/classes/Controllers/Preferences/MainPanelController.php @@ -47,7 +47,7 @@ public function __construct( public function index(): void { global $cfg, $cf, $error, $tabHash, $hash; - global $server, $PMA_Config; + global $server, $PMA_Config, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -90,7 +90,13 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - $this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation)); + $cfgRelation = $this->relation->getRelationsParam(); + + $this->response->addHTML($this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ])); if ($formDisplay->hasErrors()) { $formErrors = $formDisplay->displayErrors(); diff --git a/libraries/classes/Controllers/Preferences/ManageController.php b/libraries/classes/Controllers/Preferences/ManageController.php index 9a7ab42f29bf..b872aa7a0e19 100644 --- a/libraries/classes/Controllers/Preferences/ManageController.php +++ b/libraries/classes/Controllers/Preferences/ManageController.php @@ -67,7 +67,7 @@ public function __construct( public function index(): void { global $cf, $error, $filename, $import_handle, $json, $PMA_Config, $lang, $max_upload_size; - global $new_config, $config, $return_url, $form_display, $all_ok, $params, $query; + global $new_config, $config, $return_url, $form_display, $all_ok, $params, $query, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -153,7 +153,13 @@ public function index(): void } if (! $all_ok) { // mimic original form and post json in a hidden field - echo UserPreferencesHeader::getContent($this->template, $this->relation); + $cfgRelation = $this->relation->getRelationsParam(); + + echo $this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ]); echo $this->template->render('preferences/manage/error', [ 'form_errors' => $form_display->displayErrors(), @@ -224,7 +230,14 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - echo UserPreferencesHeader::getContent($this->template, $this->relation); + $cfgRelation = $this->relation->getRelationsParam(); + + echo $this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ]); + if ($error) { if (! $error instanceof Message) { $error = Message::error($error); diff --git a/libraries/classes/Controllers/Preferences/NavigationController.php b/libraries/classes/Controllers/Preferences/NavigationController.php index 829b05980f25..de662daec3b6 100644 --- a/libraries/classes/Controllers/Preferences/NavigationController.php +++ b/libraries/classes/Controllers/Preferences/NavigationController.php @@ -47,7 +47,7 @@ public function __construct( public function index(): void { global $cfg, $cf, $error, $tabHash, $hash; - global $server, $PMA_Config; + global $server, $PMA_Config, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -90,7 +90,13 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - $this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation)); + $cfgRelation = $this->relation->getRelationsParam(); + + $this->response->addHTML($this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ])); if ($formDisplay->hasErrors()) { $formErrors = $formDisplay->displayErrors(); diff --git a/libraries/classes/Controllers/Preferences/SqlController.php b/libraries/classes/Controllers/Preferences/SqlController.php index 03e330602e40..feda63f9aef0 100644 --- a/libraries/classes/Controllers/Preferences/SqlController.php +++ b/libraries/classes/Controllers/Preferences/SqlController.php @@ -47,7 +47,7 @@ public function __construct( public function index(): void { global $cfg, $cf, $error, $tabHash, $hash; - global $server, $PMA_Config; + global $server, $PMA_Config, $route; $cf = new ConfigFile($PMA_Config->base_settings); $this->userPreferences->pageInit($cf); @@ -90,7 +90,13 @@ public function index(): void $scripts = $header->getScripts(); $scripts->addFile('config.js'); - $this->response->addHTML(UserPreferencesHeader::getContent($this->template, $this->relation)); + $cfgRelation = $this->relation->getRelationsParam(); + + $this->response->addHTML($this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ])); if ($formDisplay->hasErrors()) { $formErrors = $formDisplay->displayErrors(); diff --git a/libraries/classes/Controllers/Preferences/TwoFactorController.php b/libraries/classes/Controllers/Preferences/TwoFactorController.php index ee47eea8efeb..5db69bffae84 100644 --- a/libraries/classes/Controllers/Preferences/TwoFactorController.php +++ b/libraries/classes/Controllers/Preferences/TwoFactorController.php @@ -32,9 +32,15 @@ public function __construct($response, $dbi, Template $template, Relation $relat public function index(): void { - global $cfg; + global $cfg, $route; - echo UserPreferencesHeader::getContent($this->template, $this->relation); + $cfgRelation = $this->relation->getRelationsParam(); + + echo $this->template->render('preferences/header', [ + 'route' => $route, + 'is_saved' => ! empty($_GET['saved']), + 'has_config_storage' => $cfgRelation['userconfigwork'], + ]); $twoFactor = new TwoFactor($cfg['Server']['user']); diff --git a/libraries/classes/UserPreferencesHeader.php b/libraries/classes/UserPreferencesHeader.php deleted file mode 100644 index d4595339b48d..000000000000 --- a/libraries/classes/UserPreferencesHeader.php +++ /dev/null @@ -1,165 +0,0 @@ - 'index.php?route=/preferences/manage', - 'text' => __('Manage your settings'), - 'active' => $route === '/preferences/manage', - ] - ) . "\n"; - /* Second authentication factor */ - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/two-factor', - 'text' => __('Two-factor authentication'), - 'active' => $route === '/preferences/two-factor', - ] - ) . "\n"; - - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/features', - 'text' => __('Features'), - 'icon' => 'b_tblops', - 'active' => $route === '/preferences/features', - ] - ) . "\n"; - - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/sql', - 'text' => __('SQL queries'), - 'icon' => 'b_sql', - 'active' => $route === '/preferences/sql', - ] - ) . "\n"; - - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/navigation', - 'text' => __('Navigation panel'), - 'icon' => 'b_select', - 'active' => $route === '/preferences/navigation', - ] - ) . "\n"; - - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/main-panel', - 'text' => __('Main panel'), - 'icon' => 'b_props', - 'active' => $route === '/preferences/main-panel', - ] - ) . "\n"; - - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/export', - 'text' => __('Export'), - 'icon' => 'b_export', - 'active' => $route === '/preferences/export', - ] - ) . "\n"; - - $content .= Generator::getHtmlTab( - [ - 'link' => 'index.php?route=/preferences/import', - 'text' => __('Import'), - 'icon' => 'b_import', - 'active' => $route === '/preferences/import', - ] - ) . "\n"; - - return '