From b2dd91ebe398b5bcbecad010ef5753a6b6b51835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 13 Feb 2017 11:08:31 +0100 Subject: [PATCH 1/3] Use URL for constructing params instead of concatenation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/db_common.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php index 5f9364d1a3..4d5a92acf9 100644 --- a/libraries/db_common.inc.php +++ b/libraries/db_common.inc.php @@ -55,9 +55,11 @@ if (! isset($is_db) || ! $is_db) { $is_db = false; } // Not a valid db name -> back to the welcome page - $uri = './index.php' - . URL::getCommonRaw(array()) - . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'; + $params = array('reload' => '1'); + if (isset($message)) { + $params['message'] = $message; + } + $uri = './index.php' . URL::getCommonRaw($params); if (strlen($db) === 0 || ! $is_db) { $response = Response::getInstance(); if ($response->isAjax()) { From cdd5f7f6d38c2e723087ac97523cfa7d99b6f7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 13 Feb 2017 11:08:43 +0100 Subject: [PATCH 2/3] Do not append ? at the URL if not needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/URL.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/URL.php b/libraries/URL.php index 14c714e455..8b463ade5f 100644 --- a/libraries/URL.php +++ b/libraries/URL.php @@ -220,7 +220,13 @@ class URL $params['collation_connection'] = $GLOBALS['collation_connection']; } - return $divider . http_build_query($params, null, $separator); + $query = http_build_query($params, null, $separator); + + if ($divider != '?' || strlen($query) > 0) { + return $divider . $query; + } + + return ''; } /** From 924aabf652f35a35ccfe66a6fa706bb434282081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 13 Feb 2017 11:22:43 +0100 Subject: [PATCH 3/3] Do not show language selector without choices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the check from template to the code, so that the selection is completely hidden when there is nothing to select. Fixes #12988 Signed-off-by: Michal Čihař --- ChangeLog | 1 + index.php | 5 +++-- libraries/LanguageManager.php | 10 ++++++++++ libraries/plugins/auth/AuthenticationCookie.php | 10 ++++++---- templates/select_lang.phtml | 4 ---- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27d8311ce7..6f1c660f50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -60,6 +60,7 @@ phpMyAdmin - ChangeLog - issue #12960 Enclose exports in transaction by default - issue #12966 After adding a column ADD INDEX option won't be displayed when enabling AI - issue #12972 Better error message when Composer has not been run +- issue #12988 Do not show language selector without choices 4.6.6 (2017-01-23) - issue #12759 Fix Notice regarding 'Undefined index: old_usergroup' diff --git a/index.php b/index.php index 0ced453dd7..f33a0b44c9 100644 --- a/index.php +++ b/index.php @@ -236,11 +236,12 @@ echo '

' , __('Appearance settings') , '

'; echo '
    '; // Displays language selection combo -if (empty($cfg['Lang'])) { +$language_manager = LanguageManager::getInstance(); +if (empty($cfg['Lang']) && $language_manager->hasChoice()) { echo '
  • '; echo PMA\libraries\Util::getImage('s_lang.png') , " " - , LanguageManager::getInstance()->getSelectorDisplay(); + , $language_manager->getSelectorDisplay(); echo '
  • '; } diff --git a/libraries/LanguageManager.php b/libraries/LanguageManager.php index fc29032021..30aab0d5b4 100644 --- a/libraries/LanguageManager.php +++ b/libraries/LanguageManager.php @@ -714,6 +714,16 @@ class LanguageManager return $this->_available_locales; } + /** + * Checks whether there are some languages available + * + * @return boolean + */ + public function hasChoice() + { + return count($this->availableLanguages()) > 1; + } + /** * Returns (cached) list of all available languages * diff --git a/libraries/plugins/auth/AuthenticationCookie.php b/libraries/plugins/auth/AuthenticationCookie.php index 3d6a3ea777..8a444d6c4a 100644 --- a/libraries/plugins/auth/AuthenticationCookie.php +++ b/libraries/plugins/auth/AuthenticationCookie.php @@ -153,13 +153,15 @@ class AuthenticationCookie extends AuthenticationPlugin )->display(); echo "\n"; - echo "
    "; // Displays the languages form - if (empty($GLOBALS['cfg']['Lang'])) { + $language_manager = LanguageManager::getInstance(); + if (empty($GLOBALS['cfg']['Lang']) && $language_manager->hasChoice()) { + echo "
    "; // use fieldset, don't show doc link - echo LanguageManager::getInstance()->getSelectorDisplay(true, false); + echo $language_manager->getSelectorDisplay(true, false); + echo '
    '; } - echo '
    + echo '
    1) : ?> @@ -31,6 +30,3 @@
    - - -