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

Bjs.php [new file with mode: 0644]

diff --git a/Bjs.php b/Bjs.php
new file mode 100644 (file)
index 0000000..a69223c
--- /dev/null
+++ b/Bjs.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * parse BJS files .... 
+ *
+ *
+ */
+
+class Pman_Core_Bjs {
+    
+    var $json;
+    var $fields = array();
+    
+    static function formFields($file)
+    {
+        
+        $this->json = json_decode(file_get_contents($file));
+        $this->iterateFields($this->json->items);
+    }
+    
+    function iterateFields($ar)
+    {
+        foreach($ar as $o) {
+            
+            switch ($o->xtype) {
+                case "ComboBox":                
+                    $this->fields[] = $o->{'String hiddenName'};
+                    // fall throught..
+                    $k = isset($o->{'String name'}) ? 'String name' : 'string name';
+                    
+                    if (!isset($o->{$k})) {
+                        break; // allowed to not exit.
+                    }
+                    $this->fields[] = $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;
+                    }
+                    $this->fields[] = $o->{$k};
+                    break;
+                
+                case "MoneyField":
+                    $k = isset($o->{'String currencyName'}) ? 'String currencyName' : 'string currencyName';
+                    
+                    $this->fields[] = $o->{$k};
+                    $k = isset($o->{'String name'}) ? 'String name' : 'string name';
+                    $this->fields[] = $o->{$k};
+                    break;
+                default:
+                    if (isset($o->items)) {
+                        $this->fields = $this->iterateFields($o->items);
+                    }
+            }
+             
+        }
+        
+    }
+    
+    
+}