瀏覽代碼

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

* 'master' of ssh://biuro.biall-net.pl:2222/plabudda/se:
  fixed bug in Menu objects
  fixed parse XML restriction without childrens
a.binder 8 年之前
父節點
當前提交
14f3df38c7
共有 2 個文件被更改,包括 29 次插入20 次删除
  1. 27 18
      SE/se-lib/Route/P5Menu.php
  2. 2 2
      SE/se-lib/XML.php

+ 27 - 18
SE/se-lib/Route/P5Menu.php

@@ -55,24 +55,33 @@ class Route_P5Menu extends RouteBase {
 			'body' => [
 				'version' => $this->getVersion(),
 
-				'objects' => array_map(function ($acl, $idZasob) use ($makeShortLabel) {
-					if (!$acl) return [
-						'id' => $idZasob,
-						'TODO' => 'TODO'
-					];
-
-					$zasobObj = ProcesHelper::getZasobTableInfo($acl->getID());
-					return [
-						'id' => $acl->getID(),
-						'namespace' => $acl->getNamespace(),
-						'name' => $acl->getName(),
-						'desc' => $zasobObj->DESC,
-						'label' => ($zasobObj->DESC_PL) ? htmlspecialchars($zasobObj->DESC_PL) : $zasobObj->DESC,
-						'short_label' => $makeShortLabel($zasobObj),
-						'opis' => htmlspecialchars($zasobObj->OPIS),
-						// 'raw_zasob_obj' => $zasobObj,
-					];
-				}, array_values($listObjects), array_keys($listObjects)),
+				'objects' => array_values( array_filter(
+					array_map(function ($acl, $idZasob) use ($makeShortLabel) {
+						if (!$acl) return [
+							'id' => $idZasob,
+							'TODO' => 'TODO'
+						];
+
+						$zasobObj = ProcesHelper::getZasobTableInfo($acl->getID());
+						return [
+							'id' => $acl->getID(),
+							'namespace' => $acl->getNamespace(),
+							'name' => $acl->getName(),
+							'desc' => $zasobObj->DESC,
+							'label' => ($zasobObj->DESC_PL) ? htmlspecialchars($zasobObj->DESC_PL) : $zasobObj->DESC,
+							'short_label' => $makeShortLabel($zasobObj),
+							'opis' => htmlspecialchars($zasobObj->OPIS),
+							// 'raw_zasob_obj' => $zasobObj,
+						];
+					}, array_values($listObjects), array_keys($listObjects)),
+					function ($infoAcl) {
+						if (!array_key_exists('namespace', $infoAcl)) {
+							trigger_error("Warning: problem z zasobem {$infoAcl['id']} - brak ACL", E_USER_WARNING);
+							return false;
+						}
+						return true;
+					}
+				) ),
 
 				'urls' => array_map(function ($label, $idZasob) {
 					return [

+ 2 - 2
SE/se-lib/XML.php

@@ -126,7 +126,7 @@ class XML {
 					DBG::log($type, 'array', "findElementType \$fieldName='{$fieldName}' type='{$nodeArray[1]['type']}' => type='{$type}'");
 					// check restrictions - if has enumeration then return 'p5:enum'
 					$isEnum = false;
-					foreach ($restrictionNode[2] as $restr) {
+					if (!empty($restrictionNode[2])) foreach ($restrictionNode[2] as $restr) {
 						if ('enumeration' === self::getTagName($restr[0])) {
 							$isEnum = true;
 							break;
@@ -261,7 +261,7 @@ class XML {
 		$restrictions = [];
 		if (empty($restrictionNode[1]['base'])) throw new Exception("Missing 'xsd:restriction/@base' for field '{$fieldName}'");
 		// xsd:simpleType/xsd:restriction/xsd:string
-		foreach ($restrictionNode[2] as $tagRestriction) {
+		if (!empty($restrictionNode[2])) foreach ($restrictionNode[2] as $tagRestriction) {
 			// xsd:string/xsd:maxLength
 			$val = $tagRestriction[1]['value'];
 			if ('enumeration' == XML::getTagName($tagRestriction[0])) {