ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
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 11 of file class.ilADT.php.

Constructor & Destructor Documentation

◆ __construct()

ilADT::__construct ( ilADTDefinition  $a_def)

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

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

38  {
39  global $DIC;
40  $this->setDefinition($a_def);
41  $this->reset();
42 
43  $this->lng = $DIC->language();
44  }
reset()
Init property defaults.
Definition: class.ilADT.php:58
$DIC
Definition: xapitoken.php:62
setDefinition(ilADTDefinition $a_def)
Set definition.
Definition: class.ilADT.php:79
+ Here is the call graph for this function:

Member Function Documentation

◆ addValidationError()

ilADT::addValidationError ( string  $a_error_code)
protected

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

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

223  : void
224  {
225  $this->validation_errors[] = $a_error_code;
226  }
+ 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

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

+ Here is the caller graph for this function:

◆ exportStdClass()

ilADT::exportStdClass ( )
abstract

Export value as stdClass.

Returns
stdClass | null

Referenced by ilAdvancedMDFieldDefinitionGroupBased\importComplexOptionFromForm(), and translateErrorCode().

+ Here is the caller graph for this function:

◆ getCheckSum()

ilADT::getCheckSum ( )
abstract

Get unique checksum.

Returns
string | null

Referenced by ilADTMultiText\equals(), ilADTGroup\equals(), ilADTInternalLink\equals(), ilADTMultiEnum\equals(), ilADTExternalLink\equals(), and translateErrorCode().

+ Here is the caller graph for this function:

◆ getCopyOfDefinition()

ilADT::getCopyOfDefinition ( )

Get copy of definition.

Returns
ilADTDefinition $a_def

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

References equals(), and isLarger().

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

102  {
103  return (clone $this->definition);
104  }
ADT definition base class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

◆ getType()

ilADT::getType ( )

Get type (from class/instance)

Returns
string

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

References getDefinition().

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

50  : string
51  {
52  return $this->getDefinition()->getType();
53  }
getDefinition()
Get definition.
Definition: class.ilADT.php:92
+ 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()

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

233  : array
234  {
235  if (
236  is_array($this->validation_errors) &&
237  count($this->validation_errors)) {
238  return array_unique($this->validation_errors);
239  }
240  return [];
241  }

◆ importStdClass()

ilADT::importStdClass ( ?stdClass  $a_std)
abstract

Import value from stdClass.

Parameters
stdClass  |  null$a_std

Referenced by ilAdvancedMDFieldDefinitionGroupBased\getADTForOption(), and translateErrorCode().

+ Here is the caller graph for this function:

◆ 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 165 of file class.ilADT.php.

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

Referenced by isInbetweenOrEqual().

165  : ?bool
166  {
167  if (
168  !$this->getDefinition()->isComparableTo($a_adt_from) ||
169  !$this->getDefinition()->isComparableTo($a_adt_to)
170  ) {
171  return null;
172  }
173  if ($this->isLarger($a_adt_from) === null || $this->isSmaller($a_adt_to) === null) {
174  return null;
175  }
176  return $this->isLarger($a_adt_from) && $this->isSmaller($a_adt_to);
177  }
isSmaller(ilADT $a_adt)
Check if given ADT is smaller than self.
isLarger(ilADT $a_adt)
Check if given ADT is larger than self.
getDefinition()
Get definition.
Definition: class.ilADT.php:92
+ 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 185 of file class.ilADT.php.

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

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

185  : ?bool
186  {
187  if (
188  !$this->getDefinition()->isComparableTo($a_adt_from) ||
189  !$this->getDefinition()->isComparableTo($a_adt_to)
190  ) {
191  return null;
192  }
193  if (
194  $this->equals($a_adt_from) === null ||
195  $this->equals($a_adt_to) === null ||
196  $this->isInbetween($a_adt_from, $a_adt_to) === null
197  ) {
198  return null;
199  }
200  return
201  $this->equals($a_adt_from) ||
202  $this->equals($a_adt_to) ||
203  $this->isInbetween($a_adt_from, $a_adt_to);
204  }
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)
getDefinition()
Get definition.
Definition: class.ilADT.php:92
+ 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

Referenced by getCopyOfDefinition(), isInbetween(), and isLargerOrEqual().

+ Here is the caller graph for this function:

◆ isLargerOrEqual()

ilADT::isLargerOrEqual ( ilADT  $a_adt)

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

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

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

