Kaynağa Gözat

updated xsl recurse example

Piotr Labudda 8 yıl önce
ebeveyn
işleme
ae9d92b01a
1 değiştirilmiş dosya ile 22 ekleme ve 2 silme
  1. 22 2
      SE/se-lib/xsl-functions/testFetchWfs.php

+ 22 - 2
SE/se-lib/xsl-functions/testFetchWfs.php

@@ -8,10 +8,30 @@ function testFetchWfs($typeName, $featureId) {
 	try {
 		$acl = ACL::getAclByTypeName($typeName);
 		$pk = substr($featureId, strpos($featureId, '.') + 1);
-		$item = $acl->buildQuery([])->getItem($pk);
+		$item = $acl->buildQuery([ 'cols' => array_keys($acl->getXsdTypes()) ])->getItem($pk);
 		if (!$item) throw new Exception("Object with primary key = '{$pk}' not found");
+		DBG::log($item, 'array', "testFetchWfs feature found");
 		foreach ($item as $fieldName => $value) {
-			$tmp->appendXML('<p>' . $fieldName .': "' . $value . '"</p>');
+			if (is_scalar($value)) {
+				$tmp->appendXML('<p>' . $fieldName .': "' . $value . '"</p>');
+			}
+			else if (is_array($value)) {
+				$out = '<details open="true"><summary>' . $fieldName .':</summary><div>';
+				foreach ($value as $refItem) {
+					if (1 === count($refItem) && !empty($refItem['xlink'])) {
+						$out .= '<p> - ' . $refItem['xlink'] .':</p>';
+					}
+					else {
+						$out .= '<p>';
+						foreach ($refItem as $refField => $refValue) {
+							$out .= '- <b>' . $refField . ':</b> ' . $refValue .'<br>';
+						}
+						$out .= '</p>';
+					}
+				}
+				$out .= '</div></details>';
+				$tmp->appendXML($out);
+			}
 		}
 	} catch (Exception $e) {
 		$tmp->appendXML('<div class="alert alert-danger">' . $e->getMessage() . '</div>');