testFetchWfs.php 875 B

12345678910111213141516171819202122
  1. <?php
  2. function testFetchWfs($typeName, $featureId) {
  3. DBG::log([$typeName, $featureId], 'array', "TODO: testFetchWfs");
  4. $dom = new DOMDocument();
  5. $tmp = $dom->createDocumentFragment();
  6. try {
  7. $acl = ACL::getAclByTypeName($typeName);
  8. $pk = substr($featureId, strpos($featureId, '.') + 1);
  9. $item = $acl->buildQuery([])->getItem($pk);
  10. if (!$item) throw new Exception("Object with primary key = '{$pk}' not found");
  11. foreach ($item as $fieldName => $value) {
  12. $tmp->appendXML('<p>' . $fieldName .': "' . $value . '"</p>');
  13. }
  14. } catch (Exception $e) {
  15. $tmp->appendXML('<div class="alert alert-danger">' . $e->getMessage() . '</div>');
  16. }
  17. 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
  18. // return $dom->saveXML($tmp);
  19. }