WfsJsRequestPanel.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('P5');
  4. Lib::loadClass('Core_AclHelper');
  5. Lib::loadClass('ACL');
  6. class Route_WfsJsRequestPanel extends RouteBase {
  7. public function defaultAction() {
  8. UI::gora();
  9. try {
  10. $exampleWfsRequestBody = "<wfs:Query>
  11. <wfs:PropertyName>ID</wfs:PropertyName>
  12. <wfs:PropertyName>PARENT_ID</wfs:PropertyName>
  13. <wfs:PropertyName>TYPE</wfs:PropertyName>
  14. <wfs:PropertyName>DESC</wfs:PropertyName>
  15. <wfs:PropertyName>OPIS</wfs:PropertyName>
  16. <wfs:PropertyName>path</wfs:PropertyName>
  17. <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES</wfs:PropertyName>
  18. <!-- <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_BENEFIT_INFO</wfs:PropertyName> -->
  19. <!-- <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_GROUP_1</wfs:PropertyName> -->
  20. <!-- <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_GROUP_2</wfs:PropertyName> -->
  21. <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_INIT/*</wfs:PropertyName>
  22. <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_INIT/**</wfs:PropertyName>
  23. <wfs:PropertyName>default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK/*</wfs:PropertyName>
  24. <ogc:Filter>
  25. <ogc:Or>
  26. <ogc:PropertyIsEqualTo>
  27. <ogc:PropertyName>ID</ogc:PropertyName>
  28. <ogc:Literal>1003</ogc:Literal>
  29. </ogc:PropertyIsEqualTo>
  30. <ogc:PropertyIsEqualTo>
  31. <ogc:PropertyName>ID</ogc:PropertyName>
  32. <ogc:Literal>608</ogc:Literal>
  33. </ogc:PropertyIsEqualTo>
  34. </ogc:Or>
  35. </ogc:Filter>
  36. </wfs:Query>";
  37. echo '...';
  38. UI::startContainer();
  39. echo UI::h('textarea', [ 'id' => 'wfsRequestBody', 'style' => "width:100%; height:300px" ], htmlspecialchars($exampleWfsRequestBody));
  40. echo UI::h('button', [ 'class' => "btn btn-primary", 'onClick' => "return sendWfsRequest(this)" ], "Wyslij");
  41. echo UI::h('pre', [ 'id' => 'wfsResponse' ], 'loading...');
  42. UI::endContainer();
  43. echo UI::h('script', [], "
  44. function sendWfsRequest() {
  45. document.getElementById('wfsResponse').innerHTML = 'loading...'
  46. var postBody = document.getElementById('wfsRequestBody').value.replace(/&lt;/g, '<').replace(/&gt;/g, '>')
  47. console.log('wfsRequestBody:', postBody)
  48. p5WFS_GetFeature('default_db__x3A__CRM_PROCES:PROCES', {
  49. 'ogc:Filter': postBody,
  50. }).then(function (features) {
  51. console.log('features', features)
  52. document.getElementById('wfsResponse').innerHTML = JSON.stringify(features, null, 2)
  53. }).catch(function (e) {
  54. console.warn(e)
  55. document.getElementById('wfsResponse').innerHTML = JSON.stringify(e, null, 2)
  56. p5UI__notifyAjaxCallback({ type: 'error', msg: e })
  57. })
  58. return false
  59. }
  60. (function () {
  61. console.log('p5WFS_GetFeature(default_db__x3A__CRM_PROCES:PROCES, ...)')
  62. sendWfsRequest()
  63. })()
  64. ");
  65. } catch (Exception $e) {
  66. UI::alert('danger', $e);
  67. }
  68. UI::dol();
  69. }
  70. }