mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
add new method getValueAsArray()
helpful for multi value attributes
This commit is contained in:
parent
68ffdb407f
commit
86ba6aa6a6
|
@ -91,8 +91,33 @@ class SeedDMS_Core_Attribute { /* {{{ */
|
||||||
|
|
||||||
function getID() { return $this->_id; }
|
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; }
|
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
|
* Set a value of an attribute
|
||||||
* The attribute is deleted completely if the value is the empty string
|
* The attribute is deleted completely if the value is the empty string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user