Ver Fonte

added label and opis for AntAcl

Piotr Labudda há 8 anos atrás
pai
commit
9d0c64a173
2 ficheiros alterados com 26 adições e 16 exclusões
  1. 1 4
      SE/se-lib/AntAclBase.php
  2. 25 12
      SE/se-lib/Core/AclBase.php

+ 1 - 4
SE/se-lib/AntAclBase.php

@@ -31,10 +31,6 @@ class AntAclBase extends Core_AclBase {
 	// public function getVisibleFieldListByIdZasob() { return $this->getRealFieldListByIdZasob(); } // TODO: get visible fields
 
 	public function _fetchInfoFromZasobyIfNeeded() {
-		DBG::log($this->_fields, 'array', "DBG sort fields - \$this->_fields");
-		$fields = $this->getRealFieldListByIdZasob();
-		DBG::log($fields, 'array', "DBG sort fields - \$fields");
-
 		if (!$this->_zasobyInfoFetched) {
 			$zasobyIds = array_filter(
 				array_map(function ($field) {
@@ -57,6 +53,7 @@ class AntAclBase extends Core_AclBase {
 					}
 				}, $zasobyInfo);
 				foreach ($this->_fields as $idx => $field) {
+					// $this->_fields[$idx]['name'] = $field['fieldNamespace']; // TODO: BUG query for non existing fields - check if isLocal is used
 					if ($field['idZasob'] > 0 && array_key_exists($field['idZasob'], $zasobyInfo)) {
 						$this->_fields[$idx]['sort_prio'] = $zasobyInfo[ $field['idZasob'] ]['SORT_PRIO'];
 						if (!empty($zasobyInfo[ $field['idZasob'] ]['DESC_PL'])) $this->_fields[$idx]['label'] = $zasobyInfo[ $field['idZasob'] ]['DESC_PL'];

+ 25 - 12
SE/se-lib/Core/AclBase.php

@@ -49,19 +49,32 @@ class Core_AclBase {
     */
     throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501);
   }
-  public function getFieldLabel($fieldName) {
-    foreach ($this->getFields() as $field) {
-      if ($fieldName != V::get('name', '', $field)) continue;
-      return V::get('label', $fieldName, $field);
-    }
-    return $fieldName;
+	public function getFieldLabel($fieldName) {
+		// DBG::log($this->getFields(), 'array', "DBG getFieldLabel({$fieldName})");
+		foreach ($this->getFields() as $field) {
+			if (empty($field['name']) && !empty($field['fieldNamespace'])) {
+				if ($fieldName != $field['fieldNamespace']) continue;
+			} else if (!empty($field['name'])) {
+				if ($fieldName != $field['name']) continue;
+			} else {
+				continue; // skip unknown field name
+			}
+			return V::get('label', $fieldName, $field);
+		}
+		return $fieldName;
 	}
-  public function getFieldOpis($fieldName) {
-    foreach ($this->getFields() as $field) {
-      if ($fieldName != V::get('name', '', $field)) continue;
-      return V::get('opis', $fieldName, $field);
-    }
-    return $fieldName;
+	public function getFieldOpis($fieldName) {
+		foreach ($this->getFields() as $field) {
+			if (empty($field['name']) && !empty($field['fieldNamespace'])) {
+				if ($fieldName != $field['fieldNamespace']) continue;
+			} else if (!empty($field['name'])) {
+				if ($fieldName != $field['name']) continue;
+			} else {
+				continue; // skip unknown field name
+			}
+			return V::get('opis', $fieldName, $field);
+		}
+		return $fieldName;
 	}
   public function getFieldListByIdZasob() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }// TODO: RMME - one field list function
   public function getLocalFieldList() { throw new HttpException("Acl function " . __FUNCTION__ . " Not implemented", 501); }// TODO: RMME - one field list function