Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-05-23 01:32:46 +0300
committerGitHub <noreply@github.com>2018-05-23 01:32:46 +0300
commita2c518ee5a3d452973052a627e15bcb3bb812dd3 (patch)
tree51732ffcac6d5c445dfd0f3773d27fbfdb36d522 /lib
parentb40bae816a5515b6420c0d82bf64eb187b2cd894 (diff)
parent760b01e8dbad054919fe766112b52d0b9cfb2d32 (diff)
Merge pull request #8824 from nextcloud/settings-vue
Vue migration: settings
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/L10N/Factory.php81
-rw-r--r--lib/private/NavigationManager.php2
-rw-r--r--lib/private/Settings/Personal/PersonalInfo.php72
5 files changed, 95 insertions, 62 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index ebf5197d4dd..c6475f8c889 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -913,7 +913,6 @@ return array(
'OC\\Settings\\Controller\\ChangePasswordController' => $baseDir . '/settings/Controller/ChangePasswordController.php',
'OC\\Settings\\Controller\\CheckSetupController' => $baseDir . '/settings/Controller/CheckSetupController.php',
'OC\\Settings\\Controller\\CommonSettingsTrait' => $baseDir . '/settings/Controller/CommonSettingsTrait.php',
- 'OC\\Settings\\Controller\\GroupsController' => $baseDir . '/settings/Controller/GroupsController.php',
'OC\\Settings\\Controller\\LogSettingsController' => $baseDir . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => $baseDir . '/settings/Controller/MailSettingsController.php',
'OC\\Settings\\Controller\\PersonalSettingsController' => $baseDir . '/settings/Controller/PersonalSettingsController.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 9a1dfebf52b..f334733a2c9 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -943,7 +943,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Controller\\ChangePasswordController' => __DIR__ . '/../../..' . '/settings/Controller/ChangePasswordController.php',
'OC\\Settings\\Controller\\CheckSetupController' => __DIR__ . '/../../..' . '/settings/Controller/CheckSetupController.php',
'OC\\Settings\\Controller\\CommonSettingsTrait' => __DIR__ . '/../../..' . '/settings/Controller/CommonSettingsTrait.php',
- 'OC\\Settings\\Controller\\GroupsController' => __DIR__ . '/../../..' . '/settings/Controller/GroupsController.php',
'OC\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/MailSettingsController.php',
'OC\\Settings\\Controller\\PersonalSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/PersonalSettingsController.php',
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index a7ffb401b7b..759340a63c3 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -59,6 +59,11 @@ class Factory implements IFactory {
*/
protected $pluralFunctions = [];
+ const COMMON_LANGUAGE_CODES = [
+ 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it',
+ 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko'
+ ];
+
/** @var IConfig */
protected $config;
@@ -137,9 +142,9 @@ class Factory implements IFactory {
*
* @link https://github.com/owncloud/core/issues/21955
*/
- if($this->config->getSystemValue('installed', false)) {
+ if ($this->config->getSystemValue('installed', false)) {
$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
- if(!is_null($userId)) {
+ if (!is_null($userId)) {
$userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
} else {
$userLang = null;
@@ -310,7 +315,7 @@ class Factory implements IFactory {
*/
private function isSubDirectory($sub, $parent) {
// Check whether $sub contains no ".."
- if(strpos($sub, '..') !== false) {
+ if (strpos($sub, '..') !== false) {
return false;
}
@@ -441,4 +446,74 @@ class Factory implements IFactory {
return $function;
}
}
+
+ /**
+ * returns the common language and other languages in an
+ * associative array
+ *
+ * @return array
+ */
+ public function getLanguages() {
+ $forceLanguage = $this->config->getSystemValue('force_language', false);
+ if ($forceLanguage !== false) {
+ return [];
+ }
+
+ $languageCodes = $this->findAvailableLanguages();
+
+ $commonLanguages = [];
+ $languages = [];
+
+ foreach($languageCodes as $lang) {
+ $l = $this->get('lib', $lang);
+ // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
+ $potentialName = (string) $l->t('__language_name__');
+ if ($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file
+ $ln = array(
+ 'code' => $lang,
+ 'name' => $potentialName
+ );
+ } else if ($lang === 'en') {
+ $ln = array(
+ 'code' => $lang,
+ 'name' => 'English (US)'
+ );
+ } else {//fallback to language code
+ $ln = array(
+ 'code' => $lang,
+ 'name' => $lang
+ );
+ }
+
+ // put appropriate languages into appropriate arrays, to print them sorted
+ // common languages -> divider -> other languages
+ if (in_array($lang, self::COMMON_LANGUAGE_CODES)) {
+ $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)] = $ln;
+ } else {
+ $languages[] = $ln;
+ }
+ }
+
+ ksort($commonLanguages);
+
+ // sort now by displayed language not the iso-code
+ usort( $languages, function ($a, $b) {
+ if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
+ // If a doesn't have a name, but b does, list b before a
+ return 1;
+ }
+ if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) {
+ // If a does have a name, but b doesn't, list a before b
+ return -1;
+ }
+ // Otherwise compare the names
+ return strcmp($a['name'], $b['name']);
+ });
+
+ return [
+ // reset indexes
+ 'commonlanguages' => array_values($commonLanguages),
+ 'languages' => $languages
+ ];
+ }
}
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php
index 279c899c5fa..af6613759b3 100644
--- a/lib/private/NavigationManager.php
+++ b/lib/private/NavigationManager.php
@@ -247,7 +247,7 @@ class NavigationManager implements INavigationManager {
'type' => 'settings',
'id' => 'core_users',
'order' => 4,
- 'href' => $this->urlGenerator->linkToRoute('settings_users'),
+ 'href' => $this->urlGenerator->linkToRoute('settings.Users.usersList'),
'name' => $l->t('Users'),
'icon' => $this->urlGenerator->imagePath('settings', 'users.svg'),
]);
diff --git a/lib/private/Settings/Personal/PersonalInfo.php b/lib/private/Settings/Personal/PersonalInfo.php
index 813d06195b5..305e3fb0a4d 100644
--- a/lib/private/Settings/Personal/PersonalInfo.php
+++ b/lib/private/Settings/Personal/PersonalInfo.php
@@ -39,6 +39,7 @@ use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
class PersonalInfo implements ISettings {
+
/** @var IConfig */
private $config;
/** @var IUserManager */
@@ -51,12 +52,6 @@ class PersonalInfo implements ISettings {
private $appManager;
/** @var IFactory */
private $l10nFactory;
-
- const COMMON_LANGUAGE_CODES = [
- 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it',
- 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko'
- ];
-
/** @var IL10N */
private $l;
@@ -198,64 +193,29 @@ class PersonalInfo implements ISettings {
$uid = $user->getUID();
- $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
- $languageCodes = $this->l10nFactory->findAvailableLanguages();
-
- $commonLanguages = [];
- $languages = [];
+ $userConfLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage());
+ $languages = $this->l10nFactory->getLanguages();
- foreach($languageCodes as $lang) {
- $l = \OC::$server->getL10N('lib', $lang);
- // TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
- $potentialName = (string) $l->t('__language_name__');
- if($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file
- $ln = array('code' => $lang, 'name' => $potentialName);
- } elseif ($lang === 'en') {
- $ln = ['code' => $lang, 'name' => 'English (US)'];
- }else{//fallback to language code
- $ln=array('code'=>$lang, 'name'=>$lang);
- }
-
- // put appropriate languages into appropriate arrays, to print them sorted
- // used language -> common languages -> divider -> other languages
- if ($lang === $userLang) {
- $userLang = $ln;
- } elseif (in_array($lang, self::COMMON_LANGUAGE_CODES)) {
- $commonLanguages[array_search($lang, self::COMMON_LANGUAGE_CODES)]=$ln;
- } else {
- $languages[]=$ln;
- }
+ // associate the user language with the proper array
+ $userLangIndex = array_search($userConfLang, array_column($languages['commonlanguages'], 'code'));
+ $userLang = $languages['commonlanguages'][$userLangIndex];
+ // search in the other languages
+ if ($userLangIndex === false) {
+ $userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
+ $userLang = $languages['languages'][$userLangIndex];
}
-
// if user language is not available but set somehow: show the actual code as name
if (!is_array($userLang)) {
$userLang = [
- 'code' => $userLang,
- 'name' => $userLang,
+ 'code' => $userConfLang,
+ 'name' => $userConfLang,
];
}
- ksort($commonLanguages);
-
- // sort now by displayed language not the iso-code
- usort( $languages, function ($a, $b) {
- if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
- // If a doesn't have a name, but b does, list b before a
- return 1;
- }
- if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) {
- // If a does have a name, but b doesn't, list a before b
- return -1;
- }
- // Otherwise compare the names
- return strcmp($a['name'], $b['name']);
- });
-
- return [
- 'activelanguage' => $userLang,
- 'commonlanguages' => $commonLanguages,
- 'languages' => $languages
- ];
+ return array_merge(
+ array('activelanguage' => $userLang),
+ $languages
+ );
}
/**