ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilADT Class Reference

ADT base class. More...

+ Inheritance diagram for ilADT:
+ Collaboration diagram for ilADT:

Public Member Functions

 __construct (ilADTDefinition $a_def)
 
 getType ()
 Get type (from class/instance) More...
 
 reset ()
 Init property defaults. More...
 
 getCopyOfDefinition ()
 Get copy of definition. More...
 
 equals (ilADT $a_adt)
 Check if given ADT equals self. More...
 
 isLarger (ilADT $a_adt)
 Check if given ADT is larger than self. More...
 
 isLargerOrEqual (ilADT $a_adt)
 
 isSmaller (ilADT $a_adt)
 Check if given ADT is smaller than self. More...
 
 isSmallerOrEqual (ilADT $a_adt)
 Check if given ADT is smaller or equal than self. More...
 
 isInbetween (ilADT $a_adt_from, ilADT $a_adt_to)
 Check if self is inbetween given ADTs (exclusive) More...
 
 isInbetweenOrEqual (ilADT $a_adt_from, ilADT $a_adt_to)
 Check if self is inbetween given ADTs (inclusive) More...
 
 isNull ()
 Is currently null. More...
 
 isValid ()
 
 getValidationErrors ()
 Get all validation error codes. More...
 
 translateErrorCode (string $a_code)
 Translate error-code to human-readable message. More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass (?stdClass $a_std)
 Import value from stdClass. More...
 

Data Fields

const ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED = "adt1"
 
const ADT_VALIDATION_ERROR_MAX_LENGTH = "adt2"
 
const ADT_VALIDATION_ERROR_MAX_SIZE = "adt3"
 
const ADT_VALIDATION_ERROR_MIN = "adt4"
 
const ADT_VALIDATION_ERROR_MAX = "adt5"
 
const ADT_VALIDATION_DATE = "adt6"
 
const ADT_VALIDATION_ERROR_INVALID_NODE = 'adt7'
 

Protected Member Functions

 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
 setDefinition (ilADTDefinition $a_def)
 Set definition. More...
 
 getDefinition ()
 Get definition. More...
 
 addValidationError (string $a_error_code)
 

Protected Attributes

ilADTDefinition $definition
 
ilLanguage $lng
 
array $validation_errors = []
 

Detailed Description

ADT base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 25 of file class.ilADT.php.

Constructor & Destructor Documentation

◆ __construct()

ilADT::__construct ( ilADTDefinition  $a_def)

Reimplemented in ilADTInternalLink.

Definition at line 51 of file class.ilADT.php.

52 {
53 global $DIC;
54 $this->setDefinition($a_def);
55 $this->reset();
56
57 $this->lng = $DIC->language();
58 }
reset()
Init property defaults.
Definition: class.ilADT.php:72
setDefinition(ilADTDefinition $a_def)
Set definition.
Definition: class.ilADT.php:93
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\lng(), reset(), and setDefinition().

+ Here is the call graph for this function:

Member Function Documentation

◆ addValidationError()

ilADT::addValidationError ( string  $a_error_code)
protected

Definition at line 237 of file class.ilADT.php.

237 : void
238 {
239 $this->validation_errors[] = $a_error_code;
240 }

Referenced by isValid(), ilADTExternalLink\isValid(), ilADTFloat\isValid(), ilADTInteger\isValid(), ilADTInternalLink\isValid(), ilADTLocation\isValid(), ilADTMultiText\isValid(), and ilADTText\isValid().

+ Here is the caller graph for this function:

◆ equals()

ilADT::equals ( ilADT  $a_adt)
abstract

Check if given ADT equals self.

Parameters
ilADT$a_adt
Returns
bool|null

Reimplemented in ilADTBoolean, ilADTDate, ilADTDateTime, ilADTEnum, ilADTExternalLink, ilADTFloat, ilADTGroup, ilADTInteger, ilADTInternalLink, ilADTLocalizedText, ilADTLocation, ilADTMultiEnum, ilADTMultiText, and ilADTText.

Referenced by isInbetweenOrEqual(), isLargerOrEqual(), and isSmallerOrEqual().

+ Here is the caller graph for this function:

◆ exportStdClass()

ilADT::exportStdClass ( )
abstract

◆ getCheckSum()

