From 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 9 Jan 2020 10:55:03 +0100 Subject: phpmyadmin working --- .../libraries/classes/UserPreferencesHeader.php | 148 +++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 srcs/phpmyadmin/libraries/classes/UserPreferencesHeader.php (limited to 'srcs/phpmyadmin/libraries/classes/UserPreferencesHeader.php') diff --git a/srcs/phpmyadmin/libraries/classes/UserPreferencesHeader.php b/srcs/phpmyadmin/libraries/classes/UserPreferencesHeader.php new file mode 100644 index 0000000..cecbb05 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/UserPreferencesHeader.php @@ -0,0 +1,148 @@ + 'prefs_manage.php', + 'text' => __('Manage your settings'), + ] + ) . "\n"; + /* Second authentication factor */ + $content .= Util::getHtmlTab( + [ + 'link' => 'prefs_twofactor.php', + 'text' => __('Two-factor authentication'), + ] + ) . "\n"; + + $content .= self::displayTabsWithIcon(); + + return $template->render( + 'list/unordered', + [ + 'id' => 'topmenu2', + 'class' => 'user_prefs_tabs', + 'content' => $content, + ] + ) . '
'; + } + + /** + * @return string + */ + protected static function displayTabsWithIcon(): string + { + $form_param = $_GET['form'] ?? null; + $tabs_icons = [ + 'Features' => 'b_tblops', + 'Sql' => 'b_sql', + 'Navi' => 'b_select', + 'Main' => 'b_props', + 'Import' => 'b_import', + 'Export' => 'b_export', + ]; + $script_name = basename($GLOBALS['PMA_PHP_SELF']); + $content = null; + foreach (UserFormList::getAll() as $formset) { + $formset_class = UserFormList::get($formset); + $tab = [ + 'link' => 'prefs_forms.php', + 'text' => $formset_class::getName(), + 'icon' => $tabs_icons[$formset], + 'active' => 'prefs_forms.php' === $script_name && $formset === $form_param, + ]; + $content .= Util::getHtmlTab($tab, ['form' => $formset]) . "\n"; + } + return $content; + } + + /** + * @return string|null + */ + protected static function displayConfigurationSavedMessage(): ?string + { + // show "configuration saved" message and reload navigation panel if needed + if (! empty($_GET['saved'])) { + return Message::rawSuccess(__('Configuration has been saved.')) + ->getDisplay(); + } + + return null; + } + + /** + * @param Relation $relation Relation instance + * + * @return string|null + */ + protected static function sessionStorageWarning(Relation $relation): ?string + { + // warn about using session storage for settings + $cfgRelation = $relation->getRelationsParam(); + if (! $cfgRelation['userconfigwork']) { + $msg = __( + 'Your preferences will be saved for current session only. Storing them ' + . 'permanently requires %sphpMyAdmin configuration storage%s.' + ); + $msg = Sanitize::sanitizeMessage( + sprintf($msg, '[doc@linked-tables]', '[/doc]') + ); + return Message::notice($msg) + ->getDisplay(); + } + + return null; + } +} -- cgit