|
|
@@ -96,10 +96,28 @@ class Api_Wfs_GetFeature {
|
|
|
}
|
|
|
|
|
|
// TODO: add $contextAcl and context xpath to check for special perms by contextAcl
|
|
|
- public static function printXmlFeatureRecurse($xmlWriter, $acl, $item, $showFields, $tagName, $attrs = [], $showAdvancedAttrs = false, $schemaCache = [], $printedFidLog = []) {
|
|
|
+ /** @example:
|
|
|
+ * Api_Wfs_GetFeature::printXmlFeatureRecurse($xmlWriter, $acl, $item, [
|
|
|
+ * 'fields' => $searchParams['cols'],
|
|
|
+ * 'tagName' => "{$wfsNs}:{$type}",
|
|
|
+ * 'showAdvancedAttrs' => !$simple,
|
|
|
+ * 'xsdAttributes' => array_merge(
|
|
|
+ * [ 'fid' => "{$type}.{$itemKey}" ],
|
|
|
+ * (!$simple)
|
|
|
+ * ? [ "{$rootWfsNs}:web_link" => Request::getPathUri() . "index.php?_route=ViewTableAjax&namespace=" . $acl->getNamespace() . "#EDIT/{$itemKey}" ]
|
|
|
+ * : []
|
|
|
+ * )
|
|
|
+ * ], $schemaCache, $printedFidLog);
|
|
|
+ */
|
|
|
+ public static function printXmlFeatureRecurse($xmlWriter, $acl, $item, $params = [], $schemaCache = [], $printedFidLog = []) {
|
|
|
+ $showFields = V::get('fields', [], $params, 'array'); // TODO: if empty $showFields ?
|
|
|
+ $tagName = V::get('tagName', '', $params);
|
|
|
+ $attrs = V::get('xsdAttributes', [], $params, 'array');
|
|
|
+ $showAdvancedAttrs = V::get('showAdvancedAttrs', false, $params, 'bool');
|
|
|
$dbgFid = V::get('fid', 0, $attrs);
|
|
|
+ $outputBlobFormat = V::get('outputBlobFormat', '', $params, 'word');
|
|
|
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($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)");
|
|
|
@@ -157,7 +175,6 @@ class Api_Wfs_GetFeature {
|
|
|
});
|
|
|
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}'");
|
|
|
@@ -189,7 +206,13 @@ 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, $showChildFields = [], $fldName, [], $showAdvancedAttrs, $schemaCache, $printedFidLog);
|
|
|
+ self::printXmlFeatureRecurse($xmlWriter, $childAcl = null, $childItem, [
|
|
|
+ 'fields' => [],
|
|
|
+ 'tagName' => $fldName,
|
|
|
+ 'xsdAttributes' => [],
|
|
|
+ 'showAdvancedAttrs' => $showAdvancedAttrs,
|
|
|
+ 'outputBlobFormat' => $outputBlobFormat,
|
|
|
+ ], $schemaCache, $printedFidLog);
|
|
|
}
|
|
|
} else {
|
|
|
DBG::log($schemaCache, 'array', "Error Processing Request - field is not ref or missing acl ".$acl->getName().".{$itemKey}/{$fldName}");
|
|
|
@@ -210,7 +233,13 @@ class Api_Wfs_GetFeature {
|
|
|
}, $showChildFields);
|
|
|
// DBG::log($showChildFields, 'array', "DBG: fld({$fldName}) \$showChildFields 2");
|
|
|
$childPK = V::get($childAcl->getPrimaryKeyField(), '', $childItem);
|
|
|
- self::printXmlFeatureRecurse($xmlWriter, $childAcl, $childItem, $showChildFields, $fldName, ($childPK) ? [ 'fid' => "{$childName}.{$childPK}" ] : [], $showAdvancedAttrs, $schemaCache, $printedFidLog);
|
|
|
+ self::printXmlFeatureRecurse($xmlWriter, $childAcl, $childItem, [
|
|
|
+ 'fields' => $showChildFields,
|
|
|
+ 'tagName' => $fldName,
|
|
|
+ 'xsdAttributes' => ($childPK) ? [ 'fid' => "{$childName}.{$childPK}" ] : [],
|
|
|
+ 'showAdvancedAttrs' => $showAdvancedAttrs,
|
|
|
+ 'outputBlobFormat' => $outputBlobFormat,
|
|
|
+ ], $schemaCache, $printedFidLog);
|
|
|
}
|
|
|
// foreach ($item[$fldName] as $refItem) {
|
|
|
// DBG::log($refItem, 'array', "\$refItem fld({$fldName})");
|
|
|
@@ -243,7 +272,7 @@ class Api_Wfs_GetFeature {
|
|
|
}
|
|
|
}
|
|
|
} else if ('xsd:base64Binary' === $acl->getXsdFieldType($fldName)) {
|
|
|
- if (empty($item[$fldName]) && '0' !== $item[$fldName]) continue;
|
|
|
+ if (empty($item[$fldName])) continue; // && '0' !== $item[$fldName]
|
|
|
$xmlWriter->startElement("{$itemPrefix}:{$fldName}");
|
|
|
if ($showAdvancedAttrs && !$acl->canReadObjectField($fldName, (object)$item)) {
|
|
|
$xmlWriter->writeAttribute("p5:allow_read", "false");
|
|
|
@@ -251,7 +280,27 @@ class Api_Wfs_GetFeature {
|
|
|
if ($showAdvancedAttrs && $acl->canWriteObjectField($fldName, (object)$item)) {
|
|
|
$xmlWriter->writeAttribute("p5:allow_write", "true");
|
|
|
}
|
|
|
- $xmlWriter->text(base64_encode($item[$fldName]));
|
|
|
+ $pk = V::get($acl->getPrimaryKeyField(), '', $item);
|
|
|
+ if ($showAdvancedAttrs) {
|
|
|
+ $xmlWriter->writeAttribute("p5:blobUrl", Request::getPathUri() . "wfs-data.php?" . implode("&", [
|
|
|
+ "SERVICE=WFS", "VERSION=1.0.0", "REQUEST=GetBlob",
|
|
|
+ "namespace=" . $acl->getNamespace(),
|
|
|
+ "primaryKey={$pk}",
|
|
|
+ "fieldName={$fldName}",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ if (in_array($item[$fldName], ['0', '1'])) {
|
|
|
+ if ('base64' === $outputBlobFormat) {
|
|
|
+ $content = DB::getPDO( $acl->getDatabaseID() )->getBlob( $acl->getRootTableName(), $fldName, $acl->getPrimaryKeyField(), $pk );
|
|
|
+ $xmlWriter->text(base64_encode($content));
|
|
|
+ } else if ('link' === $outputBlobFormat) {
|
|
|
+ $xmlWriter->text($item[$fldName]);
|
|
|
+ } else { // hide
|
|
|
+ throw new Exception("Not implemented outputBlobFormat - expected base64 or link");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $xmlWriter->text(base64_encode($item[$fldName]));
|
|
|
+ }
|
|
|
$xmlWriter->endElement();// {$itemPrefix}:{$fldName}
|
|
|
} else {
|
|
|
$value = str_replace('&', '&', $item[$fldName]);
|