ILIAS  release_8 Revision v8.24
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 $a_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 (?stdClass $a_std)
 @inheritDoc More...
 
- Public Member Functions inherited from ilADTText
 reset ()
 Init property defaults. More...
 
 setText (?string $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 ()
 
 getCheckSum ()
 Get unique checksum. More...
 
 exportStdClass ()
 Export value as stdClass. More...
 
 importStdClass (?stdClass $a_std)
 Import value from stdClass. More...
 
- Public Member Functions inherited from ilADT
 __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...
 

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
 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)
 

Private Attributes

array $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
string $value
 
- Protected Attributes inherited from ilADT
ilADTDefinition $definition
 
ilLanguage $lng
 
array $validation_errors = []
 

Detailed Description

Member Function Documentation

◆ equals()

ilADTLocalizedText::equals ( ilADT  $a_adt)

@inheritDoc

Reimplemented from ilADTText.

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

61 : ?bool
62 {
63 if (!$this->getDefinition()->isComparableTo($a_adt)) {
64 return null;
65 }
66 if ($this->getTranslations() != count($a_adt->getTranslations())) {
67 return false;
68 }
69 foreach ($a_adt->getTranslations() as $key => $value) {
70 if (!isset($this->getTranslations()[$key])) {
71 return false;
72 }
73 if (!strcmp($this->getTranslations()[$key], $value)) {
74 return false;
75 }
76 }
77 return true;
78 }
string $value
getDefinition()
Get definition.
Definition: class.ilADT.php:92
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, ilADTText\$value, ilADT\getDefinition(), and getTranslations().

+ Here is the call graph for this function:

◆ exportStdClass()

ilADTLocalizedText::exportStdClass ( )

@inheritDoc

Reimplemented from ilADTText.

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

125 : ?stdClass
126 {
127 if (!$this->isNull()) {
128 $obj = new stdClass();
129 $obj->translations = $this->getTranslations();
130 return $obj;
131 }
132 return null;
133 }

References getTranslations(), and isNull().

+ Here is the call graph for this function:

◆ getCheckSum()

ilADTLocalizedText::getCheckSum ( )

@inheritDoc

Reimplemented from ilADTText.

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

114 : ?string
115 {
116 if (!$this->isNull()) {
117 return md5(serialize($this->getTranslations()));
118 }
119 return null;
120 }

References getTranslations(), and isNull().

+ Here is the call graph for this function:

◆ getTextForLanguage()

ilADTLocalizedText::getTextForLanguage ( string  $language)

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

29 : string
30 {
31 if (array_key_exists($language, $this->getTranslations()) && strlen($this->getTranslations()[$language])) {
32 return $this->getTranslations()[$language];
33 }
34 return (string) $this->getText();
35 }

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

+ Here is the call graph for this function:

◆ getTranslations()

ilADTLocalizedText::getTranslations ( )
Returns
array

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

40 : array
41 {
43 }

References $translations.

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

+ Here is the caller graph for this function:

◆ importStdClass()

ilADTLocalizedText::importStdClass ( ?stdClass  $a_std)

@inheritDoc

Reimplemented from ilADTText.

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

138 : void
139 {
140 if (is_object($a_std)) {
141 $this->translations = $a_std->translations;
142 }
143 }

◆ isLarger()

ilADTLocalizedText::isLarger ( ilADT  $a_adt)

@inheritDoc

Reimplemented from ilADTText.

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

83 : ?bool
84 {
85 return null;
86 }

◆ isNull()

ilADTLocalizedText::isNull ( )

@inheritDoc

Reimplemented from ilADTText.

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

99 : bool
100 {
101 $has_translation = false;
102 foreach ($this->getTranslations() as $translation) {
103 if ($translation !== '') {
104 $has_translation = true;
105 break;
106 }
107 }
108 return !$this->getLength() && !$has_translation;
109 }

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

Referenced by exportStdClass(), and getCheckSum().

+ 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 91 of file class.ilADTLocalizedText.php.

91 : ?bool
92 {
93 return null;
94 }

◆ isValidDefinition()

ilADTLocalizedText::isValidDefinition ( ilADTDefinition  $a_def)
protected

@inheritDoc

Reimplemented from ilADTText.

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

53 : bool
54 {
55 return $a_def instanceof ilADTLocalizedTextDefinition;
56 }

◆ setTranslation()

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

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

45 : void
46 {
47 $this->translations[$language] = $translation;
48 }

Field Documentation

◆ $translations

array ilADTLocalizedText::$translations = []
private

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

Referenced by getTranslations().


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