ilADT::getCheckSum ( )
abstract

◆ getCopyOfDefinition()

ilADT::getCopyOfDefinition ( )

Get copy of definition.

Returns
ilADTDefinition $a_def

Definition at line 115 of file class.ilADT.php.

116 {
117 return (clone $this->definition);
118 }
ADT definition base class.

Referenced by ilADTLocationFormBridge\addToForm(), and ilADTLocalizedTextSearchBridgeSingle\isInCondition().

+ Here is the caller graph for this function:

◆ getDefinition()

◆ getType()

ilADT::getType ( )

Get type (from class/instance)

Returns
string

Reimplemented in ilADTMultiEnum.

Definition at line 64 of file class.ilADT.php.

64 : string
65 {
66 return $this->getDefinition()->getType();
67 }
getDefinition()
Get definition.

References getDefinition().

Referenced by ilAdvancedMDValues\_deleteByFieldId(), ilADTFactory\getActiveRecordBridgeForInstance(), ilADTFactory\getDBBridgeForInstance(), ilADTFactory\getFormBridgeForInstance(), and ilADTFactory\getPresentationBridgeForInstance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidationErrors()

ilADT::getValidationErrors ( )

Get all validation error codes.

Returns
string[]
See also
isValid()

Reimplemented in ilADTGroup.

Definition at line 247 of file class.ilADT.php.

247 : array
248 {
249 if (
250 is_array($this->validation_errors) &&
251 count($this->validation_errors)) {
252 return array_unique($this->validation_errors);
253 }
254 return [];
255 }

◆ importStdClass()

ilADT::importStdClass ( ?stdClass  $a_std)
abstract

◆ isInbetween()

ilADT::isInbetween ( ilADT  $a_adt_from,
ilADT  $a_adt_to 
)

Check if self is inbetween given ADTs (exclusive)

Parameters
ilADT$a_adt_from
ilADT$a_adt_to
Returns
bool | null

Definition at line 179 of file class.ilADT.php.

179 : ?bool
180 {
181 if (
182 !$this->getDefinition()->isComparableTo($a_adt_from) ||
183 !$this->getDefinition()->isComparableTo($a_adt_to)
184 ) {
185 return null;
186 }
187 if ($this->isLarger($a_adt_from) === null || $this->isSmaller($a_adt_to) === null) {
188 return null;
189 }
190 return $this->isLarger($a_adt_from) && $this->isSmaller($a_adt_to);
191 }
isSmaller(ilADT $a_adt)
Check if given ADT is smaller than self.
isLarger(ilADT $a_adt)
Check if given ADT is larger than self.

References getDefinition(), isLarger(), and isSmaller().

Referenced by isInbetweenOrEqual().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInbetweenOrEqual()

ilADT::isInbetweenOrEqual ( ilADT  $a_adt_from,
ilADT  $a_adt_to 
)

Check if self is inbetween given ADTs (inclusive)

Parameters
ilADT$a_adt_from
ilADT$a_adt_to
Returns
bool

Definition at line 199 of file class.ilADT.php.

199 : ?bool
200 {
201 if (
202 !$this->getDefinition()->isComparableTo($a_adt_from) ||
203 !$this->getDefinition()->isComparableTo($a_adt_to)
204 ) {
205 return null;
206 }
207 if (
208 $this->equals($a_adt_from) === null ||
209 $this->equals($a_adt_to) === null ||
210 $this->isInbetween($a_adt_from, $a_adt_to) === null
211 ) {
212 return null;
213 }
214 return
215 $this->equals($a_adt_from) ||
216 $this->equals($a_adt_to) ||
217 $this->isInbetween($a_adt_from, $a_adt_to);
218 }
equals(ilADT $a_adt)
Check if given ADT equals self.
isInbetween(ilADT $a_adt_from, ilADT $a_adt_to)
Check if self is inbetween given ADTs (exclusive)

References equals(), getDefinition(), and isInbetween().

Referenced by ilADTDateSearchBridgeRange\isInCondition(), and ilADTDateTimeSearchBridgeRange\isInCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLarger()

ilADT::isLarger ( ilADT  $a_adt)
abstract

Check if given ADT is larger than self.

Parameters
ilADT$a_adt
Returns
bool

