PageRenderTime 317ms CodeModel.GetById 10ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/source/includes/function/xajax_Form.php

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