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