5 * Use the Roo data to work out properties..
13 require_once 'Pman.php';
15 class Pman_Builder_PropList extends Pman
20 // parent::getAuth(); // load company!
21 // $au = $this->getAuthUser();
23 // $this->jerr("Not authenticated", array('authFailure' => true));
25 //$this->authUser = $au;
28 function get($base, $opts = array())
30 // should be in the root directory...
32 $opts = HTML_FlexyFramework::get();
34 $this->src = isset($opts->Pman_Builder['roojs1_path']) ?
35 $opts->Pman_Builder['roojs1_path'] .'/docs/json':
36 realpath($opts->rootDir. '/roojs1/docs/json');
38 $this->jerr("roojs1 directory is not in top level folder, or Builder.roojs1_path is not set");
42 if (empty($_REQUEST['xtype'])) {
43 $this->jerr("no xtype");
45 if ($_REQUEST['xtype'] == '*all') {
50 if ($_REQUEST['xtype'] == 'Array') {
51 $this->jdata(array());
54 $view = empty($_REQUEST['view']) ? 'props' : 'events';
58 if ($_REQUEST['xtype'] == '*Module' && $view == 'props') {
59 $this->jdata($this->defModule());
63 // strip non alpha chars == our dummy xtype use '*'
64 $xtype = preg_replace('/[^a-z0-9_.-]+/i', '', $_REQUEST['xtype']);
65 //var_dump($xtype);exit;
67 $guess = array( 'Roo', 'Roo.menu' , 'Roo.form', 'Roo.data', 'Roo.grid', 'Roo.Toolbar');
68 if (!empty($_REQUEST['xns'])) {
69 $guess = array( preg_replace('/[^a-z0-9_.-]+/i', '', $_REQUEST['xns']) );
73 foreach( $guess as $p) {
74 $fp = $this->src . '/'. $p.'.'.$xtype . '.json';
75 if (!file_exists($fp)) {
78 // var_dump(file_get_contents($fp) );
79 // is this needed?? can we just dump it out.. with a bit of kluding?
80 $jd = json_decode( file_get_contents($fp) );
83 foreach($jd->$view as $n=>$inf) {
86 if ($view == 'props') {
87 $ret = array_merge($ret, $this->defProps());
92 if (isset($_REQUEST['dataonly'])) {
93 $this->jerr('Not available');
95 return $this->jdata(array());
99 function defModule() {
101 array( 'name'=>'app', 'type'=>'Object', 'desc'=>'Application (used in perm name) and relates to directory that file is written to..' , 'def'=>'' ),
102 // we could get rid of these... and use the disabled function!!!
103 array( 'name'=>'perm', 'type'=>'String', 'desc'=>'(Optional) Permision name (eg. ListCompanies)' , 'def'=>'' ),
104 array( 'name'=> 'permtype', 'type'=>'String', 'desc'=>'Optional) A,E,S...' , 'def'=>'S' ),
106 array( 'name'=>'disabled', 'type'=>'Number', 'desc'=>'Disable this panel (turn it into a function to run things at module load time)' , 'def'=>'1' ),
107 array( 'name'=>'modkey', 'type'=>'Number', 'desc'=>'Order of item (for tabs)', 'def'=>'' ),
109 array( 'name'=>'module', 'type'=>'Object', 'desc'=>'Module name (eg. Pman.Tab.XXXX or Pman.Dialog.XXXX' , 'def'=>'Pman.Tab.' ),
110 array( 'name'=>'region', 'type'=>'String', 'desc'=>'center|south|east|west|north' , 'def'=>'center' ),
111 array( 'name'=>'parent', 'type'=>'Object', 'desc'=>'Name of Module to add this to.' , 'def'=> 'Pman' ),
112 array( 'name'=>'name', 'type'=>'String', 'desc'=>'Text to display when loading' , 'def'=>'Un-named Part' ),
117 function defProps() {
119 array( 'name'=>'xtype', 'type'=>'String', 'desc'=>'Xtype name of element'),
120 array( 'name'=>'|xns', 'type'=>'Object', 'desc'=>'Namespace for xtype'),
122 array( 'name'=>'style', 'type'=>'String', 'desc'=>'CSS Style'),
123 array( 'name'=>'region', 'type'=>'String', 'desc'=>'Region '), // need for panels..
124 array( 'name'=>'+buildershow', 'type'=>'Boolean', 'desc'=>'Hide from builder'), // need for panels.
125 array( 'name'=>'*prop', 'type'=>'String', 'desc'=>'Change to property'), // need for panels.
130 function jdata($ar, $total = false, $extra = array(), $cachekey = false)
132 if (isset($_REQUEST['dataonly'])) {
139 $defprops = $this->defProps();
141 $ret['*Module'] = array('events' => array(), 'props' => $this->defModule());
143 foreach(scandir($this->src) as $f) {
144 if (empty($f) || $f[0] == '.' || !preg_match('/\.json$/', $f)) {
147 $cls = preg_replace('/\.json$/', '', $f);
148 $fp = $this->src. '/'. $f;
149 $jd = json_decode( file_get_contents($fp) );
150 if (empty($jd->props) && empty($jd->events)) {
153 $jd->props = array_merge($jd->props , $defprops);