diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-02 05:31:07 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-02 05:31:07 +0400 |
commit | 2f7d4c55d4c49c12d4d536c60be7280565d9b786 (patch) | |
tree | cb60db72ce3db0ac0af8fa0a10d29ba76f88af7c /plugins/LanguagesManager/LanguagesManager.php | |
parent | 68d120ce1207aad2e492fd08b4e7cd4578ad8a79 (diff) |
refs #4899 move language selector to user settings for logged in users, still visible for anonymous users + during install
Diffstat (limited to 'plugins/LanguagesManager/LanguagesManager.php')
-rw-r--r-- | plugins/LanguagesManager/LanguagesManager.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 449d77987d..3815c1942f 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -38,6 +38,7 @@ class LanguagesManager extends \Piwik\Plugin 'User.getLanguage' => 'getLanguageToLoad', 'UsersManager.deleteUser' => 'deleteUserLanguage', 'Template.topBar' => 'addLanguagesManagerToOtherTopBar', + 'Template.jsGlobalVariables' => 'jsGlobalVariables', 'Console.addCommands' => 'addConsoleCommands' ); } @@ -65,7 +66,9 @@ class LanguagesManager extends \Piwik\Plugin public function showLanguagesSelector() { - MenuTop::addEntry('LanguageSelector', $this->getLanguagesSelector(), true, $order = 30, true); + if (Piwik::isUserIsAnonymous() || !DbHelper::isInstalled()) { + MenuTop::addEntry('LanguageSelector', $this->getLanguagesSelector(), true, $order = 30, true); + } } /** @@ -82,6 +85,17 @@ class LanguagesManager extends \Piwik\Plugin } /** + * Adds the languages drop-down list to topbars other than the main one rendered + * in CoreHome/templates/top_bar.twig. The 'other' topbars are on the Installation + * and CoreUpdater screens. + */ + public function jsGlobalVariables(&$str) + { + // piwik object & scripts aren't loaded in 'other' topbars + $str .= "piwik.languageName = '" . self::getLanguageNameForCurrentUser() . "';"; + } + + /** * Renders and returns the language selector HTML. * * @return string @@ -91,7 +105,6 @@ class LanguagesManager extends \Piwik\Plugin $view = new View("@LanguagesManager/getLanguagesSelector"); $view->languages = API::getInstance()->getAvailableLanguageNames(); $view->currentLanguageCode = self::getLanguageCodeForCurrentUser(); - $view->currentLanguageName = self::getLanguageNameForCurrentUser(); return $view->render(); } |