/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
- <?php
- /**??????UTF-8???.
- * Created on 2010-5-17
- *
- * @author EXT <isrn@qq.com>
- *
- */
- require_once '../../includes/global.php';
-
-
- function loadUrl($title,$url,$width,$height,$mask,$id=''){
- $objResponse = new xajaxResponse();
- $id=$id==''?'addWindow':$id;
- $str2=" var addwin = new Ext.Window({
- id :'".$id."',
- title :'".$title."',
- iconCls:'plugin_edit',
- closable:true,
- closeAction :'close',
- plain:true,
- width:".$width.",
- height:".$height.",
- html:'<iframe scrolling=\"auto\" id=\"adel1828\" name=\"adel1828\" frameborder=\"0\" width=\"100%\" height=\"100%\" src=\"".$url."\"></iframe>'
- });
- addwin.show();
- ";
- $str2=str_replace("\r","",$str2);
- $str2=str_replace("\n","",$str2);
- $str2=str_replace("\t","",$str2);
- $objResponse->script($str2);
- return $objResponse;
- }
-
- /*function loadUrl($title,$url,$width,$height,$mask,$id=''){
- $objResponse = new xajaxResponse();
- $id=$id==''?'addWindow':$id;
- $str2=" var addwin = new Ext.Window({
- id :'".$id."',
- title :'".$title."',
- iconCls:'plugin_edit',
- closable:true,
- closeAction :'close',
- plain:true,
- width:".$width.",
- height:".$height.",
- autoLoad:{url:'".$url."',nocache:true,scripts:true}
- });
- addwin.show();
- ";
- $str2=str_replace("\r","",$str2);
- $str2=str_replace("\n","",$str2);
- $str2=str_replace("\t","",$str2);
- $objResponse->script($str2);
- return $objResponse;
- }*/
-
- function items_config($tree_id,$field,$add=false){
- $objResponse = new xajaxResponse();
- $action = $add?'add':'save';
- $dbcfg=Sys::Gp(array('dbcfg','sevenel'));
- $p_id = "p_id:$tree_id";
- if(!$add){
- $field_data=Dgd(array(
- 'db'=>'d_sevenel',
- 'cd'=>"parent_tree = $tree_id and field_name ='$field' and is_shield = 0",
- 'tn'=>"fieldmod",
- 'limit'=>'1'
- ));
- $config = json_decode($field_data['config'],true);
- $c_id = "{$field_data['id']}";
- $type = $field_data['type'];
- }else{
- $c_id = '0';
- $type = $field;
- $tree=Dgd(array(
- 'db'=>'d_sevenel',
- 'cd'=>"id = $tree_id",
- 'tn'=>"tree",
- 'limit'=>'1'
- ));
- $tabname = gettabname($tree['table'],$dbcfg['prefix']);
- $field_=Dgd(array(
- 'db'=>'d_sevenel',
- 'cd'=>"parent_tree = $tree_id",
- 'tn'=>"fieldmod",
- 'column'=>'field_name'
- ));
- $fullfields = Dgd(array(
- 'db'=>'d_sevenel',
- 'sql'=>"SHOW FULL FIELDS FROM ".$tabname
- ));
- $doNotCreate=array('id','del','lg','gid','sortid','cataid');
- $existfields = array();
- if($field_ !=''){
- foreach ($field_ as $key=>$value){
- $existfields[] = $value['field_name'];
- }
- }
- foreach($fullfields as $arrow=>$data){
- if(!in_array($data['Field'],$existfields)&&!in_array($data['Field'],$doNotCreate)){
- $store_[]= "['{$data['Field']}']";
- }
- }
- if($store_==''){
- $str = "Ext.Msg.alert('??','????????!')";
- $objResponse->script($str);
- return $objResponse;
- }
- foreach($store_ as $array=>$f){
- $store .= $f;
- if($array < count($store_)-1){
- $store .= ',';
- }
- }
- $heigh = '+100';
- $items = "{
- xtype:'combo',
- id : 'combobox',
- name : 'field',
- width:130,
- fieldLabel:'????',
- store:new Ext.data.SimpleStore({
- fields:['value'],
- data:[$store]
- }),
- mode:'local',
- displayField:'value',
- triggerAction:'all'
- },
- ";
- $p_id=$tree_id;
- $type_="type:'$type',";
- }
- require_once '../form/items_config.php';
- foreach($type_array as $arrow => $value){
- if($value['name'] == $type){
- $elment = $value;
- }
- }
- switch($type){
- case 'checkboxgroup':
- case 'radiogroup':
- case 'combo':
- $str=" var addwin = new Ext.Window({
- id :'elment_config',
- title :'????',
- iconCls:'add',
- closable:true,
- closeAction :'close',
- plain:true,
- width:{$elment['width']},
- height:{$elment['height']},
- 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>'
- });
- addwin.show();
- ";
- break;
- default:
- if($elment['config'] != ''){
- foreach($elment['config'] as $key_ => $value_){
- $config!=''&&$v="value:'{$config[$value_['name']]}',";
- if($type == 'password'&&$config[$value_['name']]=='on'){
- $v = '"checked":true,';
- }
- $items.="{xtype:'{$value_['type']}',
- name:'{$value_['name']}',
- ".$v."
- fieldLabel:'{$value_['lable']}'}";
- $el_config .= $value_['name'];
- if($key<count($elment['config'])-1){
- $items.=',';
- $el_config.=',';
- }
- }
- }
- $el_config = ",param:'".$el_config."'";
- $bbar = ",bbar:['->',{xtype:'button',text:'??',handler:function(){
- Ext.getCmp('elment_form').form.doAction('submit',{
- url:'form/form_config.php',
- method:'POST',
- params:{require:'items_config_$action','pid':{$p_id},{$type_}id:'$c_id'$el_config},
- waitMsg:'????....',
- success:function(form,action){
- if (action.result.msg=='ok') {
- Ext.Msg.alert('????','???');
- addwin.close();
- } else {
- Ext.Msg.alert('????',action.result.msg);
- }
- }
- ,
- failure:function(){
- Ext.Msg.alert('??','???????');
- }
- });
- }}]";
- $str="var addwin = new Ext.Window({
- id :'elment_config',
- title :'????',
- closable:true,
- closeAction :'close',
- width:{$elment['width']},
- height:{$elment['height']}$heigh,
- items:[{
- xtype:'form',
- id:'elment_form',
- border:false,
- frame:true,
- style:'padding:10px',
- items:[".$items."]
-
- }]
- ".$bbar."
- });
- addwin.show();
- ";
- }
-
- $str=str_replace("\r","",$str);
- $str=str_replace("\n","",$str);
- $str=str_replace("\t","",$str);
- $objResponse->script($str);
- return $objResponse;
- }
- $xajax = new xajax();
- $xajax->registerFunction("loadUrl");
- $xajax->registerFunction("items_config");
- $xajax->processRequest();
- ?>