",
" ",
" ",
" ID",
" 1003",
" ",
" ",
" ID",
" 608",
" ",
" ",
" ",
];
$examples = [];
$examples['Procesy'] = [];
$examples['Procesy']['lvl1'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" ID",
" PARENT_ID",
" TYPE",
" DESC",
" default_db__x3A__CRM_PROCES:PROCES",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl2-by-@-1'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" ID",
" PARENT_ID",
" TYPE",
" DESC",
" default_db__x3A__CRM_PROCES:PROCES",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl2-by-@-2'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" ID",
" PARENT_ID",
" TYPE",
" DESC",
" default_db__x3A__CRM_PROCES:PROCES",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl2-by-@-3'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" ID",
" PARENT_ID",
" TYPE",
" DESC",
" default_db__x3A__CRM_PROCES:PROCES",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl2-by-@-*'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" ID",
" PARENT_ID",
" TYPE",
" DESC",
" default_db__x3A__CRM_PROCES:PROCES",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl2'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" 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",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl2wsk'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" 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/*",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['Procesy']['lvl3'] = [
'typeName' => 'default_db__x3A__CRM_PROCES:PROCES',
'postBody' => "" . "\n" . implode("\n", array_merge([
" 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/*",
], $exampleProcesyFltr)) . "\n" ."",
];
$examples['BiAudit'] = [];
$examples['BiAudit']['BiAudit'] = [
'typeName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
'args' => [ 'primaryKey' => 1 ],
];
$examples['BiAudit']['BiAudit lvl2'] = [
'typeName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
'postBody' => "" . implode("\n\t", [
"A_ADM_COMPANY",
"A_CLASSIFIED",
"A_STATUS",
"A_STATUS_INFO",
"BI_analiza_maxDepth",
"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" . "",
];
$examples['BiAudit']['BiAudit lvl3'] = [
'typeName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
'postBody' => "" . implode("\n\t", [
"A_ADM_COMPANY",
"A_CLASSIFIED",
"A_STATUS",
"A_STATUS_INFO",
"BI_analiza_maxDepth",
"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" . "",
];
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' ] ]);
$namespace = V::get('namespace', '', $_GET);
$defaultTypeName = ($namespace)
? Api_WfsNs::typeName($namespace)
: $examples['Procesy']['lvl1']['typeName'];
$defaultNamespace = Api_WfsNs::namespaceFromTypeName($defaultTypeName);
$defaultRequestBody = ($namespace)
? ''
: htmlspecialchars($examples['Procesy']['lvl1']['postBody']);
// 'wfsRequestFeatureTypeName' = 'default_db__x3A__CRM_PROCES:PROCES'
echo UI::h('form', [ 'id' => "wfs_request" ], [
UI::h('div', [ 'style' => "margin-bottom:6px; padding:6px; background-color:#333; color:#fff" ], [
UI::h('table', [ 'style' => "width:100%; margin:0 0 6px 0", 'class' => "table" ], [
UI::h('tr', [], [
UI::h('td', [ 'style' => "width:5%; padding:0 10px 0 0; border:none; line-height:22px; font-size:14px; white-space:nowrap" ], "WFS Request"),
UI::h('td', [ 'style' => "padding:0; border:none" ], [
UI::h('input', [ 'name' => "type_name", 'id' => 'wfsRequestFeatureTypeName', 'class' => "form-control input-xs", 'value' => $defaultTypeName, 'title' => "Feature name" ]),
]),
UI::h('td', [ 'style' => "width:5%; padding:3px 0 0 6px; line-height:16px; border:none" ], [
UI::h('a', [
'id' => "typeNameStorageStructLink",
'href' => "index.php?_route=Storage_AclStruct&namespace={$defaultNamespace}",
'style' => "color:#68cbfd"
], "Struktura")
]),
])
]),
UI::h('div', [], [
UI::h('label', [ 'style' => "font-weight:normal" ], [
" root ",
UI::h('input', [ 'name' => "root", 'type' => "checkbox", 'class' => "", 'value' => '1' ]),
]),
UI::h('label', [ 'style' => "margin-left:8px; font-weight:normal" ], [
" maxFeatures: ",
UI::h('input', [ 'name' => "maxFeatures", 'type' => "number", 'class' => "form-control input-xs", 'style' => "display:inline-block; width:100px", 'value' => '3' ]),
]),
UI::h('label', [ 'style' => "margin-left:8px; font-weight:normal" ], [
" resolveDepth: ",
UI::h('input', [ 'name' => "resolveDepth", 'type' => "number", 'class' => "form-control input-xs", 'style' => "display:inline-block; width:100px", 'value' => '' ]),
]),
UI::h('label', [ 'style' => "margin-left:8px; font-weight:normal" ], [
" primaryKey: ",
UI::h('input', [ 'name' => "primaryKey", 'type' => "text", 'class' => "form-control input-xs", 'style' => "display:inline-block; width:100px", 'value' => '' ]),
]),
]),
UI::h('details', [ 'style' => "padding:0; background-color:#333; color:#fff", 'open' => "open" ], [
UI::h('summary', [ 'style' => "padding:0 3px; margin-bottom:6px; outline:none; cursor:pointer" ], [
UI::h('span', [ 'style' => "margin-right:6px" ], "Request Body"),
UI::h('label', [ 'style' => "margin-right:6px; cursor:pointer; font-weight:normal", 'onclick' => "return onClickBodyType(event, this, 'ogc:Filter')" ], [
UI::h('input', [ 'type' => "radio", 'name' => "wfs_post_body_type", 'value' => "ogc:Filter", 'style' => "margin-right:6px", 'checked' => "checked" ]),
UI::h('span', [ 'style' => "margin-right:6px" ], "ogc:Filter"),
]),
UI::h('label', [ 'style' => "margin-right:6px; cursor:pointer; font-weight:normal", 'onclick' => "return onClickBodyType(event, this, 'graphql:query')" ], [
UI::h('input', [ 'type' => "radio", 'name' => "wfs_post_body_type", 'value' => "graphql:query", 'style' => "margin-right:6px" ]),
UI::h('span', [ 'style' => "margin-right:6px" ], "graphql:query"),
]),
]),
UI::h('textarea', [ 'id' => 'wfsRequestBody', 'style' => "width:100%; height:300px; color:#000" ], $defaultRequestBody),
]),
]),
]);
echo UI::h('div', [ 'style' => "margin-bottom:6px" ], [
UI::h('button', [ 'class' => "btn btn-primary", 'onClick' => "return sendWfsRequest(this)" ], "Wyslij"),
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('form', [ 'id' => "wfs_response_format", 'style' => "display:inline" ], [
UI::h('label', [ 'style' => "margin-right:6px; cursor:pointer; font-weight:normal", 'onclick' => "return onClickResponseFormat(event, this, 'text')" ], [
UI::h('input', [ 'type' => "radio", 'name' => "wfs_post_response_format", 'value' => "text", 'style' => "margin-right:6px", 'checked' => "checked" ]),
UI::h('span', [ 'style' => "margin-right:6px" ], "text"),
]),
UI::h('label', [ 'style' => "margin-right:6px; cursor:pointer; font-weight:normal", 'onclick' => "return onClickResponseFormat(event, this, 'json')" ], [
UI::h('input', [ 'type' => "radio", 'name' => "wfs_post_response_format", 'value' => "json", 'style' => "margin-right:6px" ]),
UI::h('span', [ 'style' => "margin-right:6px" ], "json tree"),
]),
]),
]),
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();
echo UI::h('script', [ 'src' => 'static/postal.min.js' ]);
UI::inlineJS(__FILE__ . '.updateResponseView.js', [
// 'NODE_ID_TREE_VIEW_FROM_TEXT' => "wfsResponseTreeView",
'NODE_ID_TREE_VIEW_FROM_JSON' => "jsonResponseTreeView",
'NODE_ID_WFS_RESPONSE' => "wfsResponse",
'JS_FUNCTION_UPDATE_RESPONSE' => $jsFunction['JS_FUNCTION_UPDATE_RESPONSE'],
'JS_FUNCTION_GET_SELECTED_FORMAT' => $jsFunction['JS_FUNCTION_GET_SELECTED_FORMAT'],
'JS_CHANNEL_UPDATE_NAME' => $jsFunction['JS_CHANNEL_UPDATE_NAME'],
]);
echo UI::h('div', [ 'id' => "ref_graph_node", 'style' => "width:100%; height:300px; border:1px solid silver; margin:10px; padding:0" ]);
echo UI::h('script', [ 'src' => "static/visjs/vis.min.js" ]);
echo UI::h('style', [ 'type' => "text/css", 'src' => "static/visjs/vis.min.css" ]);
// echo UI::h('script', [ 'src' => "static/cytoscape.min.js" ]);
// echo UI::h('script', [ 'src' => "static/cola.min.js" ]);
// echo UI::h('script', [ 'src' => "static/cytoscape-cola.js" ]);
// UI::inlineJS(__FILE__ . '.refGraph-cytoscape-cola.js', [
UI::inlineJS(__FILE__ . '.refGraph.js', [
'FUNCTION_FETCH_CHILDRENS' => 'refGraphFetchChildrens',
'FUNCTION_FETCH_PARENTS' => 'refGraphFetchParents',
'HTML_ID_REF_GRAPH' => 'ref_graph_node',
// 'NODE_ID_TREE_VIEW_FROM_TEXT' => "wfsResponseTreeView",
// 'NODE_ID_TREE_VIEW_FROM_JSON' => "jsonResponseTreeView",
// 'NODE_ID_WFS_RESPONSE' => "wfsResponse",
// 'JS_FUNCTION_UPDATE_RESPONSE' => $jsFunction['JS_FUNCTION_UPDATE_RESPONSE'],
// 'JS_FUNCTION_GET_SELECTED_FORMAT' => $jsFunction['JS_FUNCTION_GET_SELECTED_FORMAT'],
'JS_CHANNEL_UPDATE_NAME' => $jsFunction['JS_CHANNEL_UPDATE_NAME'],
'DBG' => (V::get('DBG', 0, $_GET, 'int') > 0),
]);
echo UI::h('script', [], "
function onClickBodyType(event, n, setBodyType) {
if ('INPUT' === event.target.tagName) {
return true
}
n.form['wfs_post_body_type'].value = setBodyType
return false
}
function onClickResponseFormat(event, n, setFormat) {
if ('INPUT' === event.target.tagName) {
return true
}
n.form['wfs_post_response_format'].value = setFormat
{$jsFunction['JS_FUNCTION_UPDATE_RESPONSE']}()
return false
}
function {$jsFunction['JS_FUNCTION_GET_SELECTED_FORMAT']}() {
return document.getElementById('wfs_response_format')['wfs_post_response_format'].value
}
");
echo UI::h('script', [], "
var examples = " . json_encode($examples) . ";
console.log('examples', examples)
function setWfsExample(groupName, label) {
console.log('groupName', groupName, 'label', label)
var example = examples[groupName][label]
var typeName = example.typeName
document.getElementById('wfsRequestFeatureTypeName').value = typeName
document.getElementById('typeNameStorageStructLink').href = 'index.php?_route=Storage_AclStruct&namespace=' + typeName.replace('__x3A__', '/').replace(':', '/')
document.getElementById('wfsRequestBody').value = example.postBody || ''
var form = document.getElementById('wfs_request')
form['root'].checked = (example.args && 'root' in example.args && 1 == example.args['root'])
form['maxFeatures'].value = (example.args && 'maxFeatures' in example.args && example.args['maxFeatures'] > 0) ? example.args['maxFeatures'] : 3
form['resolveDepth'].value = (example.args && 'resolveDepth' in example.args && example.args['resolveDepth'] > 0) ? example.args['resolveDepth'] : ''
form['primaryKey'].value = (example.args && 'primaryKey' in example.args && example.args['primaryKey'].length > 0) ? example.args['primaryKey'] : ''
sendWfsRequest()
}
for (var groupName in examples) {
for (var label in examples[groupName]) {
jQuery(document.getElementById('wfs-example-btns')).append('')
}
}
");
echo UI::h('script', [], "
function sendWfsRequest() {
{$jsFunction['JS_FUNCTION_UPDATE_RESPONSE']}('loading...')
var postBody = document.getElementById('wfsRequestBody').value.replace(/</g, '<').replace(/>/g, '>')
var form = document.getElementById('wfs_request')
var featureTypeName = form['type_name'].value
var wfsParams = Object.assign({ maxFeatures: 3 },
(form['root'] && form['root'].checked && '1' === form['root'].value) ? { root: 1 } : {},
(postBody && form['wfs_post_body_type'] && 'ogc:Filter' === form['wfs_post_body_type'].value) ? {
'ogc:Filter': document.getElementById('wfsRequestBody').value.replace(/</g, '<').replace(/>/g, '>')
} : {},
(postBody && form['wfs_post_body_type'] && 'graphql:query' === form['wfs_post_body_type'].value) ? {
'graphql:query': document.getElementById('wfsRequestBody').value
} : {},
(form['maxFeatures'] && form['maxFeatures'].value > 0) ? { maxFeatures: parseInt(form['maxFeatures'].value) } : {},
(form['resolveDepth'] && form['resolveDepth'].value > 0) ? {
resolve: 'all',
resolveDepth: ('*' === form['resolveDepth'].value) ? '*' : parseInt(form['resolveDepth'].value)
} : {},
(form['primaryKey'] && form['primaryKey'].value) ? { primaryKey: form['primaryKey'].value } : {}
)
console.log('p5WFS_GetFeature', featureTypeName, wfsParams)
p5WFS_GetFeature(featureTypeName, wfsParams).then(function (features) {
console.log('features', features)
{$jsFunction['JS_FUNCTION_UPDATE_RESPONSE']}(features, featureTypeName)
}).catch(function (e) {
console.warn(e)
{$jsFunction['JS_FUNCTION_UPDATE_RESPONSE']}(''+e)
p5UI__notifyAjaxCallback({ type: 'error', msg: e })
})
return false
}
(function () {
console.log('p5WFS_GetFeature() ...')
sendWfsRequest()
})()
");
} catch (Exception $e) {
UI::alert('danger', $e);
}
UI::dol();
}
}