ILIAS  release_7 Revision v7.30-3-g800a261c036
ilADTLocalizedText Class Reference

Class ilADTLocalizedText. More...

+ Inheritance diagram for ilADTLocalizedText:
+ Collaboration diagram for ilADTLocalizedText:

Public Member Functions

 getTextForLanguage (string $language)
 
 getTranslations ()
 
 setTranslation (string $language, string $translation)
 
 equals (ilADT $adt)
 @inheritDoc More...
 
 isLarger (ilADT $a_adt)
 @inheritDoc More...
 
 isSmaller (ilADT $a_adt)
 @inheritDoc More...
 
 isNull ()
 @inheritDoc More...
 
 getCheckSum ()
 @inheritDoc More...
 
 exportStdClass ()
 @inheritDoc More...
 
 importStdClass ($a_std)
 @inheritDoc More...
 
- Public Member Functions inherited from ilADTText
 reset ()
 Init property defaults. More...
 
 setText ($a_value=null)
 
 getText ()
 
 getLength ()
 
 equals (ilADT $a_adt)
 Check if given ADT equals self. More...
 
 isLarger (ilADT $a_adt)
 Check if given ADT is larger than self. More...
 
 isSmaller (ilADT $a_adt)
 Check if given ADT is smaller than self. More...
 
 isNull ()
 Is currently null. More...
 
 isValid ()
 Is currently valid. More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass ($a_std)
 Import value from stdClass. More...
 
- Public Member Functions inherited from ilADT
 __construct (ilADTDefinition $a_def)
 Constructor. More...
 
 getType ()
 Get type (from class/instance) 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)
 Check if given ADT is larger or equal than self. More...
 
 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 ()
 Is currently valid. More...
 
 getValidationErrors ()
 Get all validation error codes. More...
 
 translateErrorCode ($a_code)
 Translate error-code to human-readable message. More...
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass ($a_std)
 Import value from stdClass. More...
 

Protected Member Functions

 isValidDefinition (ilADTDefinition $a_def)
 @inheritDoc More...
 
 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
- Protected Member Functions inherited from ilADT
 reset ()
 Init property defaults. More...
 
 isValidDefinition (ilADTDefinition $a_def)
 Check if definition is valid for ADT. More...
 
 setDefinition (ilADTDefinition $a_def)
 Set definition. More...
 
 getDefinition ()
 Get definition. More...
 
 addValidationError ($a_error_code)
 Add validation error code. More...
 

Private Attributes

 $translations = []
 

Additional Inherited Members

- Data Fields inherited from ilADT
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 Attributes inherited from ilADTText
 $value
 
- Protected Attributes inherited from ilADT
 $definition
 
 $validation_errors = []
 

Detailed Description

Member Function Documentation

◆ equals()

ilADTLocalizedText::equals ( ilADT  $adt)

@inheritDoc

Reimplemented from ilADTText.

Definition at line 54 of file class.ilADTLocalizedText.php.

55 {
56 if (!$this->getDefinition()->isComparableTo($adt)) {
57 return false;
58 }
59 if (count($this->getTranslations()) != count($adt->getTranslations())) {
60 return false;
61 }
62 foreach ($adt->getTranslations() as $key => $value) {
63 if (!isset($this->getTranslations()[$key])) {
64 return false;
65 }
66 if (!strcmp($this->getTranslations()[$key], $value)) {
67 return false;
68 }
69 }
70 return true;
71 }
getDefinition()
Get definition.
Definition: class.ilADT.php:97

References ilADTText\$value, ilADT\getDefinition(), and getTranslations().

+ Here is the call graph for this function:

◆ exportStdClass()

ilADTLocalizedText::exportStdClass ( )

@inheritDoc

Reimplemented from ilADTText.

Definition at line 106 of file class.ilADTLocalizedText.php.

107 {
108 if (!$this->isNull()) {
109 $obj = new stdClass();
110 $obj->translations = $this->getTranslations();
111 return $obj;
112 }
113 }

References getTranslations(), and isNull().

+ Here is the call graph for this function:

◆ getCheckSum()

ilADTLocalizedText::getCheckSum ( )

@inheritDoc

Reimplemented from ilADTText.

Definition at line 98 of file class.ilADTLocalizedText.php.

99 {
100 return md5(serialize($this->getTranslations()));
101 }

References getTranslations().

+ Here is the call graph for this function:

◆ getTextForLanguage()

ilADTLocalizedText::getTextForLanguage ( string  $language)
Parameters
string$language

Definition at line 18 of file class.ilADTLocalizedText.php.

19 {
20 if (strlen($this->getTranslations()[$language])) {
21 return $this->getTranslations()[$language];
22 }
23 return $this->getText();
24 }

References ilADTText\getText(), and getTranslations().

+ Here is the call graph for this function:

◆ getTranslations()

ilADTLocalizedText::getTranslations ( )
Returns
array

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

References $translations.

Referenced by equals(), exportStdClass(), getCheckSum(), getTextForLanguage(), and isNull().

+ Here is the caller graph for this function:

◆ importStdClass()

ilADTLocalizedText::importStdClass (   $a_std)

@inheritDoc

Reimplemented from ilADTText.

Definition at line 118 of file class.ilADTLocalizedText.php.

119 {
120 if (is_object($a_std)) {
121 $this->translations = $a_std->translations;
122 }
123 }

◆ isLarger()

ilADTLocalizedText::isLarger ( ilADT  $a_adt)

@inheritDoc

Reimplemented from ilADTText.

Definition at line 76 of file class.ilADTLocalizedText.php.

77 {
78 }

◆ isNull()

ilADTLocalizedText::isNull ( )

@inheritDoc

Reimplemented from ilADTText.

Definition at line 90 of file class.ilADTLocalizedText.php.

91 {
92 return !$this->getLength() && !count($this->getTranslations());
93 }

References ilADTText\getLength(), and getTranslations().

Referenced by exportStdClass().

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

◆ isSmaller()

ilADTLocalizedText::isSmaller ( ilADT  $a_adt)

@inheritDoc

Reimplemented from ilADTText.

Definition at line 83 of file class.ilADTLocalizedText.php.

84 {
85 }

◆ isValidDefinition()

ilADTLocalizedText::isValidDefinition ( ilADTDefinition  $a_def)
protected

@inheritDoc

Reimplemented from ilADTText.

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

47 {
48 return $a_def instanceof ilADTLocalizedTextDefinition;
49 }

◆ setTranslation()

ilADTLocalizedText::setTranslation ( string  $language,
string  $translation 
)
Parameters
string$language
string$translation

Definition at line 38 of file class.ilADTLocalizedText.php.

39 {
40 $this->translations[$language] = $translation;
41 }

Field Documentation

◆ $translations

ilADTLocalizedText::$translations = []
private

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

Referenced by getTranslations().


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