|
|
@@ -80,13 +80,14 @@ class Api_Wfs_GetFeature {
|
|
|
}
|
|
|
|
|
|
// TODO: add $contextAcl and context xpath to check for special perms by contextAcl
|
|
|
- public static function printXmlFeatureRecurse($xmlWriter, $acl, $item, $tagName, $attrs = [], $showAdvancedAttrs = false, $schemaCache = [], $printedFidLog = []) {
|
|
|
+ public static function printXmlFeatureRecurse($xmlWriter, $acl, $item, $showFields, $tagName, $attrs = [], $showAdvancedAttrs = false, $schemaCache = [], $printedFidLog = []) {
|
|
|
$dbgFid = V::get('fid', 0, $attrs);
|
|
|
if ($dbgFid) $printedFidLog[] = $dbgFid;
|
|
|
- if(V::get('DBG_XML', '', $_GET))$xmlWriter->writeComment("DBG: printXmlFeatureRecurse... '{$tagName}'" . ( $dbgFid ? " fid='{$dbgFid}'" : "" )); // TODO: DBG
|
|
|
- DBG::log($acl, 'array', "DBG: printXmlFeatureRecurse( ... {$tagName}, \$acl)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ));
|
|
|
- DBG::log($item, 'array', "DBG: printXmlFeatureRecurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ));
|
|
|
- DBG::log([$attrs, $showAdvancedAttrs, array_keys($schemaCache), $printedFidLog], 'array', "DBG: printXmlFeatureRecurse( ... {$tagName}, \$attrs, \$showAdvancedAttrs, keys(\$schemaCache), \$printedFidLog)");
|
|
|
+ if(V::get('DBG_XML', '', $_GET))$xmlWriter->writeComment("DBG: print Xml Feature Recurse... '{$tagName}'" . ( $dbgFid ? " fid='{$dbgFid}'" : "" )); // TODO: DBG
|
|
|
+ DBG::log($acl, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$acl)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$acl");
|
|
|
+ DBG::log($item, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$item");
|
|
|
+ DBG::log($showFields, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$showFields");
|
|
|
+ DBG::log([$attrs, $showAdvancedAttrs, array_keys($schemaCache), $printedFidLog], 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$attrs, \$showAdvancedAttrs, keys(\$schemaCache), \$printedFidLog)");
|
|
|
// $rootWfsNs = 'p5';
|
|
|
list($itemPrefix, $localName) = explode(':', $tagName);
|
|
|
|
|
|
@@ -132,7 +133,17 @@ class Api_Wfs_GetFeature {
|
|
|
}
|
|
|
|
|
|
DBG::log($fldList, 'array', ">>> loop start fields(".count($fldList).")");
|
|
|
+ // DBG::log($showFields, 'array', "DBG: \$showLocalFields \$showFields 0");
|
|
|
+ $showLocalFields = array_filter($showFields, function ($showFieldName) {
|
|
|
+ return (false === strpos($showFieldName, "/"));
|
|
|
+ });
|
|
|
+ // DBG::log($showLocalFields, 'array', "DBG: \$showLocalFields");
|
|
|
+ $fldList = array_filter($fldList, function ($fieldName) use ($showLocalFields) {
|
|
|
+ return (in_array($fieldName, $showLocalFields));
|
|
|
+ });
|
|
|
+ DBG::log($fldList, 'array', ">>> loop start filtered fields(".count($fldList).")");
|
|
|
foreach ($fldList as $idZasob => $fldName) {
|
|
|
+ // TODO: show only fields from $showFields
|
|
|
DBG::log(">>> loop {$idZasob} => {$fldName}...");
|
|
|
$fldType = $acl->getXsdFieldType($fldName);
|
|
|
DBG::log(">>> loop '{$fldName}' xsdType: '{$fldType}'");
|
|
|
@@ -164,7 +175,7 @@ class Api_Wfs_GetFeature {
|
|
|
$firstItem = reset($item[$fldName]);
|
|
|
if (1 === count($firstItem) && !empty($firstItem['xlink'])) { // TODO: $schemaCache[$fieldNs] must exists for xlinks - xlmns is required
|
|
|
foreach ($item[$fldName] as $childItem) {
|
|
|
- self::printXmlFeatureRecurse($xmlWriter, $childAcl = null, $childItem, $fldName, [], $showAdvancedAttrs, $schemaCache, $printedFidLog);
|
|
|
+ self::printXmlFeatureRecurse($xmlWriter, $childAcl = null, $childItem, $showChildFields = [], $fldName, [], $showAdvancedAttrs, $schemaCache, $printedFidLog);
|
|
|
}
|
|
|
} else {
|
|
|
DBG::log($schemaCache, 'array', "Error Processing Request - field is not ref or missing acl ".$acl->getName().".{$itemKey}/{$fldName}");
|
|
|
@@ -175,8 +186,17 @@ class Api_Wfs_GetFeature {
|
|
|
$childAcl = Core_AclHelper::getAclByNamespace($schemaCache[$fieldNs]['namespace'], false, $schemaCache[$fieldNs]);
|
|
|
$childName = $schemaCache[$fieldNs]['name'];
|
|
|
foreach ($item[$fldName] as $childItem) {
|
|
|
+ // DBG::log($showFields, 'array', "DBG: fld({$fldName}) \$showFields 0");
|
|
|
+ $showChildFields = array_filter($showFields, function ($showFieldName) use ($fldName) {
|
|
|
+ return ("{$fldName}/" === substr("{$showFieldName}", 0, strlen($fldName) + 1));
|
|
|
+ });
|
|
|
+ // DBG::log($showChildFields, 'array', "DBG: fld({$fldName}) \$showChildFields 1");
|
|
|
+ $showChildFields = array_map(function ($showFieldName) use ($fldName) {
|
|
|
+ return substr($showFieldName, strlen($fldName) + 1);
|
|
|
+ }, $showChildFields);
|
|
|
+ // DBG::log($showChildFields, 'array', "DBG: fld({$fldName}) \$showChildFields 2");
|
|
|
$childPK = V::get($childAcl->getPrimaryKeyField(), '', $childItem);
|
|
|
- self::printXmlFeatureRecurse($xmlWriter, $childAcl, $childItem, $fldName, ($childPK) ? [ 'fid' => "{$childName}.{$childPK}" ] : [], $showAdvancedAttrs, $schemaCache, $printedFidLog);
|
|
|
+ self::printXmlFeatureRecurse($xmlWriter, $childAcl, $childItem, $showChildFields, $fldName, ($childPK) ? [ 'fid' => "{$childName}.{$childPK}" ] : [], $showAdvancedAttrs, $schemaCache, $printedFidLog);
|
|
|
}
|
|
|
// foreach ($item[$fldName] as $refItem) {
|
|
|
// DBG::log($refItem, 'array', "\$refItem fld({$fldName})");
|