PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/source/includes/function/xajax_items.php

http://prosporous.googlecode.com/
PHP | 93 lines | 84 code | 3 blank | 6 comment | 4 complexity | be60afa1c9bba5e7df0009c2e8294ce3 MD5 | raw file
 1<?php
 2/**??????UTF-8???.
 3 * Created on 2010-5-17
 4 *
 5 * @author EXT <isrn@qq.com>
 6 *
 7 */
 8require_once '../../includes/global.php';
 9
10function items_config($id,$type,$tree_id)
11{
12	require_once '../../includes/config/items_config.php';
13	foreach($type_array as $arrow=>$data){
14		if($data['value'] == $type&&$data['param']==1){
15			$config=$data['config'];
16		}
17	}
18
19	function item_tpl($js,$width){
20		return "{
21				                columnWidth :".$width.",
22				                baseCls:'x-plain',
23				                layout : 'form',
24				                border:false,
25				                items : [".$js."]
26				            }";
27
28	}
29	foreach($config as $key=>$value){
30		switch($value['type']){
31    		case 'combo':{
32        		$str.=item_tpl('{xtype:"combo",
33        		id:"combo",
34        		layout:"form",
35        		fieldLabel:"'.$value['lable'].'",
36        		width:200,
37        		anchor:"100%",
38        		mode:"local",
39        		displayField:"value",
40        		triggerAction:"all",
41        		readOnly:true,
42        		store:new Ext.data.SimpleStore({
43        			fields:["id","value"]
44        			})
45        		}',0.4);
46        		break;
47    		}
48    		case 'button':{
49        		if($value['fun']!=''){
50        			$handle=',handler:'.$value['fun'];
51        			$fun.=$fun_database[$value['fun']];
52        		}else
53        			$handle='';
54        			$fun.='';
55        			$str.='{baseCls:"x-plain",columnWidth:.1,bodyStyle:"padding-left:20px",items:{"xtype":"button","text":"'.$value['text'].'"'.$handle.'}}';
56        		break;
57    		}
58    		default:{
59        		$str.=item_tpl("{xtype: '".$value['type']."', fieldLabel: '".$value['lable']."'}",$value['width']);
60        		if($key<count($config)-1){
61        			$str.=',';
62        		}
63        		break;
64    		}
65    	}
66	}
67	$objResponse = new xajaxResponse();
68	$core="var formpanel = new Ext.FormPanel({
69				id:'formpanel',
70                autoHeight: true,
71                autoWidth: true,
72                title: false,
73                labelWidth : 80,
74                border:false,
75                layout: 'form',
76                border:false,
77                bodyStyle : 'padding:6px',
78                renderTo: 'activity-".$id."',
79                items :[{
80				        layout : 'column',
81				        border:false,
82				        id:'add_items',
83				        items : [$str]
84				    }]
85              });";
86    $core.=$fun;
87	$objResponse->script($core);
88	return $objResponse;
89}
90$xajax = new xajax();
91$xajax->registerFunction("items_config");
92$xajax->processRequest();
93?>