add SeedDMS_Core_Attribute::getParsedValue() and use it in SeedDMS_Core_Object:: getAttributeValue()

This commit is contained in:
Uwe Steinmann 2022-11-09 10:26:08 +01:00
parent 3571d97f2f
commit 5438d95eb5
3 changed files with 24 additions and 2 deletions

View File

@ -120,6 +120,27 @@ class SeedDMS_Core_Attribute { /* {{{ */
*/
function getValue() { return $this->_value; }
/**
* Return attribute value parsed into a php type or object
*
* This function will return the value of multi value attributes
* including the separator char.
*
* @return string the attribute value as it is stored in the database.
*/
function getParsedValue() { /* {{{ */
switch($this->_attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_float:
return (float) $this->_value;
case SeedDMS_Core_AttributeDefinition::type_boolean:
return (bool) $this->_value;
case SeedDMS_Core_AttributeDefinition::type_int:
return (int) $this->_value;
default:
return $this->_value;
}
} /* }}} */
/**
* Return attribute values as an array
*

View File

@ -152,7 +152,7 @@ class SeedDMS_Core_Object { /* {{{ */
}
if (isset($this->_attributes[$attrdef->getId()])) {
$value = $this->_attributes[$attrdef->getId()]->getValue();
$value = $this->_attributes[$attrdef->getId()]->getValue();
if($attrdef->getMultipleValues()) {
$sep = substr($value, 0, 1);
$vsep = $attrdef->getValueSetSeparator();
@ -166,7 +166,7 @@ class SeedDMS_Core_Object { /* {{{ */
else
return(array($value));
} else {
return $value;
return $this->_attributes[$attrdef->getId()]->getParsedValue();
}
} else
return false;

View File

@ -28,6 +28,7 @@
- fix SeedDMS_Core_File::fileExtension()
- SeedDMS_Core_DMS::createPasswordRequest() creates a cryptographically secure hash
- fix sql error when deleting a folder attribute
- add SeedDMS_Core_Attribute::getParsedValue() and use it in SeedDMS_Core_Object::getAttributeValue()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">