add more documentation

This commit is contained in:
Uwe Steinmann 2021-09-16 16:14:21 +02:00
parent 32dda4b3e9
commit 4aa4556df8

View File

@ -704,6 +704,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
/**
* Get the whole value set as an array
*
* Each element is trimmed.
*
* @return array values of value set or false if the value set has
* less than 2 chars
*/
@ -715,9 +717,9 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
} /* }}} */
/**
* Get the n'th value of a value set
* Get the n'th trimmed value of a value set
*
* @param $ind
* @param $ind starting from 0 for the first element in the value set
* @return string n'th value of value set or false if the index is
* out of range or the value set has less than 2 chars
* @internal param int $index
@ -738,7 +740,9 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
*
* A value set is a list of values allowed for an attribute. The values
* are separated by a char which must also be the first char of the
* value set string.
* value set string. The method decomposes the value set, removes all
* leading and trailing white space from the elements and recombines them
* into a string.
*
* @param string $valueset
* @return boolean true if value set could be set, otherwise false
@ -784,12 +788,23 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
*
* A value of the attribute must match this regular expression.
*
* The methods checks if the regular expression is valid by running
* preg_match() on an empty string and see if it fails. Trying to set
* an invalid regular expression will not overwrite the current
* regular expression.
*
* All leading and trailing spaces of $regex will be removed.
*
* @param string $regex
* @return boolean true if regex could be set, otherwise false
* @return boolean true if regex could be set or is invalid, otherwise false
*/
function setRegex($regex) { /* {{{ */
$db = $this->_dms->getDB();
$regex = trim($regex);
if(@preg_match($regex, '') === false)
return false;
$queryStr = "UPDATE `tblAttributeDefinitions` SET `regex` =".$db->qstr($regex)." WHERE `id` = " . $this->_id;
$res = $db->getResult($queryStr);
if (!$res)
@ -830,13 +845,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
/**
* Parse a given value according to attribute definition
*
* The return value is always an array, even if the attribute is single
* value attribute.
* The return value is always an array, even if the attribute is a single
* value attribute. If the type of attribute is any of document, folder, user,
* or group then this method will fetch each object from the database and
* return an array of SeedDMS_Core_Document, SeedDMS_Core_Folder, etc.
*
* @param $value
* @param $value string
* @return array|bool
*/
function parseValue($value) { /* {{{ */
function parseValue(string $value) { /* {{{ */
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.
@ -1165,8 +1182,10 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
*
* @param string|array $attrvalue attribute value
* @param object $object set if the current attribute is saved for this object
* (this will only be passed to the onAttributeValidate callback)
* @param boolean $new set to true if the value is new value and not taken from
* an existing attribute
* an existing attribute
* (this will only be passed to the onAttributeValidate callback)
* @return boolean true if validation succeds, otherwise false
*/
function validate($attrvalue, $object=null, $new=false) { /* {{{ */