_translations_/Bjs.php
authorAlan Knowles <alan@roojs.com>
Thu, 17 Jan 2019 05:17:47 +0000 (13:17 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 17 Jan 2019 05:17:47 +0000 (13:17 +0800)
_translations_/Bjs.php

index 6d0a72b..e6c38a7 100644 (file)
@@ -8,15 +8,66 @@
 
 class Pman_Core_Bjs {
     
+    var $json;
+    var $fields = array();
     
     static function formFields($file)
     {
-        $a = new Pman_Core_Bjs();
-        $json = json_decode(file_get_contents($file));
+        
+        $this->json = json_decode(file_get_contents($file));
     
-        return $a->iterateFields($json->items,$res);
+        $this->iterateFields($this->json->items);
     }
     
+    function iterateFields($ar, $res)
+    {
+        foreach($ar as $o) {
+            
+            switch ($o->xtype) {
+                case "ComboBox":                
+                    $res[] = $o->{'String hiddenName'};
+                    // fall throught..
+                    $k = isset($o->{'String name'}) ? 'String name' : 'string name';
+                    
+                    if (!isset($o->{$k})) {
+                        break; // allowed to not exit.
+                    }
+                    $res[] = $o->{$k};
+                    
+                case "Input":
+                case "TextArea":
+                case "CheckBox":
+                case "DateField":
+                case "Radio":
+                case "RadioSet":                    
+                case "PhoneInput":
+                case "NumberField":
+                    $k = isset($o->{'String name'}) ? 'String name' : 'string name';
+                    
+                    if (!isset($o->{$k})) {
+                        echo "missing string name";
+                        print_r($o);exit;
+                    }
+                    $res[] = $o->{$k};
+                    break;
+                
+                case "MoneyField":
+                    $k = isset($o->{'String currencyName'}) ? 'String currencyName' : 'string currencyName';
+                    
+                    $res[] = $o->{$k};
+                    $k = isset($o->{'String name'}) ? 'String name' : 'string name';
+                    $res[] = $o->{$k};
+                    break;
+                default:
+                    if (isset($o->items)) {
+                        $res = $this->iterateFields($o->items,$res);
+                    }
+            }
+             
+        }
+        
+        return $res;
+    }
     
     
 }