| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- function testFetchWfs($typeName, $featureId) {
- DBG::log([$typeName, $featureId], 'array', "TODO: testFetchWfs");
- $dom = new DOMDocument();
- $tmp = $dom->createDocumentFragment();
- try {
- $acl = ACL::getAclByTypeName($typeName);
- $pk = substr($featureId, strpos($featureId, '.') + 1);
- $item = $acl->buildQuery([ 'cols' => array_keys($acl->getXsdTypes()) ])->getItem($pk);
- if (!$item) throw new Exception("Object with primary key = '{$pk}' not found");
- DBG::log($item, 'array', "testFetchWfs feature found");
- foreach ($item as $fieldName => $value) {
- if (is_scalar($value)) {
- $tmp->appendXML('<p>' . $fieldName .': "' . $value . '"</p>');
- }
- else if (is_array($value)) {
- $out = '<details open="true"><summary>' . $fieldName .':</summary><div>';
- foreach ($value as $refItem) {
- if (1 === count($refItem) && !empty($refItem['xlink'])) {
- $out .= '<p> - ' . $refItem['xlink'] .':</p>';
- }
- else {
- $out .= '<p>';
- foreach ($refItem as $refField => $refValue) {
- $out .= '- <b>' . $refField . ':</b> ' . $refValue .'<br>';
- }
- $out .= '</p>';
- }
- }
- $out .= '</div></details>';
- $tmp->appendXML($out);
- }
- }
- } catch (Exception $e) {
- $tmp->appendXML('<div class="alert alert-danger">' . $e->getMessage() . '</div>');
- }
- return $tmp; // TODO: require <xsl:copy-of select="php:function(...)/node() - @see https://en.wikibooks.org/wiki/PHP_Programming/XSL/registerPHPFunctions#XSL_receiving_external_fragments
- // return $dom->saveXML($tmp);
- }
|