| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- <?php
- Lib::loadClass('Api_WfsServerBase');
- Lib::loadClass('Api_WfsException');
- Lib::loadClass('Api_WfsGeomTypeConverter');
- Lib::loadClass('Api_WfsNs');
- Lib::loadClass('Core_XmlWriter');
- Lib::loadClass('DBG');
- Lib::loadClass('Api_Wfs_GetCapabilities');
- class Api_WfsDataServer extends Api_WfsServerBase {
- public function run($request) {
- $document = '';
- if ('WFS' != V::get('SERVICE', '', $request->query) && ('WFS' != V::get('service', '', $request->query))) {
- throw new Api_WfsException("Only WFS Service is allowed");
- }
- $req = V::get('REQUEST', '', $request->query);
- if (!empty($req)) {
- $methodName = "{$req}Action";
- if (!method_exists($this, $methodName)) {
- throw new Api_WfsException("Not Implemented " . htmlspecialchars($req), 501);
- }
- $this->DBG("WfsServer->{$methodName}() ...", __LINE__);
- $document = $this->$methodName($urlQuery);
- }
- else {
- $this->DBG("WfsServer->parseXMLRequest() ...", __LINE__);
- $document = $this->parseXMLRequest();
- header('Content-type: application/xml');
- echo '<?xml version="1.0" encoding="UTF-8"?>';
- echo $document; exit;// TODO: return $document;
- }
- IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$document (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($document);echo'</pre>';}
- if ('raw' == V::get('outputFormat', '', $request->query)) {
- header('Content-type: text/plain; charset=utf-8');
- echo $document;
- } else {
- header('Content-type: application/xml');
- echo $document;
- }
- }
- public function parseXMLRequest() {
- $data = array();
- $reqContent = Request::getRequestBody();
- if (empty($reqContent)) {
- throw new Exception("Empty request");
- }
- $parserXml = xml_parser_create();
- xml_parser_set_option($parserXml, XML_OPTION_CASE_FOLDING, 0);
- xml_parser_set_option($parserXml, XML_OPTION_SKIP_WHITE, 1);
- if (0 == xml_parse_into_struct($parserXml, $reqContent, $tags)) {
- throw new Exception("Error parsing xml");
- }
- xml_parser_free($parserXml);
- if (empty($tags)) {
- throw new Exception("Empty structure from request");
- }
- $rootTagName = V::get('tag', '', $tags[0]);
- if ('Transaction' == $rootTagName) return $this->_parseTransactionXmlStruct($reqContent, $tags);
- throw new Api_WfsException("Not implemented '{$rootTagName}' #L." . __LINE__, 501);
- }
- public function getFeatureAction() {
- $args = $this->parseGetFeatureArgsFromRequest();
- if ('hits' == $args['resultType']) {
- return $this->getTotalFeatures($args, $simple = true);
- } else {
- return $this->getFeatures($args, $simple = true);
- }
- }
- public function getFeatureAdvancedAction() {
- $args = $this->parseGetFeatureArgsFromRequest();
- if ('hits' == $args['resultType']) {
- return $this->getTotalFeatures($args, $simple = false);
- } else {
- if ('/@instance' == strtolower(substr($args['typeName'], -1 * strlen('/@instance')))) {
- return $this->getInstanceFeatures(substr($args['typeName'], 0, -1 * strlen('/@instance')), $args);
- }
- return $this->getFeatures($args, $simple = false);
- }
- }
- public function testOgcFilterAction() {
- $type = V::get('TYPENAME', '', $_REQUEST);
- $typeEx = explode(':', $type);
- $maxFeatures = V::get('MAXFEATURES', '10000', $_REQUEST, 'int');// TODO: Set Deafult Limit
- $ogcFilter = V::get('Filter', '', $_REQUEST);
- $srsname = V::get('SRSNAME', '', $_REQUEST);// eg. EPSG:4326
- if (count($typeEx) == 2) {
- Lib::loadClass('ParseOgcFilter');
- $parser = new ParseOgcFilter();
- $parser->loadOgcFilter($ogcFilter);
- $queryWhereBuilder = $parser->convertToSqlQueryWhereBuilder();
- echo $queryWhereBuilder->getQueryWhere('t');
- } else {
- throw new HttpException("Wrong param TYPENAME", 400);
- }
- }
- public function getTotalFeatures($args, $simple = true) {
- DBG::log("typeName({$args['xsd:type']})");
- $acl = $this->getAclFromTypeName($args['xsd:type']);
- DBG::log([ 'msg'=>"typeName({$args['xsd:type']}) - acl(".get_class($acl).")", '$acl'=>$acl ]);
- $fldList = $this->_getFieldListFromAcl($acl);
- $baseNsUri = Api_WfsNs::getBaseWfsUri();
- $rootWfsNs = 'p5';
- $rootWfsNsUri = "{$baseNsUri}";
- $wfsNs = $args['typePrefix'];
- $wfsNsUri = "{$baseNsUri}/" . ('p5_' == substr($args['typePrefix'], 0, 3)) ? substr($args['typePrefix'], 3) : $args['typePrefix'];
- $featureTypeUri = $this->getBaseUri() . "?SERVICE=WFS&VERSION=1.0.0&TYPENAME={$args['xsd:type']}&REQUEST=DescribeFeatureType";
- // get BBox from geom_field (only one geom fld is allowed)
- $geomFld = null;
- {
- foreach ($fldList as $fldName) {
- if ($acl->isGeomField($fldName)) {
- $geomFld = $fldName;
- }
- }
- }
- DBG::log("ogcFilter(" . strlen($args['ogc:filter']) . "): {$args['ogc:filter']}");
- $searchParams = array();
- $searchParams['limit'] = $args['limit'];
- $searchParams['limitstart'] = $args['offset'];
- if (!empty($args['sortBy'])) {
- $searchParams['sortBy'] = $args['sortBy'];
- } else {
- $searchParams['order_by'] = $acl->getPrimaryKeyField();
- $searchParams['order_dir'] = 'DESC';
- }
- if (strlen($args['ogc:filter']) > 0) $searchParams['ogc:Filter'] = $args['ogc:filter'];
- if (!empty($args['filterFields'])) $searchParams['cols'] = $args['filterFields'];// propertyName
- if (!empty($args['primaryKey'])) $searchParams['primaryKey'] = $args['primaryKey'];// featureID
- if (!empty($args['bbox'])) $searchParams['f_the_geom'] = "BBOX:{$args['bbox']}";
- $queryFeatures = $acl->buildQuery($searchParams);
- $totalItems = $queryFeatures->getTotal();
- $xmlWriter = new XMLWriter();
- if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
- $xmlWriter->openUri('php://output');
- $xmlWriter->setIndent(true);
- $xmlWriter->startDocument('1.0','UTF-8');
- $xmlWriter->startElement('wfs:FeatureCollection');
- $xmlWriter->writeAttribute('xmlns:wfs', 'http://www.opengis.net/wfs/2.0');
- $xmlWriter->writeAttribute('xmlns', 'http://www.opengis.net/wfs/2.0');
- $xmlWriter->writeAttribute('xmlns:gml', 'http://www.opengis.net/gml');
- $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
- // $xmlWriter->writeAttribute('xsi:schemaLocation', "{$wfsNsUri} {$featureTypeUri}");
- $xmlWriter->writeAttribute('numberMatched', $totalItems);
- $xmlWriter->writeAttribute('numberReturned', 0);
- // $xmlWriter->writeAttribute('timeStamp', "TODO: timestamp like '2011-12-09T11:30:16'");
- $xmlWriter->endElement();// wfs:FeatureCollection
- $xmlWriter->endDocument();
- exit;
- }
- public function getFeatures($args, $simple = true) {
- $type = $args['typeName'];
- DBG::log("typeName({$args['xsd:type']})");
- $acl = $this->getAclFromTypeName($args['xsd:type']);
- DBG::log([ 'msg'=>"typeName({$args['xsd:type']}) - acl(".get_class($acl).")", '$acl'=>$acl ]);
- $fldList = $this->_getFieldListFromAcl($acl);
- $baseNsUri = Api_WfsNs::getBaseWfsUri();
- $rootWfsNs = 'p5';
- $rootWfsNsUri = "{$baseNsUri}";
- $wfsNs = $args['typePrefix'];
- $wfsNsUri = "{$baseNsUri}/" . ('p5_' === substr($args['typePrefix'], 0, 3) ? substr($args['typePrefix'], 3) : $args['typePrefix']);
- $featureTypeUri = $this->getBaseUri() . "?SERVICE=WFS&VERSION=1.0.0&TYPENAME={$args['xsd:type']}&REQUEST=DescribeFeatureType";
- // get BBox from geom_field (only one geom fld is allowed)
- $geomFld = null;
- {
- foreach ($fldList as $fldName) {
- if ($acl->isGeomField($fldName)) {
- $geomFld = $fldName;
- }
- }
- }
- DBG::log("ogcFilter(" . strlen($args['ogc:filter']) . "): {$args['ogc:filter']}");
- $searchParams = array();
- $searchParams['limit'] = $args['limit'];
- $searchParams['limitstart'] = $args['offset'];
- if (!empty($args['sortBy'])) {
- $searchParams['sortBy'] = $args['sortBy'];
- } else {
- $searchParams['order_by'] = $acl->getPrimaryKeyField();
- $searchParams['order_dir'] = 'DESC';
- }
- if (strlen($args['ogc:filter']) > 0) $searchParams['ogc:Filter'] = $args['ogc:filter'];
- if (!empty($args['filterFields'])) $searchParams['cols'] = $args['filterFields'];// PropertyName
- if (!empty($args['primaryKey'])) $searchParams['primaryKey'] = $args['primaryKey'];// featureID
- if (!empty($args['bbox'])) $searchParams['f_the_geom'] = "BBOX:{$args['bbox']}";
- $contextFieldList = []; // convert $args['filterFields'] to field list
- $schemaCache = array();
- try {
- $acl__getAllFieldNames = function ($listFields) {
- return array_map(function ($field) {
- return $field['fieldNamespace'];
- }, $listFields);
- };
- $acl__getLocalFieldNames = function ($listFields) {
- return array_map(function ($field) {
- return $field['fieldNamespace'];
- }, array_filter($listFields, function ($field) {
- return $field['isLocal'];
- }));
- };
- DBG::log($acl->getFields(), 'array', "\$contextFieldList ACL fields");
- if (empty($args['filterFields'])) { // get all local fields
- // $contextFieldList = $acl__getLocalFieldNames($acl->getFields());
- $contextFieldList = $acl__getAllFieldNames($acl->getFields());
- } else {
- foreach ($args['filterFields'] as $fieldXPath) {
- if ('*' === $fieldXPath) {
- $contextFieldList = array_merge($contextFieldList, $acl__getLocalFieldNames($acl->getFields()));
- } else if (false === strpos($fieldXPath, '/') && false === strpos($fieldXPath, ':')) {
- $contextFieldList[] = $fieldXPath;
- } else if (false === strpos($fieldXPath, '/') && false !== strpos($fieldXPath, ':')) {
- $contextFieldList[] = $fieldXPath;
- $fieldNs = str_replace(['__x3A__', ':'], '/', $fieldXPath);
- $schemaCache[$fieldNs] = SchemaFactory::loadDefaultObject('SystemObject')->getItem($fieldNs, [ 'propertyName' => '*,field' ]);
- DBG::log($schemaCache[$fieldNs], 'array', "\$schemaCache[{$fieldNs}]");
- } else if ('/*' === substr($fieldXPath, -2) && false === strpos(substr($fieldXPath, 0, -2), '/')) {
- $fieldName = substr($fieldXPath, 0, -2);
- $contextFieldList[] = $fieldName;
- $xsdType = $acl->getXsdFieldType($fieldName);
- if ('ref:' !== substr($xsdType, 0, 4)) throw new Exception("Error Processing Request - field '{$fieldXPath}' type is not ref '/*' is not allowed");
- $fieldNs = str_replace(['__x3A__', ':'], '/', substr($xsdType, 4));
- if (!array_key_exists($fieldNs, $schemaCache)) {
- $schemaCache[$fieldNs] = SchemaFactory::loadDefaultObject('SystemObject')->getItem($fieldNs, [ 'propertyName' => '*,field' ]);
- DBG::log($schemaCache[$fieldNs], 'array', "\$schemaCache[{$fieldNs}]");
- }
- $fieldPrefix = "{$fieldName}";
- $contextFieldList = array_merge($contextFieldList, array_map(function ($fieldName) use ($fieldPrefix) {
- return "{$fieldPrefix}/{$fieldName}";
- }, $acl__getLocalFieldNames($schemaCache[$fieldNs]['field'])));
- } else {
- $fieldName = trim($fieldXPath, '*/');
- DBG::log(['$fieldXPath'=>$fieldXPath, '$fieldName'=>$fieldName], 'array', "\$contextFieldList TODO");
- }
- }
- }
- DBG::log($contextFieldList, 'array', "\$contextFieldList");
- $searchParams['cols'] = $contextFieldList;
- } catch (Exception $e) {
- DBG::log($e);
- throw $e;
- }
- DBG::log([ 'msg'=>'getItems - $searchParams', '$searchParams'=>$searchParams ]);
- if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">get_total (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($jsonData->total);echo'</pre>';}
- $queryFeatures = $acl->buildQuery($searchParams);
- $items = $queryFeatures->getItems();
- DBG::log([ 'msg'=>'getItems - $items', '$items'=>$items ]);
- header('Content-type: application/xml; charset=utf-8');
- $xmlWriter = new Core_XmlWriter();
- $xmlWriter->openUri('php://output');
- // $xmlWriter->openMemory();// DBG
- $xmlWriter->setIndent(true);
- if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
- $xmlWriter->startDocument('1.0','UTF-8');
- //$xmlWriter->startElementNS('wfs', 'FeatureCollection', 'http://www.opengis.net/wfs');
- $xmlWriter->startElement('wfs:FeatureCollection');
- // $xmlWriter->writeAttributeNS('xmlns', 'wfs', 'http://www.w3.org/2000/xmlns/', 'http://www.opengis.net/wfs');
- $xmlWriter->writeAttribute('xmlns:wfs', 'http://www.opengis.net/wfs');
- $xmlWriter->writeAttribute('xmlns', 'http://www.opengis.net/wfs');
- $xmlWriter->writeAttribute('xmlns:gml', 'http://www.opengis.net/gml');
- $xmlWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
- $xmlWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
- $xmlWriter->writeAttribute("xmlns:{$wfsNs}", $wfsNsUri); // TODO: BUG $wfsNsUri
- if (!$simple) $xmlWriter->writeAttribute("xmlns:{$rootWfsNs}", $rootWfsNsUri);
- foreach ($schemaCache as $childSchema) {
- $xmlWriter->writeAttribute("xmlns:{$childSchema['nsPrefix']}", "{$rootWfsNsUri}/" . str_replace('__x3A__', '/', $childSchema['nsPrefix']));
- }
- $xmlWriter->writeAttribute('xsi:schemaLocation', "{$wfsNsUri} {$featureTypeUri}"); // TODO: BUG $wfsNsUri
- $xmlWriter->writeAttribute('numberMatched', 'unknown'); // TODO: return total items if simple query (without prefix, small total number, maxFeatures set, etc.)
- // NOTE: for client: if numberMatched == 'unknown' then request with resultType = 'hits'
- $xmlWriter->writeAttribute('numberReturned', count($items));
- $tblName = $acl->getName();
- $primaryKeyField = $acl->getPrimaryKeyField();
- foreach ($items as $item) {
- $itemKey = V::get($primaryKeyField, '', $item);
- if (!is_array($item)) $item = (array)$item;
- if (!empty($geomFld)) DBG::log(['msg'=>"item[{$itemKey}] ({$geomFld})isEmpty(".empty($item[$geomFld])."):", '$item['.$geomFld.']'=>$item[$geomFld]]);
- DBG::log([ 'msg'=>">>> loop({$itemKey})", '$item'=>$item ]);
- $xmlWriter->startElement('gml:featureMember');
- $xmlWriter->startElement("{$wfsNs}:{$type}");
- $xmlWriter->writeAttribute('fid', "{$type}.{$itemKey}");
- if (!$simple) $xmlWriter->writeAttribute("{$rootWfsNs}:web_link", Request::getPathUri() . "index.php?_route=ViewTableAjax&namespace=" . $acl->getNamespace() . "#EDIT/{$itemKey}");
- foreach ($fldList as $idZasob => $fldName) {
- if(V::get('DBG_LOOP','',$_GET))DBG::log([ 'msg'=>">>> loop({$itemKey}) item({$item['ID']}) fld({$fldName})", '$item'=>$item[$fldName] ]);
- $fldType = $acl->getXsdFieldType($fldName);
- if (!$acl->canReadObjectField($fldName, (object)$item)) continue;
- if ($geomFld != null && $fldName == $geomFld) {
- $xmlWriter->startElement("{$wfsNs}:{$fldName}");
- if (!$simple && !$acl->canReadObjectField($fldName, (object)$item)) {
- $xmlWriter->writeAttribute("{$rootWfsNs}:allow_read", "false");
- }
- if (!$simple && $acl->canWriteObjectField($fldName, (object)$item)) {
- $xmlWriter->writeAttribute("{$rootWfsNs}:allow_write", "true");
- }
- $this->_typeConverter->createGmlFromWkt_xmlWriter($item[$fldName], $xmlWriter);
- $xmlWriter->endElement();// {$wfsNs}:{$fldName}
- } else if (is_array($item[$fldName])) {// TODO: by struct - REF field
- DBG::log([ 'msg'=>">>> loop({$itemKey}) REF item[{$itemKey}][{$fldName}]", '$item'=>$item[$fldName] ]);
- if (empty($item[$fldName])) {
- $xmlWriter->h($fldName);
- // } else if (1 == count($item[$fldName]) && !empty($item[$fldName][0]['xlink'])) {
- // $xlink = $item[$fldName][0]['xlink'];
- // $xlinkParts = explode(':', $xlink);
- // if (2 != count($xlinkParts)) throw new Exception("Error Processing Request - wrong xlink format for ".$acl->getName().".{$itemKey}/{$fldName}");
- // $xlinkParts[0] = Api_WfsNs::getNsUri($xlinkParts[0]);
- // $xlink = implode('#', $xlinkParts);
- // $xmlWriter->startElement("{$wfsNs}:{$fldName}");
- // if (!$simple && !$acl->canReadObjectField($fldName, (object)$item)) {
- // $xmlWriter->writeAttribute("{$rootWfsNs}:allow_read", "false");
- // }
- // if (!$simple && $acl->canWriteObjectField($fldName, (object)$item)) {
- // $xmlWriter->writeAttribute("{$rootWfsNs}:allow_write", "true");
- // }
- // $xmlWriter->writeAttribute('xlink:href', $xlink);
- // $xmlWriter->endElement();// {$wfsNs}:{$fldName}
- } else {
- // $xmlWriter->writeComment("TODO: ".$acl->getName().".{$itemKey}/{$fldName} ...");
- $fieldNs = str_replace(['__x3A__', ':'], '/', $fldName); // substr($xsdType, 4));
- if (!array_key_exists($fieldNs, $schemaCache)) {
- $xmlWriter->writeComment("Error Processing Request - field is not ref ".$acl->getName().".{$itemKey}/{$fldName}");
- } else {
- foreach ($item[$fldName] as $refItem) {
- DBG::log($refItem, 'array', "\$refItem fld({$fldName})");
- if (1 == count($refItem) && !empty($refItem['xlink'])) {
- $xmlWriter->startElement($schemaCache[$fieldNs]['typeName']);
- $xmlWriter->writeAttribute("xlink:href", $refItem['xlink']);
- $xmlWriter->endElement();
- } else {
- $xmlWriter->startElement($schemaCache[$fieldNs]['typeName']);
- foreach ($schemaCache[$fieldNs]['field'] as $field) {
- // $xmlWriter->writeComment("REF field ({$field['fieldNamespace']}) value({$refItem[$field['fieldNamespace']]})");
- if (array_key_exists($field['fieldNamespace'], $refItem)) {
- $xmlWriter->startElement("{$schemaCache[$fieldNs]['nsPrefix']}:{$field['fieldNamespace']}");
- $xmlWriter->text($refItem[$field['fieldNamespace']]);
- $xmlWriter->endElement();
- }
- }
- $xmlWriter->endElement();
- }
- }
- }
- }
- } else if ('xsd:base64Binary' === $acl->getXsdFieldType($fldName)) {
- if (empty($item[$fldName]) && '0' !== $item[$fldName]) continue;
- $xmlWriter->startElement("{$wfsNs}:{$fldName}");
- if (!$simple && !$acl->canReadObjectField($fldName, (object)$item)) {
- $xmlWriter->writeAttribute("{$rootWfsNs}:allow_read", "false");
- }
- if (!$simple && $acl->canWriteObjectField($fldName, (object)$item)) {
- $xmlWriter->writeAttribute("{$rootWfsNs}:allow_write", "true");
- }
- $xmlWriter->text(base64_encode($item[$fldName]));
- $xmlWriter->endElement();// {$wfsNs}:{$fldName}
- } else {
- $value = str_replace('&', '&', $item[$fldName]);
- if (empty($value) && '0' !== $value) {
- continue;
- } else {
- $xmlWriter->startElement("{$wfsNs}:{$fldName}");
- if (!$simple && !$acl->canReadObjectField($fldName, (object)$item)) {
- $xmlWriter->writeAttribute("{$rootWfsNs}:allow_read", "false");
- }
- if (!$simple && $acl->canWriteObjectField($fldName, (object)$item)) {
- $xmlWriter->writeAttribute("{$rootWfsNs}:allow_write", "true");
- }
- $xmlWriter->text($value);
- $xmlWriter->endElement();// {$wfsNs}:{$fldName}
- }
- }
- }
- $xmlWriter->endElement();// {$wfsNs}:{$type}
- $xmlWriter->endElement();// gml:featureMember
- }
- $xmlWriter->endElement();// wfs:FeatureCollection
- $xmlWriter->endDocument();
- exit;
- }
- public function describeFeatureTypeAction() {
- $type = V::get('TYPENAME', '', $_REQUEST);
- if (empty($type)) {
- $reqContent = Request::getRequestBody();
- if (!empty($reqContent)) {
- return $this->_parseDescribeFeatureTypeRequest($reqContent);
- } else {
- return $this->_getDescribeFeatureAllTypes();
- }
- //throw new HttpException("Wrong param TYPENAME", 400);
- }
- $typeEx = explode(':', $type);
- if (count($typeEx) != 2) throw new HttpException("Wrong param TYPENAME", 400);
- return $this->_getDescribeFeatureType($typeEx[0], $typeEx[1]);
- }
- public function describeFeatureTypeAdvancedAction() {
- $typeName = V::geti('TYPENAME', '', $_REQUEST);
- if (empty($typeName)) {
- $reqContent = Request::getRequestBody();
- if (!empty($reqContent)) {
- return $this->_parseDescribeFeatureTypeRequest($reqContent, $simple = false);
- } else {
- return $this->_getDescribeFeatureAllTypes($simple = false);
- }
- //throw new HttpException("Wrong param TYPENAME", 400);
- }
- if (false === strpos($typeName, ':')) throw new HttpException("Wrong param TYPENAME", 400);
- list($nsPrefix, $name) = explode(':', $typeName);
- if ('/@instance' == strtolower(substr($name, -1 * strlen('/@instance')))) {
- return $this->_describeInstanceAttributeTable($nsPrefix, substr($name, 0, -1 * strlen('/@instance')));
- }
- return $this->_getDescribeFeatureType($nsPrefix, $name, $simple = false);
- }
- public function getCapabilitiesAction() {
- $wfsServerUrl = $this->getBaseUri();
- $serviceTitle = "Web Feature Service";
- $serviceDescription = "This is the reference implementation of WFS 1.0.0 and WFS 1.1.0, supports all WFS operations including Transaction.";
- $idDefaultDB = DB::getPDO()->getZasobId();
- $aclList = array_filter($this->_usrAcl->getTablesAcl(), function ($acl) use ($idDefaultDB) {
- // // $dataSourceName = 'default_db';// TODO: getSourceName
- // // $tblName = $tblAcl->getName();
- // // try {
- // // $acl = $this->getAclFromTypeName($typeName = "p5_{$dataSourceName}:{$tblName}");
- // // } catch (Exception $e) {
- // // // echo "Error for table({$tblName}): " . $e->getMessage() . "\n";
- // // }
- // // if (!$acl) {
- // // // TODO: error log msg
- // // return false;
- // // }
- return ($idDefaultDB == $acl->getDB()); // hide non default_db tables
- });
- //header('Content-type: application/xml; charset="utf-8"');
- header('Content-type: application/xml');
- (new Api_Wfs_GetCapabilities)->getCapabilitiesXml($wfsServerUrl, $serviceTitle, $serviceDescription, $aclList);
- }
- }
|