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