fix #8131 - chinese translations
[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     var $cols = array();
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                     if (!isset($o->{'String hiddenName'})) {
29                         continue 2;
30                     }
31                     $this->fields[] = $o->{'String hiddenName'};
32                     // fall throught..
33                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
34                     
35                     if (!isset($o->{$k})) {
36                         break; // allowed to not exit.
37                     }
38                     $this->fields[] = $o->{$k};
39                     
40                 case "Input":
41                 case "TextArea":
42                 case "CheckBox":
43                 case "DateField":
44                 case "Radio":
45                 case "RadioSet":                    
46                 case "PhoneInput":
47                 case "NumberField":
48                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
49                     
50                     if (!isset($o->{$k})) {
51                         echo "missing string name";
52                         print_r($o);exit;
53                     }
54                     $this->fields[] = $o->{$k};
55                     break;
56                 
57                 case "MoneyField":
58                     $k = isset($o->{'String currencyName'}) ? 'String currencyName' : 'string currencyName';
59                     
60                     $this->fields[] = $o->{$k};
61                     $k = isset($o->{'String name'}) ? 'String name' : 'string name';
62                     $this->fields[] = $o->{$k};
63                     break;
64                 default:
65                     if (isset($o->items)) {
66                         $this->iterateFields($o->items);
67                     }
68             }
69              
70         }
71         
72     }
73     function iterateColumns($ar)
74     {
75         foreach($ar as $o) {
76             switch ($o->xtype) {
77                 case "ColumnModel":
78                     $this->cols[] = $o;
79                     break;
80                 default:
81                     if (isset($o->items)) {
82                         $this->iterateColumns($o->items);
83                     }
84             }
85         }
86     }
87      
88     
89 }