mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-31 22:17:33 +00:00
getValueAsArray() checks if value starts with separator
new funtion parseValue()
This commit is contained in:
parent
444ee2f8eb
commit
530d75fdf0
|
@ -117,7 +117,17 @@ class SeedDMS_Core_Attribute { /* {{{ */
|
||||||
*/
|
*/
|
||||||
function getValueAsArray() { /* {{{ */
|
function getValueAsArray() { /* {{{ */
|
||||||
if($this->_attrdef->getMultipleValues()) {
|
if($this->_attrdef->getMultipleValues()) {
|
||||||
return explode($this->_value[0], substr($this->_value, 1));
|
/* If the value doesn't start with the separator used in the value set,
|
||||||
|
* then assume that the value was not saved with a leading separator.
|
||||||
|
* This can happen, if the value was previously a single value from
|
||||||
|
* the value set and later turned into a multi value attribute.
|
||||||
|
*/
|
||||||
|
$sep = substr($this->_value, 0, 1);
|
||||||
|
$vsep = $this->_attrdef->getValueSetSeparator();
|
||||||
|
if($sep == $vsep)
|
||||||
|
return(explode($sep, substr($this->_value, 1)));
|
||||||
|
else
|
||||||
|
return(array($this->_value));
|
||||||
} else {
|
} else {
|
||||||
return array($this->_value);
|
return array($this->_value);
|
||||||
}
|
}
|
||||||
|
@ -684,6 +694,35 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a given value according to attribute definition
|
||||||
|
*
|
||||||
|
* The return value is always an array, even if the attribute is single
|
||||||
|
* value attribute.
|
||||||
|
*
|
||||||
|
* @return array list of single values
|
||||||
|
*/
|
||||||
|
function parseValue($value) { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
if($this->getMultipleValues()) {
|
||||||
|
/* If the value doesn't start with the separator used in the value set,
|
||||||
|
* then assume that the value was not saved with a leading separator.
|
||||||
|
* This can happen, if the value was previously a single value from
|
||||||
|
* the value set and later turned into a multi value attribute.
|
||||||
|
*/
|
||||||
|
$sep = substr($value, 0, 1);
|
||||||
|
$vsep = $this->getValueSetSeparator();
|
||||||
|
if($sep == $vsep)
|
||||||
|
return(explode($sep, substr($value, 1)));
|
||||||
|
else
|
||||||
|
return(array($value));
|
||||||
|
} else {
|
||||||
|
return array($value);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of documents, folders, document contents where this
|
* Return a list of documents, folders, document contents where this
|
||||||
* attribute definition is used
|
* attribute definition is used
|
||||||
|
|
Loading…
Reference in New Issue
Block a user