mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 23:42:11 +00:00
fix handling of multivalue attributes
This commit is contained in:
parent
41469a4570
commit
5c07f7545b
|
@ -105,16 +105,23 @@ class SeedDMS_Core_Object { /* {{{ */
|
|||
/**
|
||||
* Returns an attribute of the object for the given attribute definition
|
||||
*
|
||||
* @return object object of class SeedDMS_Core_Attribute or false
|
||||
* @return array|string value of attritbute or false. The value is an array
|
||||
* if the attribute is defined as multi value
|
||||
*/
|
||||
function getAttributeValue($attrdef) { /* {{{ */
|
||||
if (!$this->_attributes) {
|
||||
$this->getAttributes();
|
||||
}
|
||||
|
||||
if (isset($this->_attributes[$attrdef->getId()]))
|
||||
return $this->_attributes[$attrdef->getId()]->getValue();
|
||||
else
|
||||
if (isset($this->_attributes[$attrdef->getId()])) {
|
||||
$value = $this->_attributes[$attrdef->getId()]->getValue();
|
||||
if($attrdef->getMultipleValues()) {
|
||||
$sep = substr($value, 0, 1);
|
||||
return(explode($sep, substr($value, 1)));
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
|
||||
} /* }}} */
|
||||
|
@ -122,6 +129,9 @@ class SeedDMS_Core_Object { /* {{{ */
|
|||
/**
|
||||
* Set an attribute of the object for the given attribute definition
|
||||
*
|
||||
* @param object $attrdef definition of attribute
|
||||
* @param array|sting $value value of attribute, for multiple values this
|
||||
* must be an array
|
||||
* @return boolean true if operation was successful, otherwise false
|
||||
*/
|
||||
function setAttributeValue($attrdef, $value) { /* {{{ */
|
||||
|
@ -129,6 +139,10 @@ class SeedDMS_Core_Object { /* {{{ */
|
|||
if (!$this->_attributes) {
|
||||
$this->getAttributes();
|
||||
}
|
||||
if($attrdef->getMultipleValues() && is_array($value)) {
|
||||
$sep = substr($attrdef->getValueSet(), 0, 1);
|
||||
$value = $sep.implode($sep, $value);
|
||||
}
|
||||
if(!isset($this->_attributes[$attrdef->getId()])) {
|
||||
switch(get_class($this)) {
|
||||
case "SeedDMS_Core_Document":
|
||||
|
|
Loading…
Reference in New Issue
Block a user