Pman.Gnumeric.js
[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     }
20     
21     function iterateFields($ar)
22     {
23         foreach($ar as $o) {
24             
25             switch ($o->xtype) {
26                 case "ComboBox":                
27                     $this->fields[] = $o->{'String hiddenName'};
28                     // fall throught..
29                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
30                     
31                     if (!isset($o->{$k})) {
32                         break; // allowed to not exit.
33                     }
34                     $this->fields[] = $o->{$k};
35                     
36                 case "Input":
37                 case "TextArea":
38                 case "CheckBox":
39                 case "DateField":
40                 case "Radio":
41                 case "RadioSet":                    
42                 case "PhoneInput":
43                 case "NumberField":
44                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
45                     
46                     if (!isset($o->{$k})) {
47                         echo "missing string name";
48                         print_r($o);exit;
49                     }
50                     $this->fields[] = $o->{$k};
51                     break;
52                 
53                 case "MoneyField":
54                     $k = isset($o->{'String currencyName'}) ? 'String currencyName' : 'string currencyName';
55                     
56                     $this->fields[] = $o->{$k};
57                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
58                     $this->fields[] = $o->{$k};
59                     break;
60                 default:
61                     if (isset($o->items)) {
62                         $this->iterateFields($o->items);
63                     }
64             }
65              
66         }
67         
68     }
69     
70     
71 }