ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)

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

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

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
global $DIC
Definition: shib_login.php:22
setDefinition(ilADTDefinition $a_def)
Set definition.
Definition: class.ilADT.php:93
+ 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.

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

237  : void
238  {
239  $this->validation_errors[] = $a_error_code;
240  }
+ 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(), ilADTInternalLink\equals(), ilADTGroup\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 115 of file class.ilADT.php.

References equals(), and isLarger().

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

116  {
117  return (clone $this->definition);
118  }
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 64 of file class.ilADT.php.

References getDefinition().

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

64  : string
65  {
66  return $this->getDefinition()->getType();
67  }
getDefinition()
Get definition.
+ 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 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

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

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

Referenced by isInbetweenOrEqual().

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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDefinition()
Get definition.
+ 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.

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

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

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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isInbetween(ilADT $a_adt_from, ilADT $a_adt_to)
Check if self is inbetween given ADTs (exclusive)
getDefinition()
Get definition.
+ 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 139 of file class.ilADT.php.

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

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

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  }
equals(ilADT $a_adt)
Check if given ADT equals self.
isLarger(ilADT $a_adt)
Check if given ADT is larger than self.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDefinition()
Get definition.
+ 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 162 of file class.ilADT.php.

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

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

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  }
equals(ilADT $a_adt)
Check if given ADT equals self.
isSmaller(ilADT $a_adt)
Check if given ADT is smaller than self.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDefinition()
Get definition.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid()

ilADT::isValid ( )

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

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

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  }
addValidationError(string $a_error_code)
isNull()
Is currently null.
getDefinition()
Get definition.
+ 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 72 of file class.ilADT.php.

References isValidDefinition().

Referenced by __construct().

72  : void
73  {
74  }
+ 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 93 of file class.ilADT.php.

References isValidDefinition().

Referenced by __construct().

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.
+ 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 263 of file class.ilADT.php.

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

263  : string
264  {
265  switch ($a_code) {
266  case self::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED:
267  return $this->lng->txt("msg_input_is_required");
268 
269  case self::ADT_VALIDATION_ERROR_MAX_LENGTH:
270  return $this->lng->txt("adt_error_max_length");
271 
272  case self::ADT_VALIDATION_ERROR_MAX_SIZE:
273  return $this->lng->txt("adt_error_max_size");
274 
275  case self::ADT_VALIDATION_ERROR_MIN:
276  return $this->lng->txt("form_msg_value_too_low");
277 
278  case self::ADT_VALIDATION_ERROR_MAX:
279  return $this->lng->txt("form_msg_value_too_high");
280 
281  // :TODO: currently not used - see ilDateTimeInputGUI
282  case self::ADT_VALIDATION_DATE:
283  return $this->lng->txt("exc_date_not_valid");
284  }
285  throw new Exception("ADT unknown error code");
286  }
+ 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.

◆ 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.

◆ ADT_VALIDATION_ERROR_MAX_LENGTH

const ilADT::ADT_VALIDATION_ERROR_MAX_LENGTH = "adt2"

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

◆ ADT_VALIDATION_ERROR_MAX_SIZE

const ilADT::ADT_VALIDATION_ERROR_MAX_SIZE = "adt3"

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

◆ ADT_VALIDATION_ERROR_MIN

const ilADT::ADT_VALIDATION_ERROR_MIN = "adt4"

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

◆ ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED

const ilADT::ADT_VALIDATION_ERROR_NULL_NOT_ALLOWED = "adt1"

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


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