php7 fixes
[Pman.Builder] / Palette.php
1 <?php 
2
3 require_once 'Pman.php';
4 class Pman_Builder_Palette extends Pman 
5 {
6     // generic list we do not care who looks at it..
7     function getAuth()
8     {
9         return true;
10     }
11     
12     function get($sub, $opts = array())
13     {
14         if (empty($sub)) {
15             return $this->roousage();
16         }
17         // list of properties or events.
18         // gets xns+xtype+list
19         $ff = HTML_FlexyFramework::get();
20         
21         $cls = $_REQUEST['xns'] . '.' . $_REQUEST['xtype'];
22         
23         $data = json_decode(file_get_contents($ff->rootDir . '/roojs1/docs/json/roodata.json'));
24         
25         //echo '<PRE>'; print_R($data);
26         
27         $out = $data->data->{ $cls } -> {$_REQUEST['list'] };
28         if ($sub == 'Prop') {
29             foreach(array(
30                 array(
31                     'name' => "builder.sharedname",
32                     'desc'  => "This is a shared part, between different parts (modifying it will change other pages",
33                     'memberOf' => "Builder",
34                     
35                     'type' => "Boolean"
36                 ),
37                 
38                 array(
39                     'name' => "flexy:foreach",
40                     'desc'  => "Loop foreach (array,key,val|array,val)",
41                     'memberOf' => "Flexy",
42                     
43                     'type' => "String"
44                 ),
45                 array(
46                     'name' => "flexy:if",
47                     'desc'  => "if condition - put 0 to always disable it",
48                     'memberOf' => "Flexy",
49                     
50                     'type' => "String"
51                 ),
52                 array(
53                     'name' => "flexy:nameuses",
54                     'desc'  => "nameuses",
55                     'memberOf' => "Flexy",
56                     'type' => "String"
57                 ),
58                 
59             ) as  $add) {
60                 array_push($out,$add);
61             }
62   
63             
64             
65          
66         }
67         $this->jdata($out );
68               
69         // 
70         
71     }
72     function roousage() // list of what elements, can have what as children..
73     {
74         
75         // use file..
76         // this is our hand made file at present.. shared with app.Builders code.
77         
78         $lines = file(dirname(__FILE__).'/RooUsage.txt');
79         $s = -1;
80         $res = array();
81         $left = array();
82         foreach($lines as $l) {
83             
84             $l = preg_replace('#//.*#', '', $l);
85             $l = trim($l);
86             if (!strlen(trim($l))){
87                 continue;
88             }
89             if (preg_match('/left:$/', $l)) {
90                 $s = 0;
91                 $left = array();
92                 continue;
93             }
94             if (preg_match('/right:$/', $l)) {
95                 $s = 1;
96                 continue;
97             }
98             switch($s) {
99                 case 0:
100                     $left[] = $l;
101                     
102                     continue 2;
103                 case 1:
104                     if (!isset($res[$l])) {
105                         $res[$l] = array(); 
106                     }
107                     foreach($left as $ll) {
108                         $res[$l][$ll] = true; 
109                     }
110                     continue 2;
111                 default:
112                     continue 2;
113             }
114              
115         }
116         $ret = array();
117         ksort($res);
118         foreach($res as $k=>$v) {
119             $ret[] = array( 
120                 'name' => $k,
121                 'parents' =>  array_keys($v) 
122             );
123         }
124         
125        // echo '<PRE>';print_r($ret);
126        
127         
128         $this->jdata($ret);
129         //echo '<PRE>';print_R($ret);exit;
130     }
131     
132 }