Преглед изворни кода

Merge branch 'master' of ssh://biuro.biall-net.pl:2222/plabudda/se

a.binder пре 8 година
родитељ
комит
71c17d6045
3 измењених фајлова са 34 додато и 13 уклоњено
  1. 3 3
      SE/se-lib/AclQueryFeatures.php
  2. 27 7
      SE/se-lib/Api/Wfs/GetFeature.php
  3. 4 3
      SE/se-lib/Api/WfsDataServer.php

+ 3 - 3
SE/se-lib/AclQueryFeatures.php

@@ -493,7 +493,7 @@ class AclQueryFeatures {
 
 			$xsdType = $this->_acl->getXsdFieldType($fieldName);
 			if ('ref:' === substr($xsdType, 0, 4) && empty($cols)) { // only xlink's
-				DBG::log("TODO: add remote xlink's '{$fieldName}' \$items[{$primaryKey}]");
+				DBG::log("add remote xlink's '{$fieldName}' \$items[{$primaryKey}] ...");
 				$refTable = ACL::getRefTable($this->_acl->getNamespace(), $fieldName);
 				if (!$refTable) DBG::log("BUG: Missing refTable in add remote xlink's '{$fieldName}' \$items[{$primaryKey}]");
 				if ($refTable) {
@@ -502,7 +502,7 @@ class AclQueryFeatures {
 						from `{$refTable}` r
 						where r.PRIMARY_KEY = '{$primaryKey}'
 					");
-					DBG::log($xlinks, 'array', "TODO: add remote xlink's '{$fieldName}' \$items[{$primaryKey}]");
+					DBG::log($xlinks, 'array', "add remote xlink's for '{$fieldName}' \$items[{$primaryKey}]");
 					$row[$fieldName] = array_map(function ($refInfo) use ($fieldName) {
 						$ns = Core_AclHelper::parseTypeName($fieldName);
 						return [
@@ -510,7 +510,7 @@ class AclQueryFeatures {
 							'xlink' => "{$ns['url']}#{$ns['name']}.{$refInfo['REMOTE_PRIMARY_KEY']}",
 						];
 					}, $xlinks);
-					DBG::log($row[$fieldName], 'array', "TODO: remote xlinks: \$items[{$primaryKey}][{$fieldName}]");
+					DBG::log($row[$fieldName], 'array', "remote xlinks for \$items[{$primaryKey}][{$fieldName}]");
 				}
 			} else if ('ref:' === substr($xsdType, 0, 4)) { // cols
 				$items = ACL::getAclByTypeName($fieldName)->buildQuery([

+ 27 - 7
SE/se-lib/Api/Wfs/GetFeature.php

@@ -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})");

+ 4 - 3
SE/se-lib/Api/WfsDataServer.php

@@ -231,10 +231,11 @@ class Api_WfsDataServer extends Api_WfsServerBase {
 			$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 ]);
+			if (!empty($geomFld)) DBG::log($item[$geomFld], 'array', "item[{$itemKey}] ({$geomFld})isEmpty(".empty($item[$geomFld])."):");
+			DBG::log($item, 'array' , ">>> loop({$itemKey})");
+			DBG::log($searchParams['cols'], 'array' , "\$searchParams['cols']");
 			$xmlWriter->startElement('gml:featureMember');
-			Api_Wfs_GetFeature::printXmlFeatureRecurse($xmlWriter, $acl, $item, $tagName = "{$wfsNs}:{$type}", array_merge(
+			Api_Wfs_GetFeature::printXmlFeatureRecurse($xmlWriter, $acl, $item, $searchParams['cols'], $tagName = "{$wfsNs}:{$type}", array_merge(
 				[
 					'fid' => "{$type}.{$itemKey}",
 				],