_translations_/Bjs.php
[Pman.Core] / _translations_ / Bjs.php
1 <?php
2
3 /**
4  * parse BJS files .... 
5  *
6  *
7  */
8
9 class Pman_Core_Bjs {
10     
11     var $json;
12     var $fields = array();
13     
14     static function formFields($file)
15     {
16         
17         $this->json = json_decode(file_get_contents($file));
18     
19         $this->iterateFields($this->json->items);
20     }
21     
22     function iterateFields($ar, $res)
23     {
24         foreach($ar as $o) {
25             
26             switch ($o->xtype) {
27                 case "ComboBox":                
28                     $res[] = $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                     $res[] = $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                     $res[] = $o->{$k};
52                     break;
53                 
54                 case "MoneyField":
55                     $k = isset($o->{'String currencyName'}) ? 'String currencyName' : 'string currencyName';
56                     
57                     $res[] = $o->{$k};
58                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
59                     $res[] = $o->{$k};
60                     break;
61                 default:
62                     if (isset($o->items)) {
63                         $res = $this->iterateFields($o->items,$res);
64                     }
65             }
66              
67         }
68         
69         return $res;
70     }
71     
72     
73 }