Reimplemented in ilADTBoolean, ilADTDate, ilADTDateTime, ilADTEnum, ilADTExternalLink, ilADTFloat, ilADTGroup, ilADTInteger, ilADTInternalLink, ilADTLocalizedText, ilADTLocation, ilADTMultiEnum, ilADTMultiText, and ilADTText.

Referenced by isInbetween(), and isLargerOrEqual().

+ Here is the caller graph for this function:

◆ isLargerOrEqual()

ilADT::isLargerOrEqual ( ilADT  $a_adt)

Definition at line 139 of file class.ilADT.php.

139 : ?bool
140 {
141 if (!$this->getDefinition()->isComparableTo($a_adt)) {
142 return null;
143 }
144 if ($this->equals($a_adt) === null || $this->isLarger($a_adt) === null) {
145 return null;
146 }
147 return $this->equals($a_adt) || $this->isLarger($a_adt);
148 }

References equals(), getDefinition(), and isLarger().

Referenced by ilADTDateSearchBridgeRange\isInCondition(), and ilADTDateTimeSearchBridgeRange\isInCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNull()

◆ isSmaller()

ilADT::isSmaller ( ilADT  $a_adt)
abstract

Check if given ADT is smaller than self.

Parameters
ilADT$a_adt
Returns
bool | null

Reimplemented in ilADTBoolean, ilADTDate, ilADTDateTime, ilADTEnum, ilADTExternalLink, ilADTFloat, ilADTGroup, ilADTInteger, ilADTInternalLink, ilADTLocalizedText, ilADTLocation, ilADTMultiEnum, ilADTMultiText, and ilADTText.

Referenced by isInbetween(), and isSmallerOrEqual().

+ Here is the caller graph for this function:

◆ isSmallerOrEqual()

ilADT::isSmallerOrEqual ( ilADT  $a_adt)

Check if given ADT is smaller or equal than self.

Parameters
ilADT$a_adt
Returns
bool | null

Definition at line 162 of file class.ilADT.php.

162 : ?bool
163 {
164 if (!$this->getDefinition()->isComparableTo($a_adt)) {
165 return null;
166 }
167 if ($this->equals($a_adt) === null || $this->isSmaller($a_adt) === null) {
168 return null;
169 }
170 return $this->equals($a_adt) || $this->isSmaller($a_adt);
171 }

References equals(), getDefinition(), and isSmaller().

Referenced by ilADTDateSearchBridgeRange\isInCondition(), and ilADTDateTimeSearchBridgeRange\isInCondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid()

ilADT::isValid ( )

Reimplemented in ilADTBoolean, ilADTExternalLink, ilADTFloat, ilADTGroup, ilADTInteger, ilADTInternalLink, ilADTLocation, ilADTMultiText, and ilADTText.

Definition at line 226 of file class.ilADT.php.

226 : bool
227 {
228 $this->validation_errors = [];
229
230 if (!$this->getDefinition()->isNullAllowed() && $this->isNull()) {
231 $this->addValidationError(self::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED);
232 return false;
233 }
234 return true;
235 }
isNull()
Is currently null.
addValidationError(string $a_error_code)

References addValidationError(), getDefinition(), and isNull().

+ Here is the call graph for this function:

◆ isValidDefinition()

ilADT::isValidDefinition ( ilADTDefinition  $a_def)
abstractprotected

Check if definition is valid for ADT.

Parameters
ilADTDefinition$a_def
Returns
bool

Reimplemented in ilADTBoolean, ilADTDate, ilADTDateTime, ilADTEnum, ilADTExternalLink, ilADTFloat, ilADTGroup, ilADTInteger, ilADTInternalLink, ilADTLocalizedText, ilADTLocation, ilADTMultiEnum, ilADTMultiText, and ilADTText.

Referenced by setDefinition().

+ Here is the caller graph for this function:

◆ reset()

ilADT::reset ( )

Init property defaults.

Reimplemented in ilADTBoolean, ilADTDate, ilADTDateTime, ilADTEnum, ilADTExternalLink, ilADTFloat, ilADTGroup, ilADTInteger, ilADTInternalLink, ilADTLocalizedText, ilADTLocation, ilADTMultiEnum, ilADTMultiText, and ilADTText.

Definition at line 72 of file class.ilADT.php.

