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