diff options
-rw-r--r-- | index.php | 5 | ||||
-rw-r--r-- | libraries/LanguageManager.php | 40 | ||||
-rw-r--r-- | libraries/display_select_lang.lib.php | 78 | ||||
-rw-r--r-- | libraries/plugins/auth/AuthenticationCookie.php | 4 | ||||
-rw-r--r-- | templates/select_lang.phtml | 35 |
5 files changed, 80 insertions, 82 deletions
@@ -10,6 +10,7 @@ use PMA\libraries\URL; use PMA\libraries\Sanitize; use PMA\libraries\Charsets; use PMA\libraries\ThemeManager; +use PMA\libraries\LanguageManager; /** * Gets some core libraries and displays a top message if required @@ -236,9 +237,9 @@ echo ' <ul>'; // Displays language selection combo if (empty($cfg['Lang'])) { echo '<li id="li_select_lang" class="no_bullets">'; - include_once 'libraries/display_select_lang.lib.php'; + echo PMA\libraries\Util::getImage('s_lang.png') , " " - , PMA_getLanguageSelectorHtml(); + , LanguageManager::getInstance()->getSelectorDisplay(); echo '</li>'; } diff --git a/libraries/LanguageManager.php b/libraries/LanguageManager.php index 7249756aff..2e31b00653 100644 --- a/libraries/LanguageManager.php +++ b/libraries/LanguageManager.php @@ -8,6 +8,7 @@ namespace PMA\libraries; use PMA\libraries\Language; +use PMA\libraries\URL; /** * Language selection manager @@ -890,4 +891,43 @@ class LanguageManager ); } } + + + /** + * Returns HTML code for the language selector + * + * @param boolean $use_fieldset whether to use fieldset for selection + * @param boolean $show_doc whether to show documentation links + * + * @return string + * + * @access public + */ + public function getSelectorDisplay($use_fieldset = false, $show_doc = true) + { + $_form_params = array( + 'db' => $GLOBALS['db'], + 'table' => $GLOBALS['table'], + ); + + // For non-English, display "Language" with emphasis because it's + // not a proper word in the current language; we show it to help + // people recognize the dialog + $language_title = __('Language') + . (__('Language') != 'Language' ? ' - <em>Language</em>' : ''); + if ($show_doc) { + $language_title .= Util::showDocu('faq', 'faq7-2'); + } + + $available_languages = $this->sortedLanguages(); + + return Template::get('select_lang')->render( + array( + 'language_title' => $language_title, + 'use_fieldset' => $use_fieldset, + 'available_languages' => $available_languages, + '_form_params' => $_form_params, + ) + ); + } } diff --git a/libraries/display_select_lang.lib.php b/libraries/display_select_lang.lib.php deleted file mode 100644 index 4af6a95ad1..0000000000 --- a/libraries/display_select_lang.lib.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php -/* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Code for displaying language selection - * - * @package PhpMyAdmin - */ -use PMA\libraries\LanguageManager; -use PMA\libraries\URL; - -/** - * Returns HTML code for the language selector - * - * @param boolean $use_fieldset whether to use fieldset for selection - * @param boolean $show_doc whether to show documentation links - * - * @return string - * - * @access public - */ -function PMA_getLanguageSelectorHtml($use_fieldset = false, $show_doc = true) -{ - $retval = ''; - $available_languages = LanguageManager::getInstance()->sortedLanguages(); - - // Display language selection only if there - // is more than one language to choose from - if (count($available_languages) > 1) { - $retval .= '<form method="get" action="index.php" class="disableAjax">'; - - $_form_params = array( - 'db' => $GLOBALS['db'], - 'table' => $GLOBALS['table'], - ); - $retval .= URL::getHiddenInputs($_form_params); - - // For non-English, display "Language" with emphasis because it's - // not a proper word in the current language; we show it to help - // people recognize the dialog - $language_title = __('Language') - . (__('Language') != 'Language' ? ' - <em>Language</em>' : ''); - if ($show_doc) { - $language_title .= PMA\libraries\Util::showDocu('faq', 'faq7-2'); - } - if ($use_fieldset) { - $retval .= '<fieldset><legend lang="en" dir="ltr">' - . $language_title . '</legend>'; - } else { - $retval .= '<bdo lang="en" dir="ltr"><label for="sel-lang">' - . $language_title . ': </label></bdo>'; - } - - $retval .= '<select name="lang" class="autosubmit" lang="en"' - . ' dir="ltr" id="sel-lang">'; - - foreach ($available_languages as $language) { - //Is current one active? - if ($language->isActive()) { - $selected = ' selected="selected"'; - } else { - $selected = ''; - } - $retval .= '<option value="' . strtolower($language->getCode()) . '"' . $selected . '>'; - $retval .= $language->getName(); - $retval .= '</option>'; - } - - $retval .= '</select>'; - - if ($use_fieldset) { - $retval .= '</fieldset>'; - } - - $retval .= '</form>'; - } - return $retval; -} - diff --git a/libraries/plugins/auth/AuthenticationCookie.php b/libraries/plugins/auth/AuthenticationCookie.php index 17a116f22c..7e214a74d2 100644 --- a/libraries/plugins/auth/AuthenticationCookie.php +++ b/libraries/plugins/auth/AuthenticationCookie.php @@ -9,6 +9,7 @@ namespace PMA\libraries\plugins\auth; use phpseclib\Crypt; +use PMA\libraries\LanguageManager; use PMA\libraries\Message; use PMA\libraries\plugins\AuthenticationPlugin; use PMA\libraries\Response; @@ -132,9 +133,8 @@ class AuthenticationCookie extends AuthenticationPlugin echo "<div class='hide js-show'>"; // Displays the languages form if (empty($GLOBALS['cfg']['Lang'])) { - include_once './libraries/display_select_lang.lib.php'; // use fieldset, don't show doc link - echo PMA_getLanguageSelectorHtml(true, false); + echo LanguageManager::getInstance()->getSelectorDisplay(true, false); } echo '</div> <br /> diff --git a/templates/select_lang.phtml b/templates/select_lang.phtml new file mode 100644 index 0000000000..f257429b63 --- /dev/null +++ b/templates/select_lang.phtml @@ -0,0 +1,35 @@ +<?php if (count($available_languages) >= 1) : ?> + <form method="get" action="index.php" class="disableAjax"> + <?= PMA\libraries\URL::getHiddenInputs($_form_params) ?> + + <?php if ($use_fieldset) : ?> + <fieldset> + <legend lang="en" dir="ltr"> <?= $language_title ?> </legend> + <?php else : ?> + <bdo lang="en" dir="ltr"> + <label for="sel-lang"><?= $language_title ?> </label> + </bdo> + <?php endif; ?> + + <select name="lang" class="autosubmit" lang="en" dir="ltr" id="sel-lang"> + + <?php foreach ($available_languages as $language): ?> + <!-- Is current one active ? --> + <option value=<?= '"', strtolower($language->getCode()), '"' ?> + <?php if ($language->isActive()) : ?> + selected="selected"> + <?php endif; ?> + <?= $language->getName(); ?> + </option> + <?php endforeach; ?> + + </select> + + <?php if ($use_fieldset): ?> + </fieldset> + <?php endif; ?> + + </form> +<?php endif; ?> + + |