From 772bbd99bee83d17707c73a630a4d47c4b8bc807 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 5 Jul 2018 00:41:59 +0200 Subject: Backend work to provide NC whats New info to users Signed-off-by: Arthur Schiwon --- apps/updatenotification/lib/Settings/Admin.php | 33 +++++--------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'apps/updatenotification') diff --git a/apps/updatenotification/lib/Settings/Admin.php b/apps/updatenotification/lib/Settings/Admin.php index b859ca79f62..cae62ee0a9f 100644 --- a/apps/updatenotification/lib/Settings/Admin.php +++ b/apps/updatenotification/lib/Settings/Admin.php @@ -123,39 +123,18 @@ class Admin implements ISettings { return $filtered; } - $isFirstCall = true; + $iterator = $this->l10nFactory->getLanguageIterator(); do { - $lang = $this->l10nFactory->iterateLanguage($isFirstCall); - if($this->findWhatsNewTranslation($lang, $filtered, $changes['whatsNew'])) { - return $filtered; + $lang = $iterator->current(); + if(isset($changes['whatsNew'][$lang])) { + return $filtered['whatsNew'][$lang]; } - $isFirstCall = false; - } while($lang !== 'en'); + $iterator->next(); + } while($lang !== 'en' && $iterator->valid()); return $filtered; } - protected function getLangTrunk(string $lang):string { - $pos = strpos($lang, '_'); - if($pos !== false) { - $lang = substr($lang, 0, $pos); - } - return $lang; - } - - protected function findWhatsNewTranslation(string $lang, array &$result, array $whatsNew): bool { - if(isset($whatsNew[$lang])) { - $result['whatsNew'] = $whatsNew[$lang]; - return true; - } - $trunkedLang = $this->getLangTrunk($lang); - if($trunkedLang !== $lang && isset($whatsNew[$trunkedLang])) { - $result['whatsNew'] = $whatsNew[$trunkedLang]; - return true; - } - return false; - } - /** * @param array $groupIds * @return array -- cgit v1.2.3