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         if (empty($sub)) {
15             return $this->roousage();
16         }
17         // list of properties or events.
18         // gets xns+xtype+list
19         
20         // 
21         
22     }
23     function roousage() // list of what elements, can have what as children..
24     {
25         
26         // use file..
27         // get this directly from roo?
28         
29         echo '<PRE>';print_R(HMTL_FlexyFramework::get());exit;
30         $lines = file(dirname(__FILE__).'/RooUsage.txt');
31         $s = -1;
32         $res = array();
33         $left = array();
34         foreach($lines as $l) {
35             
36             $l = preg_replace('#//.*#', '', $l);
37             $l = trim($l);
38             if (!strlen(trim($l))){
39                 continue;
40             }
41             if (preg_match('/left:$/', $l)) {
42                 $s = 0;
43                 $left = array();
44                 continue;
45             }
46             if (preg_match('/right:$/', $l)) {
47                 $s = 1;
48                 continue;
49             }
50             switch($s) {
51                 case 0:
52                     $left[] = $l;
53                     
54                     continue;
55                 case 1:
56                     if (!isset($res[$l])) {
57                         $res[$l] = array(); 
58                     }
59                     foreach($left as $ll) {
60                         $res[$l][$ll] = true; 
61                     }
62                     continue;
63                 default:
64                     continue;
65             }
66             
67             
68         }
69         $ret = array();
70         ksort($res);
71         foreach($res as $k=>$v) {
72             $ret[] = array( 
73                 'name' => $k,
74                 'parents' =>  array_keys($v) 
75             );
76         }
77         $this->jdata($ret);
78         //echo '<PRE>';print_R($ret);exit;
79     }
80     
81 }