72 : void
73 {
74 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setDefinition()

ilADT::setDefinition ( ilADTDefinition  $a_def)
protected

Set definition.

Parameters
ilADTDefinition$a_def
Exceptions
ilException

Reimplemented in ilADTGroup.

Definition at line 93 of file class.ilADT.php.

93 : void
94 {
95 if ($this->isValidDefinition($a_def)) {
96 $this->definition = clone $a_def;
97 } else {
98 throw new ilException("ilADT invalid definition");
99 }
100 }
isValidDefinition(ilADTDefinition $a_def)
Check if definition is valid for ADT.
Base class for ILIAS Exception handling.

References isValidDefinition().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translateErrorCode()

ilADT::translateErrorCode ( string  $a_code)

Translate error-code to human-readable message.

Parameters
string$a_code
Returns
string
Exceptions
Exception

Reimplemented in ilADTGroup, and ilADTLocation.

Definition at line 263 of file class.ilADT.php.

263 : string
264 {
265 switch ($a_code) {
267 return $this->lng->txt("msg_input_is_required");
268
270 return $this->lng->txt("adt_error_max_length");
271
273 return $this->lng->txt("adt_error_max_size");
274
276 return $this->lng->txt("form_msg_value_too_low");
277
279 return $this->lng->txt("form_msg_value_too_high");
280
281 // :TODO: currently not used - see ilDateTimeInputGUI
283 return $this->lng->txt("exc_date_not_valid");
284 }
285 throw new Exception("ADT unknown error code");
286 }
const ADT_VALIDATION_ERROR_MAX_SIZE
Definition: class.ilADT.php:39
const ADT_VALIDATION_ERROR_MAX_LENGTH
Definition: class.ilADT.php:36
const ADT_VALIDATION_ERROR_MAX
Definition: class.ilADT.php:43
const ADT_VALIDATION_ERROR_MIN
Definition: class.ilADT.php:42
const ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED
Definition: class.ilADT.php:33
const ADT_VALIDATION_DATE
Definition: class.ilADT.php:46

References ADT_VALIDATION_DATE, ADT_VALIDATION_ERROR_MAX, ADT_VALIDATION_ERROR_MAX_LENGTH, ADT_VALIDATION_ERROR_MAX_SIZE, ADT_VALIDATION_ERROR_MIN, ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $definition

ilADTDefinition ilADT::$definition
protected

Definition at line 27 of file class.ilADT.php.

Referenced by getDefinition().

◆ $lng

ilLanguage ilADT::$lng
protected

Definition at line 29 of file class.ilADT.php.

◆ $validation_errors

array ilADT::$validation_errors = []
protected

Definition at line 31 of file class.ilADT.php.

Referenced by ilADTGroup\getValidationErrorsByElements().

◆ ADT_VALIDATION_DATE

const ilADT::ADT_VALIDATION_DATE = "adt6"

Definition at line 46 of file class.ilADT.php.

Referenced by translateErrorCode().

◆ ADT_VALIDATION_ERROR_INVALID_NODE

const ilADT::ADT_VALIDATION_ERROR_INVALID_NODE = 'adt7'

Definition at line 49 of file class.ilADT.php.

◆ ADT_VALIDATION_ERROR_MAX

const ilADT::ADT_VALIDATION_ERROR_MAX = "adt5"

Definition at line 43 of file class.ilADT.php.

Referenced by translateErrorCode().

◆ ADT_VALIDATION_ERROR_MAX_LENGTH

const ilADT::ADT_VALIDATION_ERROR_MAX_LENGTH = "adt2"

Definition at line 36 of file class.ilADT.php.

Referenced by translateErrorCode().

◆ ADT_VALIDATION_ERROR_MAX_SIZE

const ilADT::ADT_VALIDATION_ERROR_MAX_SIZE = "adt3"

Definition at line 39 of file class.ilADT.php.

Referenced by translateErrorCode().

◆ ADT_VALIDATION_ERROR_MIN

const ilADT::ADT_VALIDATION_ERROR_MIN = "adt4"

Definition at line 42 of file class.ilADT.php.

Referenced by translateErrorCode().

◆ ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED

const ilADT::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED = "adt1"

Definition at line 33 of file class.ilADT.php.

Referenced by translateErrorCode().


The documentation for this class was generated from the following file: