mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 13:11:31 +00:00
inc.ClassAttribute.php
This commit is contained in:
parent
2ab5db0c6d
commit
61382afc7b
|
@ -85,6 +85,4 @@ define("N_DELETE_VERSION", 5);
|
||||||
/**
|
/**
|
||||||
* Notify when version of document was deleted
|
* Notify when version of document was deleted
|
||||||
*/
|
*/
|
||||||
define("N_ADD_DOCUMENT", 6);
|
define("N_ADD_DOCUMENT", 6);
|
||||||
|
|
||||||
?>
|
|
|
@ -36,7 +36,7 @@ class SeedDMS_Core_Attribute { /* {{{ */
|
||||||
protected $_id;
|
protected $_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object SeedDMS_Core_Object folder, document or document content
|
* @var SeedDMS_Core_Folder|SeedDMS_Core_Document|SeedDMS_Core_DocumentContent SeedDMS_Core_Object folder, document or document content
|
||||||
* this attribute belongs to
|
* this attribute belongs to
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
|
@ -44,7 +44,7 @@ class SeedDMS_Core_Attribute { /* {{{ */
|
||||||
protected $_obj;
|
protected $_obj;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object SeedDMS_Core_AttributeDefinition definition of this attribute
|
* @var SeedDMS_Core_AttributeDefinition definition of this attribute
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
|
@ -65,20 +65,19 @@ class SeedDMS_Core_Attribute { /* {{{ */
|
||||||
protected $_validation_error;
|
protected $_validation_error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
|
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected $_dms;
|
protected $_dms;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* SeedDMS_Core_Attribute constructor.
|
||||||
*
|
* @param $id
|
||||||
* @param integer $id internal id of attribute
|
* @param $obj
|
||||||
* @param SeedDMS_Core_Object $obj object this attribute is attached to
|
* @param $attrdef
|
||||||
* @param SeedDMS_Core_AttributeDefinition $attrdef reference to the attribute definition
|
* @param $value
|
||||||
* @param string $value value of the attribute
|
*/
|
||||||
*/
|
|
||||||
function __construct($id, $obj, $attrdef, $value) { /* {{{ */
|
function __construct($id, $obj, $attrdef, $value) { /* {{{ */
|
||||||
$this->_id = $id;
|
$this->_id = $id;
|
||||||
$this->_obj = $obj;
|
$this->_obj = $obj;
|
||||||
|
@ -242,10 +241,11 @@ class SeedDMS_Core_Attribute { /* {{{ */
|
||||||
* If the validation fails the validation error will be set which
|
* If the validation fails the validation error will be set which
|
||||||
* can be requested by SeedDMS_Core_Attribute::getValidationError()
|
* can be requested by SeedDMS_Core_Attribute::getValidationError()
|
||||||
*
|
*
|
||||||
* @return boolean true if validation succeds, otherwise false
|
* @return boolean true if validation succeeds, otherwise false
|
||||||
*/
|
*/
|
||||||
function validate() { /* {{{ */
|
function validate() { /* {{{ */
|
||||||
$attrdef = $this->_attrdef();
|
/** @var SeedDMS_Core_AttributeDefinition $attrdef */
|
||||||
|
$attrdef = $this->_attrdef(); /** @todo check this out, this method is not existing */
|
||||||
$result = $attrdef->validate($this->_value);
|
$result = $attrdef->validate($this->_value);
|
||||||
$this->_validation_error = $attrdef->getValidationError();
|
$this->_validation_error = $attrdef->getValidationError();
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -373,12 +373,17 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
protected $_validation_error;
|
protected $_validation_error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object SeedDMS_Core_DMS reference to the dms instance this attribute definition belongs to
|
* @var SeedDMS_Core_DMS reference to the dms instance this attribute definition belongs to
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected $_dms;
|
protected $_dms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_separator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Possible skalar data types of an attribute
|
* Possible skalar data types of an attribute
|
||||||
*/
|
*/
|
||||||
|
@ -398,20 +403,21 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
const objtype_document = '2';
|
const objtype_document = '2';
|
||||||
const objtype_documentcontent = '3';
|
const objtype_documentcontent = '3';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param integer $id internal id of attribute definition
|
* @param integer $id internal id of attribute definition
|
||||||
* @param string $name name of attribute
|
* @param string $name name of attribute
|
||||||
* @param integer $objtype type of object for which this attribute definition
|
* @param integer $objtype type of object for which this attribute definition
|
||||||
* may be used.
|
* may be used.
|
||||||
* @param integer $type skalar type of attribute
|
* @param integer $type skalar type of attribute
|
||||||
* @param boolean $multiple set to true if multiple values are allowed
|
* @param boolean $multiple set to true if multiple values are allowed
|
||||||
* @param integer $minvalues minimum number of values
|
* @param integer $minvalues minimum number of values
|
||||||
* @param integer $maxvalues maximum number of values
|
* @param integer $maxvalues maximum number of values
|
||||||
* @param string $valueset separated list of allowed values, the first char
|
* @param string $valueset separated list of allowed values, the first char
|
||||||
* is taken as the separator
|
* is taken as the separator
|
||||||
*/
|
* @param $regex
|
||||||
|
*/
|
||||||
function __construct($id, $name, $objtype, $type, $multiple, $minvalues, $maxvalues, $valueset, $regex) { /* {{{ */
|
function __construct($id, $name, $objtype, $type, $multiple, $minvalues, $maxvalues, $valueset, $regex) { /* {{{ */
|
||||||
$this->_id = $id;
|
$this->_id = $id;
|
||||||
$this->_name = $name;
|
$this->_name = $name;
|
||||||
|
@ -472,14 +478,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
*/
|
*/
|
||||||
function getObjType() { return $this->_objtype; }
|
function getObjType() { return $this->_objtype; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set object type of attribute definition
|
* Set object type of attribute definition
|
||||||
*
|
*
|
||||||
* This can be one of objtype_all,
|
* This can be one of objtype_all,
|
||||||
* objtype_folder, objtype_document, or objtype_documentcontent.
|
* objtype_folder, objtype_document, or objtype_documentcontent.
|
||||||
*
|
*
|
||||||
* @param integer $objtype type
|
* @param integer $objtype type
|
||||||
*/
|
* @return bool
|
||||||
|
*/
|
||||||
function setObjType($objtype) { /* {{{ */
|
function setObjType($objtype) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -502,14 +509,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
*/
|
*/
|
||||||
function getType() { return $this->_type; }
|
function getType() { return $this->_type; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set type of attribute definition
|
* Set type of attribute definition
|
||||||
*
|
*
|
||||||
* This can be one of type_int, type_float, type_string, type_boolean,
|
* This can be one of type_int, type_float, type_string, type_boolean,
|
||||||
* type_url, type_email.
|
* type_url, type_email.
|
||||||
*
|
*
|
||||||
* @param integer $type type
|
* @param integer $type type
|
||||||
*/
|
* @return bool
|
||||||
|
*/
|
||||||
function setType($type) { /* {{{ */
|
function setType($type) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -529,12 +537,13 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
*/
|
*/
|
||||||
function getMultipleValues() { return $this->_multiple; }
|
function getMultipleValues() { return $this->_multiple; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if attribute definition allows multi values for attribute
|
* Set if attribute definition allows multi values for attribute
|
||||||
*
|
*
|
||||||
* @param boolean $mv true if attribute may have multiple values, otherwise
|
* @param boolean $mv true if attribute may have multiple values, otherwise
|
||||||
* false
|
* false
|
||||||
*/
|
* @return bool
|
||||||
|
*/
|
||||||
function setMultipleValues($mv) { /* {{{ */
|
function setMultipleValues($mv) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -633,13 +642,14 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
return array();
|
return array();
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the n'th value of a value set
|
* Get the n'th value of a value set
|
||||||
*
|
*
|
||||||
* @param interger $index
|
* @param $ind
|
||||||
* @return string n'th value of value set or false if the index is
|
* @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
|
* out of range or the value set has less than 2 chars
|
||||||
*/
|
* @internal param int $index
|
||||||
|
*/
|
||||||
function getValueSetValue($ind) { /* {{{ */
|
function getValueSetValue($ind) { /* {{{ */
|
||||||
if(strlen($this->_valueset) > 1) {
|
if(strlen($this->_valueset) > 1) {
|
||||||
$tmp = explode($this->_valueset[0], substr($this->_valueset, 1));
|
$tmp = explode($this->_valueset[0], substr($this->_valueset, 1));
|
||||||
|
@ -745,17 +755,16 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a given value according to attribute definition
|
* Parse a given value according to attribute definition
|
||||||
*
|
*
|
||||||
* The return value is always an array, even if the attribute is single
|
* The return value is always an array, even if the attribute is single
|
||||||
* value attribute.
|
* value attribute.
|
||||||
*
|
*
|
||||||
* @return array list of single values
|
* @param $value
|
||||||
*/
|
* @return array|bool
|
||||||
|
*/
|
||||||
function parseValue($value) { /* {{{ */
|
function parseValue($value) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
|
||||||
|
|
||||||
if($this->getMultipleValues()) {
|
if($this->getMultipleValues()) {
|
||||||
/* If the value doesn't start with the separator used in the value set,
|
/* 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.
|
* then assume that the value was not saved with a leading separator.
|
||||||
|
@ -771,7 +780,6 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
} else {
|
} else {
|
||||||
return array($value);
|
return array($value);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -779,8 +787,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
* attribute definition is used
|
* attribute definition is used
|
||||||
*
|
*
|
||||||
* @param integer $limit return not more the n objects of each type
|
* @param integer $limit return not more the n objects of each type
|
||||||
* @return boolean true if attribute definition is used, otherwise false
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function getStatistics($limit=0) { /* {{{ */
|
function getStatistics($limit=0) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -995,8 +1003,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
if(!$success)
|
if(!$success)
|
||||||
$this->_validation_error = 3;
|
$this->_validation_error = 3;
|
||||||
break;
|
break;
|
||||||
case self::type_boolean:
|
case self::type_boolean: /** @todo: Same case in LINE 966 */
|
||||||
foreach($values as $value) {
|
foreach($values as $value) {
|
||||||
$success &= preg_match('/^[01]$/', $value);
|
$success &= preg_match('/^[01]$/', $value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1041,4 +1049,3 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
||||||
function getValidationError() { return $this->_validation_error; }
|
function getValidationError() { return $this->_validation_error; }
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user