Adds I18nHandler::getValues()
authorMatthias Schmidt <gravatronics@live.com>
Sat, 14 Jul 2012 10:58:37 +0000 (12:58 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 14 Jul 2012 10:58:37 +0000 (12:58 +0200)
This method is useful if you want to do something else with the i18n values which are now accessible.

wcfsetup/install/files/lib/system/language/I18nHandler.class.php

index d9a9dcee176beb88d6c75772ab227463b9bd6979..999d35534e42835c27942d79292bd1beff369c8a 100644 (file)
@@ -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<string>
+        */
+       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.
         *