add new method getValueAsArray()

helpful for multi value attributes
This commit is contained in:
Uwe Steinmann 2014-11-13 08:20:45 +01:00
parent 68ffdb407f
commit 86ba6aa6a6

View File

@ -91,8 +91,33 @@ class SeedDMS_Core_Attribute { /* {{{ */
function getID() { return $this->_id; }
/**
* Return attribute value as stored in database
*
* 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 getValue() { return $this->_value; }
/**
* Return attribute values as an array
*
* This function returns the attribute value as an array. Such an array
* has one element for non multi value attributes and n elements for
* multi value attributes.
*
* @return array the attribute values
*/
function getValueAsArray() { /* {{{ */
if($this->_attrdef->getMultipleValues()) {
return explode($this->_value[0], substr($this->_value, 1));
} else {
return array($this->_value);
}
} /* }}} */
/**
* Set a value of an attribute
* The attribute is deleted completely if the value is the empty string