Changed Bjs.php
[Pman.Core] / Bjs.php
1 <?php
2
3 /**
4  * parse BJS files .... 
5  *
6  * currenly only extracts $this->fields from the list..
7  */
8
9 class Pman_Core_Bjs {
10     
11     var $json;
12     var $fields = array();
13     
14     function __construct($file)
15     {
16         
17         $this->json = json_decode(file_get_contents($file));
18         $this->iterateFields($this->json->items);
19         $this->iterateColumns($this->json->items);
20     }
21     
22     function iterateFields($ar)
23     {
24         foreach($ar as $o) {
25             
26             switch ($o->xtype) {
27                 case "ComboBox":                
28                     $this->fields[] = $o->{'String hiddenName'};
29                     // fall throught..
30                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
31                     
32                     if (!isset($o->{$k})) {
33                         break; // allowed to not exit.
34                     }
35                     $this->fields[] = $o->{$k};
36                     
37                 case "Input":
38                 case "TextArea":
39                 case "CheckBox":
40                 case "DateField":
41                 case "Radio":
42                 case "RadioSet":                    
43                 case "PhoneInput":
44                 case "NumberField":
45                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
46                     
47                     if (!isset($o->{$k})) {
48                         echo "missing string name";
49                         print_r($o);exit;
50                     }
51                     $this->fields[] = $o->{$k};
52                     break;
53                 
54                 case "MoneyField":
55                     $k = isset($o->{'String currencyName'}) ? 'String currencyName' : 'string currencyName';
56                     
57                     $this->fields[] = $o->{$k};
58                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
59                     $this->fields[] = $o->{$k};
60                     break;
61                 default:
62                     if (isset($o->items)) {
63                         $this->iterateFields($o->items);
64                     }
65             }
66              
67         }
68         
69     }
70     
71     
72 }