فهرست منبع

added WfsJsRequestPanel

Piotr Labudda 8 سال پیش
والد
کامیت
49446f432c
1فایلهای تغییر یافته به همراه77 افزوده شده و 0 حذف شده
  1. 77 0
      SE/se-lib/Route/WfsJsRequestPanel.php

+ 77 - 0
SE/se-lib/Route/WfsJsRequestPanel.php

@@ -0,0 +1,77 @@
+<?php
+
+Lib::loadClass('RouteBase');
+Lib::loadClass('P5');
+Lib::loadClass('Core_AclHelper');
+Lib::loadClass('ACL');
+
+class Route_WfsJsRequestPanel extends RouteBase {
+
+	public function defaultAction() {
+		UI::gora();
+		try {
+			$exampleWfsRequestBody = "<wfs:Query>
+					<wfs:PropertyName>ID</wfs:PropertyName>
+					<wfs:PropertyName>PARENT_ID</wfs:PropertyName>
+					<wfs:PropertyName>TYPE</wfs:PropertyName>
+					<wfs:PropertyName>DESC</wfs:PropertyName>
+					<wfs:PropertyName>OPIS</wfs:PropertyName>
+					<wfs:PropertyName>path</wfs:PropertyName>
+					<wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES/*</wfs:PropertyName>
+					<!-- <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_BENEFIT_INFO</wfs:PropertyName> -->
+					<!-- <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_GROUP_1</wfs:PropertyName> -->
+					<!-- <wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_GROUP_2</wfs:PropertyName> -->
+					<wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_INIT/*</wfs:PropertyName>
+					<wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES_INIT/**</wfs:PropertyName>
+					<wfs:PropertyName>default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK/*</wfs:PropertyName>
+					<ogc:Filter>
+						<ogc:Or>
+							<ogc:PropertyIsEqualTo>
+								<ogc:PropertyName>ID</ogc:PropertyName>
+								<ogc:Literal>1003</ogc:Literal>
+							</ogc:PropertyIsEqualTo>
+							<ogc:PropertyIsEqualTo>
+								<ogc:PropertyName>ID</ogc:PropertyName>
+								<ogc:Literal>608</ogc:Literal>
+							</ogc:PropertyIsEqualTo>
+						</ogc:Or>
+					</ogc:Filter>
+				</wfs:Query>";
+			echo '...';
+			UI::startContainer();
+
+			echo UI::h('textarea', [ 'id' => 'wfsRequestBody', 'style' => "width:100%; height:300px" ], htmlspecialchars($exampleWfsRequestBody));
+			echo UI::h('button', [ 'class' => "btn btn-primary", 'onClick' => "return sendWfsRequest(this)" ], "Wyslij");
+			echo UI::h('pre', [ 'id' => 'wfsResponse' ], 'loading...');
+			UI::endContainer();
+			echo UI::h('script', [], "
+				function sendWfsRequest() {
+					document.getElementById('wfsResponse').innerHTML = 'loading...'
+					var postBody = document.getElementById('wfsRequestBody').value.replace(/&lt;/g, '<').replace(/&gt;/g, '>')
+					console.log('wfsRequestBody:', postBody)
+					p5WFS_GetFeature('default_db__x3A__CRM_PROCES:PROCES', {
+						'ogc:Filter': postBody,
+					}).then(function (features) {
+						console.log('features', features)
+						document.getElementById('wfsResponse').innerHTML = JSON.stringify(features, null, 2)
+					}).catch(function (e) {
+						console.warn(e)
+						document.getElementById('wfsResponse').innerHTML = JSON.stringify(e, null, 2)
+						p5UI__notifyAjaxCallback({ type: 'error', msg: e })
+					})
+					return false
+				}
+
+				(function () {
+					console.log('p5WFS_GetFeature(default_db__x3A__CRM_PROCES:PROCES, ...)')
+
+					sendWfsRequest()
+				})()
+			");
+		} catch (Exception $e) {
+			UI::alert('danger', $e);
+		}
+		UI::dol();
+	}
+
+}