Merge branch 'seeddms-5.0.x' into seeddms-5.1.x

This commit is contained in:
Uwe Steinmann 2016-11-14 11:11:11 +01:00
commit a8f5892562
4 changed files with 53 additions and 3 deletions

View File

@ -125,7 +125,17 @@ class SeedDMS_Core_Attribute { /* {{{ */
*/
function getValueAsArray() { /* {{{ */
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 {
return array($this->_value);
}
@ -728,6 +738,35 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
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
* attribute definition is used

View File

@ -136,7 +136,16 @@ class SeedDMS_Core_Object { /* {{{ */
$value = $this->_attributes[$attrdef->getId()]->getValue();
if($attrdef->getMultipleValues()) {
$sep = substr($value, 0, 1);
return(explode($sep, substr($value, 1)));
$vsep = $attrdef->getValueSetSeparator();
/* 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.
*/
if($sep == $vsep)
return(explode($sep, substr($value, 1)));
else
return(array($value));
} else {
return $value;
}

View File

@ -1128,6 +1128,7 @@ SeedDMS_Core_DMS::getNotificationsByUser() are deprecated
<notes>
- new method SeedDMЅ_Core_WorkflowAction::getTransitions()
- new method SeedDMЅ_Core_WorkflowState::getTransitions()
- new method SeedDMЅ_Core_AttributeDefinition::parseValue()
</notes>
</release>
<release>

View File

@ -92,8 +92,9 @@ $(document).ready( function() {
print "<th></th>\n";
print "</tr></thead>\n<tbody>\n";
foreach($res['frequencies'][$type] as $entry) {
$value = $selattrdef->parseValue($entry['value']);
echo "<tr>";
echo "<td>".$entry['value']."</td><td>".$entry['c']."</td>";
echo "<td>".implode(';', $value)."</td><td>".$entry['c']."</td>";
/* various checks, if the value is valid */
echo "<td>";
/* Check if value is in value set */