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