125  : ?bool
126  {
127  if (!$this->getDefinition()->isComparableTo($a_adt)) {
128  return null;
129  }
130  if ($this->equals($a_adt) === null || $this->isLarger($a_adt) === null) {
131  return null;
132  }
133  return $this->equals($a_adt) || $this->isLarger($a_adt);
134  }
equals(ilADT $a_adt)
Check if given ADT equals self.
isLarger(ilADT $a_adt)
Check if given ADT is larger than self.
getDefinition()
Get definition.
Definition: class.ilADT.php:92
+ 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

Referenced by isInbetween(), isLargerOrEqual(), 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 148 of file class.ilADT.php.

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

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

148  : ?bool
149  {
150  if (!$this->getDefinition()->isComparableTo($a_adt)) {
151  return null;
152  }
153  if ($this->equals($a_adt) === null || $this->isSmaller($a_adt) === null) {
154  return null;
155  }
156  return $this->equals($a_adt) || $this->isSmaller($a_adt);
157  }
equals(ilADT $a_adt)
Check if given ADT equals self.
isSmaller(ilADT $a_adt)
Check if given ADT is smaller than self.
getDefinition()
Get definition.
Definition: class.ilADT.php:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid()

ilADT::isValid ( )

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

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

212  : bool
213  {
214  $this->validation_errors = [];
215 
216  if (!$this->getDefinition()->isNullAllowed() && $this->isNull()) {
217  $this->addValidationError(self::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED);
218  return false;
219  }
220  return true;
221  }
addValidationError(string $a_error_code)
isNull()
Is currently null.
getDefinition()
Get definition.
Definition: class.ilADT.php:92
+ 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

Referenced by reset(), and setDefinition().

+ Here is the caller graph for this function:

◆ reset()

ilADT::reset ( )

Init property defaults.

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

References isValidDefinition().

Referenced by __construct().

58  : void
59  {
60  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefinition()

ilADT::setDefinition ( ilADTDefinition  $a_def)
protected

Set definition.

Parameters
ilADTDefinition$a_def
Exceptions
ilException

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

References isValidDefinition().

Referenced by __construct().

79  : void
80  {
81  if ($this->isValidDefinition($a_def)) {
82  $this->definition = clone $a_def;
83  } else {
84  throw new ilException("ilADT invalid definition");
85  }
86  }
isValidDefinition(ilADTDefinition $a_def)
Check if definition is valid for ADT.
+ 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

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

References exportStdClass(), getCheckSum(), importStdClass(), and ILIAS\Repository\lng().

249  : string
250  {
251  switch ($a_code) {
252  case self::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED:
253  return $this->lng->txt("msg_input_is_required");
254 
255  case self::ADT_VALIDATION_ERROR_MAX_LENGTH:
256  return $this->lng->txt("adt_error_max_length");
257 
258  case self::ADT_VALIDATION_ERROR_MAX_SIZE:
259  return $this->lng->txt("adt_error_max_size");
260 
261  case self::ADT_VALIDATION_ERROR_MIN:
262  return $this->lng->txt("form_msg_value_too_low");
263 
264  case self::ADT_VALIDATION_ERROR_MAX:
265  return $this->lng->txt("form_msg_value_too_high");
266 
267  // :TODO: currently not used - see ilDateTimeInputGUI
268  case self::ADT_VALIDATION_DATE:
269  return $this->lng->txt("exc_date_not_valid");
270  }
271  throw new Exception("ADT unknown error code");
272  }
+ Here is the call graph for this function:

Field Documentation

◆ $definition

ilADTDefinition ilADT::$definition
protected

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

Referenced by getDefinition().

◆ $lng

ilLanguage ilADT::$lng
protected

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

◆ $validation_errors

array ilADT::$validation_errors = []
protected

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

Referenced by ilADTGroup\getValidationErrorsByElements().

◆ ADT_VALIDATION_DATE

const ilADT::ADT_VALIDATION_DATE = "adt6"

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

◆ ADT_VALIDATION_ERROR_INVALID_NODE

const ilADT::ADT_VALIDATION_ERROR_INVALID_NODE = 'adt7'

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

◆ ADT_VALIDATION_ERROR_MAX

const ilADT::ADT_VALIDATION_ERROR_MAX = "adt5"

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

◆ ADT_VALIDATION_ERROR_MAX_LENGTH

const ilADT::ADT_VALIDATION_ERROR_MAX_LENGTH = "adt2"

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

◆ ADT_VALIDATION_ERROR_MAX_SIZE

const ilADT::ADT_VALIDATION_ERROR_MAX_SIZE = "adt3"

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

◆ ADT_VALIDATION_ERROR_MIN

const ilADT::ADT_VALIDATION_ERROR_MIN = "adt4"

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

◆ ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED

const ilADT::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED = "adt1"

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


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