Pman.Tab.BuilderDatabase.bjs
[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         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                   
53                 
54             ) as  $add) {
55                 array_push($out,$add);
56             }
57   
58             
59             
60          
61         }
62         $this->jdata($out );
63               
64         // 
65         
66     }
67     function roousage() // list of what elements, can have what as children..
68     {
69         
70         // use file..
71         // this is our hand made file at present.. shared with app.Builders code.
72         
73         $lines = file(dirname(__FILE__).'/RooUsage.txt');
74         $s = -1;
75         $res = array();
76         $left = array();
77         foreach($lines as $l) {
78             
79             $l = preg_replace('#//.*#', '', $l);
80             $l = trim($l);
81             if (!strlen(trim($l))){
82                 continue;
83             }
84             if (preg_match('/left:$/', $l)) {
85                 $s = 0;
86                 $left = array();
87                 continue;
88             }
89             if (preg_match('/right:$/', $l)) {
90                 $s = 1;
91                 continue;
92             }
93             switch($s) {
94                 case 0:
95                     $left[] = $l;
96                     
97                     continue;
98                 case 1:
99                     if (!isset($res[$l])) {
100                         $res[$l] = array(); 
101                     }
102                     foreach($left as $ll) {
103                         $res[$l][$ll] = true; 
104                     }
105                     continue;
106                 default:
107                     continue;
108             }
109             
110             
111         }
112         $ret = array();
113         ksort($res);
114         foreach($res as $k=>$v) {
115             $ret[] = array( 
116                 'name' => $k,
117                 'parents' =>  array_keys($v) 
118             );
119         }
120         
121        // echo '<PRE>';print_r($ret);
122        
123         
124         $this->jdata($ret);
125         //echo '<PRE>';print_R($ret);exit;
126     }
127     
128 }