From ce09dbb4544dfa4d92b6a4fa7cdcc0ae1f3f213b Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 14 Jul 2012 12:58:37 +0200 Subject: [PATCH] Adds I18nHandler::getValues() This method is useful if you want to do something else with the i18n values which are now accessible. --- .../lib/system/language/I18nHandler.class.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php index d9a9dcee17..999d35534e 100644 --- a/wcfsetup/install/files/lib/system/language/I18nHandler.class.php +++ b/wcfsetup/install/files/lib/system/language/I18nHandler.class.php @@ -126,7 +126,7 @@ class I18nHandler extends SingletonFactory { } /** - * Returns plain value for given element. + * Returns the plain value for the given element. * * @param string elementID * @return string @@ -136,6 +136,29 @@ class I18nHandler extends SingletonFactory { return $this->plainValues[$elementID]; } + /** + * Returns the values for the given element. If the element is multilingual, + * the multilingual values are returned, otherweise the plain value is + * returned for each language id. + * + * @param string elementID + * @return array + */ + public function getValues($elementID) { + if ($this->hasI18nValues($elementID)) { + return $this->i18nValues[$elementID]; + } + + $plainValue = $this->getValue($elementID); + + $values = array(); + foreach ($this->availableLanguages as $language) { + $values[$language->languageID] = $plainValue; + } + + return $values; + } + /** * Returns false, if element value is not empty. * -- 2.20.1