Add language item support of selection form field options
authorMatthias Schmidt <gravatronics@live.com>
Sat, 13 Jan 2018 16:24:50 +0000 (17:24 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 13 Jan 2018 16:24:50 +0000 (17:24 +0100)
See #2509

wcfsetup/install/files/lib/system/form/builder/field/TSelectionFormField.class.php

index 8538c77c017f9cc979dc7c8a1e8c279a996ba668..b90e1b58283c6e3b584251333e48bca2e29213a6 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\system\form\builder\field;
 use wcf\system\form\builder\field\validation\FormFieldValidationError;
+use wcf\system\WCF;
 
 /**
  * Provides default implementations of `ISelectionFormField` methods.
@@ -58,7 +59,7 @@ trait TSelectionFormField {
                }
                
                // validate options and read possible values
-               $validateOptions = function($array) use (&$validateOptions) {
+               $validateOptions = function(array &$array) use (&$validateOptions) {
                        foreach ($array as $key => $value) {
                                if (is_array($value)) {
                                        $validateOptions($value);
@@ -73,6 +74,11 @@ trait TSelectionFormField {
                                        }
                                        
                                        $this->possibleValues[] = $key;
+                                       
+                                       // fetch language item value
+                                       if (preg_match('~^([a-zA-Z0-9-_]+\.){2,}[a-zA-Z0-9-_]+$~', $value)) {
+                                               $array[$key] = WCF::getLanguage()->getDynamicVariable($value);
+                                       }
                                }
                        }
                };