", " ", " ", " ID", " 1003", " ", " ", " ID", " 608", " ", " ", " ", ]; $listExampleProp = []; $listExampleProp['lvl1'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " default_db__x3A__CRM_PROCES:PROCES", ]; $listExampleProp['lvl2-by-@-1'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " default_db__x3A__CRM_PROCES:PROCES", ]; $listExampleProp['lvl2-by-@-2'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " default_db__x3A__CRM_PROCES:PROCES", ]; $listExampleProp['lvl2-by-@-3'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " default_db__x3A__CRM_PROCES:PROCES", ]; $listExampleProp['lvl2-by-@-*'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " default_db__x3A__CRM_PROCES:PROCES", ]; $listExampleProp['lvl2'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " default_db__x3A__CRM_PROCES:PROCES/ID", " default_db__x3A__CRM_PROCES:PROCES/PARENT_ID", " default_db__x3A__CRM_PROCES:PROCES/TYPE", " default_db__x3A__CRM_PROCES:PROCES/DESC", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES", ]; $listExampleProp['lvl2wsk'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " OPIS", " path", " default_db__x3A__CRM_PROCES:PROCES/ID", " default_db__x3A__CRM_PROCES:PROCES/PARENT_ID", " default_db__x3A__CRM_PROCES:PROCES/TYPE", " default_db__x3A__CRM_PROCES:PROCES/DESC", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK", " default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK/*", ]; $listExampleProp['lvl3'] = [ " ID", " PARENT_ID", " TYPE", " DESC", " OPIS", " path", " default_db__x3A__CRM_PROCES:PROCES/ID", " default_db__x3A__CRM_PROCES:PROCES/PARENT_ID", " default_db__x3A__CRM_PROCES:PROCES/TYPE", " default_db__x3A__CRM_PROCES:PROCES/DESC", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES/ID", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES/PARENT_ID", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES/TYPE", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES/DESC", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_PROCES:PROCES", " default_db__x3A__CRM_PROCES:PROCES/default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK/*", " default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK/*", ]; $exampleWfsRequestBody = "" . "\n" . implode("\n", array_merge($listExampleProp['lvl1'], $exampleFltr)) . "\n" .""; UI::startContainer(); // Lib::loadClass('Vendor_Monolog'); // $logger = new Vendor_Monolog('dbg-logger-name'); // $logger->pushHandler(new StreamHandler('/tmp/monolog-test.log', Vendor_Monolog::WARNING)); // $logger->warning('Foo'); // $logger->error('Bar'); // // $logFile = '/tmp/monolog-test-json.log'; // $formatter = new JsonFormatter(); // // Create a handler // $stream = new StreamHandler($logFile, Vendor_Monolog::INFO); // $stream->setFormatter($formatter); // // bind it to a logger object // $securityLogger = new Vendor_Monolog('View Info'); // $securityLogger->pushHandler($stream); // $securityLogger->addInfo('debug message / label', [ 'dbg-object' => [ 'x' => 'y', 'z' ] ]); // 'wfsRequestFeatureTypeName' = 'default_db__x3A__CRM_PROCES:PROCES' echo UI::h('input', [ 'id' => 'wfsRequestFeatureTypeName', 'class' => "form-control", 'value' => 'default_db__x3A__CRM_PROCES:PROCES', 'title' => "Feature name" ]); 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('div', [ 'style' => "display:inline", 'id' => "wfs-example-btns" ]); echo UI::h('details', [ 'style' => "padding:6px; background-color:#333; color:#fff", 'open' => "open" ], [ UI::h('summary', [ 'style' => "padding:0 3px; outline:none; cursor:pointer" ], [ "WFS Response converted to JSON ", UI::h('button', [ 'class' => "btn btn-xs btn-default", 'onClick' => "return wfsResponseToggleTreeView(this)" ], "toggle tree view"), ]), UI::h('pre', [ 'id' => 'wfsResponse', 'style' => "margin:0; font-size:x-small; border-radius:0" ], 'loading...'), ]); echo UI::h('details', [ 'style' => "padding:6px; background-color:#68cbfd; color:#fff" ], [ UI::h('summary', [ 'style' => "padding:0 3px; outline:none; cursor:pointer" ], [ UI::h('i',[ 'class' => "glyphicon glyphicon-question-sign" ]), " WFS 1.1, 2.0 fetch nested objects (traverse, resolve)", ]), UI::h('pre', ['style' => "margin:0; font-size:x-small; border-radius:0"], implode("\n", [ "WFS 1.1 - traverseXlinkDepth, traverseXlinkExpiry " . UI::h('a', ['href'=>"http://docs.opengeospatial.org/is/04-094r1/04-094r1.html#50"], "http://docs.opengeospatial.org/is/04-094r1/04-094r1.html#50"), "WFS 2.0 - resolve, resolveDepth, resolveTimeout " . UI::h('a', ['href'=>"http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#57"], "http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#57"), "", "WFS 1.1 traverseXlinkDepth type=\"string\" ('*' or int > 0) - recurse limit ('*' - no limit)", "WFS 1.1 traverseXlinkExpiry type=\"xsd:positiveInteger\" - timeOut in minutes", "WFS 1.1 Note: traverse used in wfs:GetFeature or inside wfs:Query tag wfs:XlinkPropertyName (same like wfs:PropertyName but with @traverse* attributes)", "", "WFS 2.0 resolve type=\"wfs:ResolveValueType\" default=\"none\" (enum: 'local', 'remote', 'all', 'none')", " - resolve=\"local\" - operation shall only resolve local references", " - resolve=\"remote\" - operation shall only resolve remote resource references", " - resolve=\"all\" - means that an operation shall resolve all resource references", " - resolve=\"none\" - means that an operation shall not resolve any resource references", "WFS 2.0 resolveDepth type=\"wfs:positiveIntegerWithStar\" default=\"*\" ('*' or int > 0) - recurse limit ('*' - no limit)", "WFW 2.0 resolveTimeout type=\"xsd:positiveInteger\" default=\"300\" - timeOut in seconds", "WFS 2.0 Note: resolve used in wfs:GetFeature or inside wfs:Query tag wfs:PropertyName", " in wfs:PropertyName may use resolvePath - @see " . UI::h('a', ['href'=>"http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#103"], "http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#103"), "", "WFS 2.0 resolve, resolveDepth example " . UI::h('a', ['href'=>"http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.ogc/ogc-schemas/2.2.0/ogc/wfs/2.0/examples/GetFeature/GetFeature_12.xml"], "http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.ogc/ogc-schemas/2.2.0/ogc/wfs/2.0/examples/GetFeature/GetFeature_12.xml"), ])), ]); UI::endContainer(); $examples['Procesy'] = [ 'typeName' => 'default_db__x3A__CRM_PROCES:PROCES', 'examples' => array_map(function ($props) use ($exampleFltr) { return "" . "\n" . implode("\n", array_merge($props, $exampleFltr)) . "\n" . ""; }, $listExampleProp), ]; $examples['BiAudit'] = [ 'typeName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 'examples' => [ 'BiAudit' => "", 'BiAudit lvl3' => "" . implode("\n\t", [ "A_ADM_COMPANY", "A_CLASSIFIED", "A_STATUS", "A_STATUS_INFO", "BI_analiza_depth", "BI_analiza_reloadCache", "FILE_STATUS", "FILE_STATUS_info", "ID", "L_APPOITMENT_USER", "default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY", "default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI", "default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row", "default_db__x3A__BI_audit_KW_requested_person:BI_audit_KW_requested_person", ]) . "\n" . "", ], ]; echo UI::h('script', [], " var examples = " . json_encode($examples) . "; console.log('examples', examples) function setWfsExample(label, i) { console.log('label', label, 'i', i) document.getElementById('wfsRequestFeatureTypeName').value = examples[label].typeName document.getElementById('wfsRequestBody').value = examples[label].examples[i] sendWfsRequest() } for (var label in examples) { for (var i in examples[label].examples) { jQuery(document.getElementById('wfs-example-btns')).append('') } } "); echo UI::h('script', [], " function sendWfsRequest() { var treeViewNode = document.getElementById('wfsResponseTreeView') if (treeViewNode) treeViewNode.parentNode.removeChild(treeViewNode) document.getElementById('wfsResponse').style.display = 'block' document.getElementById('wfsResponse').innerHTML = 'loading...' var featureTypeName = document.getElementById('wfsRequestFeatureTypeName').value var postBody = document.getElementById('wfsRequestBody').value.replace(/</g, '<').replace(/>/g, '>') console.log('wfsRequestBody:', postBody) var wfsParams = Object.assign({ 'maxFeatures': 3, }, (!postBody) ? {} : { 'ogc:Filter': postBody } ) console.log('p5WFS_GetFeature', featureTypeName, wfsParams) p5WFS_GetFeature(featureTypeName, wfsParams).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() ...') sendWfsRequest() })() "); echo UI::h('script', [], " var DBG = 0; function wfsResponseToggleTreeView(btnNode) { btnNode.isTreeViewActive = ! btnNode.isTreeViewActive if(DBG)console.log('btnNode.isTreeViewActive', btnNode.isTreeViewActive) if (btnNode.isTreeViewActive) { document.getElementById('wfsResponse').style.display = 'none' if (!document.getElementById('wfsResponseTreeView')) { var respTxtNode = document.getElementById('wfsResponse') var treeViewNode = document.createElement('div') treeViewNode.id = 'wfsResponseTreeView' treeViewNode.style.margin = '0' treeViewNode.style.padding = '9.5px' treeViewNode.style.border = '1px solid #ccc' treeViewNode.style.color = '#333' treeViewNode.style.backgroundColor = '#f5f5f5' treeViewNode.style.fontFamily = 'monospace' treeViewNode.style.fontSize = 'x-small' treeViewNode.style.lineHeight = '1.42857143' treeViewNode.style.wordBreak = 'break-all' treeViewNode.style.wordWrap = 'break-word' treeViewNode.innerHTML = parseJsonTextToTreeView(respTxtNode.innerHTML) respTxtNode.parentNode.insertBefore(treeViewNode, respTxtNode.nextSibling); } document.getElementById('wfsResponseTreeView').style.display = 'block' } else { var treeViewNode = document.getElementById('wfsResponseTreeView') if (treeViewNode) treeViewNode.parentNode.removeChild(treeViewNode) document.getElementById('wfsResponse').style.display = 'block' } } function parseJsonTextToTreeView(txtJson) { var out = '' var jsonLines = txtJson.split('\\n').map(function (line) { var whiteSpacePrefix = line.match(/^\s*/)[0].length return [ whiteSpacePrefix, line.substr(whiteSpacePrefix) ] }) if(DBG)console.table(jsonLines) jsonLines = jsonLines.map(function (jsonLine) { if (jsonLine[1].length > 100) jsonLine[1] = jsonLine[1].substr(0, 100) + '...\"' return jsonLine }) return generateTreeView(jsonLines) } function generateTreeView(jsonLines) { if (!jsonLines || !jsonLines.length) return '' out = '' if(DBG)console.log('----------------- group Childrens jsonLines:', jsonLines) groupedChildrens = jsonLines.reduce(function (grouped, cur, idx) { var last = grouped.pop() if (!last) { grouped.push({ deep: cur[0], label: cur[1], childrens: [] }) if(DBG)console.log('groupedChildrens::(!last)', ' cur:[ '+cur[0]+', \"'+cur[1]+'\" ]') } else if (cur[0] > last.deep) { last.childrens.push([ cur[0] - 2, cur[1] ]) grouped.push(last) if(DBG)console.log('groupedChildrens::(deep > cur[0])', ' cur:[ '+cur[0]+', \"'+cur[1]+'\" ]') } else if (cur[0] === last.deep) { var isEndOfObject = ([ ']', '],', '}', '},' ].indexOf(cur[1]) > -1) if (isEndOfObject && !last.childrens.length) last.label += ' ' + cur[1]; grouped.push(last) if (!isEndOfObject) grouped.push({ deep: cur[0], label: cur[1], childrens: [] }) // if (!isEndOfObject) console.log('groupedChildrens::(deep === cur[0] && !isEndOfObject)', ' cur:[ '+cur[0]+', \"'+cur[1]+'\" ]') if(DBG)console.log('groupedChildrens::(deep === cur[0])', ' cur:[ '+cur[0]+', \"'+cur[1]+'\" ]') } return grouped }, []) if(DBG)console.log('groupedChildrens', groupedChildrens) return groupedChildrens.map(function (group) { return (group.childrens.length > 0) ? '
' + group.label + '
' + generateTreeView(group.childrens) + '
' : '
' + group.label + '
' }).join('\\n') } "); } catch (Exception $e) { UI::alert('danger', $e); } UI::dol(); } }