PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/source/gl/ajax/xajax_Form.php

http://prosporous.googlecode.com/
PHP | 229 lines | 195 code | 6 blank | 28 comment | 14 complexity | 7f82543a73b575b092586a34ce81bd00 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
 10
 11function loadUrl($title,$url,$width,$height,$mask,$id=''){
 12$objResponse = new xajaxResponse();
 13$id=$id==''?'addWindow':$id;
 14$str2="	var addwin =  new Ext.Window({
 15				id :'".$id."',
 16				title :'".$title."',
 17				iconCls:'plugin_edit',
 18				closable:true,
 19				closeAction :'close',
 20				plain:true,
 21				width:".$width.",
 22				height:".$height.",
 23				html:'<iframe scrolling=\"auto\" id=\"adel1828\" name=\"adel1828\" frameborder=\"0\" width=\"100%\" height=\"100%\" src=\"".$url."\"></iframe>'
 24			});
 25	addwin.show();
 26	";
 27$str2=str_replace("\r","",$str2);
 28$str2=str_replace("\n","",$str2);
 29$str2=str_replace("\t","",$str2);
 30	$objResponse->script($str2);
 31	return $objResponse;
 32}
 33
 34/*function loadUrl($title,$url,$width,$height,$mask,$id=''){
 35$objResponse = new xajaxResponse();
 36$id=$id==''?'addWindow':$id;
 37$str2="	var addwin =  new Ext.Window({
 38				id :'".$id."',
 39				title :'".$title."',
 40				iconCls:'plugin_edit',
 41				closable:true,
 42				closeAction :'close',
 43				plain:true,
 44				width:".$width.",
 45				height:".$height.",
 46				autoLoad:{url:'".$url."',nocache:true,scripts:true}
 47			});
 48	addwin.show();
 49	";
 50$str2=str_replace("\r","",$str2);
 51$str2=str_replace("\n","",$str2);
 52$str2=str_replace("\t","",$str2);
 53	$objResponse->script($str2);
 54	return $objResponse;
 55}*/
 56
 57function items_config($tree_id,$field,$add=false){
 58	$objResponse = new xajaxResponse();
 59	$action = $add?'add':'save';
 60	$dbcfg=Sys::Gp(array('dbcfg','sevenel'));
 61	$p_id = "p_id:$tree_id";
 62	if(!$add){
 63			$field_data=Dgd(array(
 64				  'db'=>'d_sevenel',
 65				  'cd'=>"parent_tree = $tree_id and field_name ='$field' and is_shield = 0",
 66				  'tn'=>"fieldmod",
 67				  'limit'=>'1'
 68			));
 69			$config = json_decode($field_data['config'],true);
 70			$c_id = "{$field_data['id']}";
 71			$type = $field_data['type'];
 72	}else{
 73			$c_id = '0';
 74			$type = $field;
 75						$tree=Dgd(array(
 76						  'db'=>'d_sevenel',
 77						  'cd'=>"id = $tree_id",
 78						  'tn'=>"tree",
 79						  'limit'=>'1'
 80						));
 81						$tabname = gettabname($tree['table'],$dbcfg['prefix']);
 82						$field_=Dgd(array(
 83							'db'=>'d_sevenel',
 84							'cd'=>"parent_tree = $tree_id",
 85							'tn'=>"fieldmod",
 86							'column'=>'field_name'
 87						));
 88				 		$fullfields = Dgd(array(
 89						  'db'=>'d_sevenel',
 90						  'sql'=>"SHOW FULL FIELDS FROM ".$tabname
 91						));
 92						$doNotCreate=array('id','del','lg','gid','sortid','cataid');
 93						$existfields = array();
 94						if($field_ !=''){
 95						foreach ($field_ as $key=>$value){
 96								$existfields[] = $value['field_name'];
 97				    		}
 98						}
 99				    	foreach($fullfields as $arrow=>$data){
100								if(!in_array($data['Field'],$existfields)&&!in_array($data['Field'],$doNotCreate)){
101									$store_[]= "['{$data['Field']}']";
102								}
103							}
104						if($store_==''){
105							$str = "Ext.Msg.alert('??','????????!')";
106							$objResponse->script($str);
107							return $objResponse;
108						}
109				    	foreach($store_ as $array=>$f){
110				    		$store .= $f;
111				    		if($array < count($store_)-1){
112								$store .= ',';
113				    		}
114				    	}
115						$heigh = '+100';
116						$items = "{
117						xtype:'combo',
118						id : 'combobox',
119						name : 'field',
120						width:130,
121						fieldLabel:'????',
122						store:new Ext.data.SimpleStore({
123						fields:['value'],
124						data:[$store]
125						}),
126						mode:'local',
127				        displayField:'value',
128				        triggerAction:'all'
129						},
130					";
131						$p_id=$tree_id;
132						$type_="type:'$type',";
133	}
134	require_once '../form/items_config.php';
135	foreach($type_array as $arrow => $value){
136			if($value['name'] == $type){
137				$elment = $value;
138				}
139			}
140	switch($type){
141			case 'checkboxgroup':
142			case 'radiogroup':
143			case 'combo':
144				$str="	var addwin =  new Ext.Window({
145				id :'elment_config',
146				title :'????',
147				iconCls:'add',
148				closable:true,
149				closeAction :'close',
150				plain:true,
151				width:{$elment['width']},
152				height:{$elment['height']},
153				html:'<iframe scrolling=\"auto\"  frameborder=\"0\" width=\"100%\" height=\"100%\" src=\"form/form_config.php?op=form_component&component=$type&c_id=$c_id&p_id=$p_id\"></iframe>'
154			});
155				addwin.show();
156				";
157			break;
158			default:
159			if($elment['config'] != ''){
160				foreach($elment['config'] as $key_ => $value_){
161						$config!=''&&$v="value:'{$config[$value_['name']]}',";
162						if($type == 'password'&&$config[$value_['name']]=='on'){
163							$v = '"checked":true,';
164						}
165						$items.="{xtype:'{$value_['type']}',
166										name:'{$value_['name']}',
167										".$v."
168										fieldLabel:'{$value_['lable']}'}";
169							 			$el_config .= $value_['name'];
170						if($key<count($elment['config'])-1){
171										$items.=',';
172										$el_config.=',';
173								}
174					}
175				}
176					$el_config = ",param:'".$el_config."'";
177					$bbar = ",bbar:['->',{xtype:'button',text:'??',handler:function(){
178							Ext.getCmp('elment_form').form.doAction('submit',{
179									url:'form/form_config.php',
180									method:'POST',
181									params:{require:'items_config_$action','pid':{$p_id},{$type_}id:'$c_id'$el_config},
182									waitMsg:'????....',
183									success:function(form,action){
184											if (action.result.msg=='ok') {
185												Ext.Msg.alert('????','???');
186												addwin.close();
187											} else {
188												Ext.Msg.alert('????',action.result.msg);
189											}
190									 }
191									 ,
192									 failure:function(){
193											Ext.Msg.alert('??','???????');
194									 }
195								});
196						}}]";
197					$str="var addwin =  new Ext.Window({
198							id :'elment_config',
199							title :'????',
200							closable:true,
201							closeAction :'close',
202							width:{$elment['width']},
203							height:{$elment['height']}$heigh,
204							items:[{
205								xtype:'form',
206								id:'elment_form',
207								border:false,
208								frame:true,
209								style:'padding:10px',
210								items:[".$items."]
211
212							}]
213							".$bbar."
214						});
215							addwin.show();
216						";
217					}
218
219	$str=str_replace("\r","",$str);
220	$str=str_replace("\n","",$str);
221	$str=str_replace("\t","",$str);
222	$objResponse->script($str);
223	return $objResponse;
224}
225$xajax = new xajax();
226$xajax->registerFunction("loadUrl");
227$xajax->registerFunction("items_config");
228$xajax->processRequest();
229?>