ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 
 reset ()
 Init property defaults. More...
 
 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 67 of file class.ilADTLocalizedText.php.

67 : ?bool
68 {
69 if (!$this->getDefinition()->isComparableTo($a_adt)) {
70 return null;
71 }
72 if ($this->getTranslations() != count($a_adt->getTranslations())) {
73 return false;
74 }
75 foreach ($a_adt->getTranslations() as $key => $value) {
76 if (!isset($this->getTranslations()[$key])) {
77 return false;
78 }
79 if (!strcmp($this->getTranslations()[$key], $value)) {
80 return false;
81 }
82 }
83 return true;
84 }
getDefinition()
Get definition.

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

131 : ?stdClass
132 {
133 if (!$this->isNull()) {
134 $obj = new stdClass();
135 $obj->translations = $this->getTranslations();
136 return $obj;
137 }
138 return null;
139 }

References getTranslations(), and isNull().

+ Here is the call graph for this function:

◆ getCheckSum()

ilADTLocalizedText::getCheckSum ( )

@inheritDoc

Reimplemented from ilADTText.

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

120 : ?string
121 {
122 if (!$this->isNull()) {
123 return md5(serialize($this->getTranslations()));
124 }
125 return null;
126 }

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

144 : void
145 {
146 if (is_object($a_std)) {
147 $this->translations = $a_std->translations;
148 }
149 }

◆ isLarger()

ilADTLocalizedText::isLarger ( ilADT  $a_adt)

@inheritDoc

Reimplemented from ilADTText.

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

89 : ?bool
90 {
91 return null;
92 }

◆ isNull()

ilADTLocalizedText::isNull ( )

@inheritDoc

Reimplemented from ilADTText.

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

105 : bool
106 {
107 $has_translation = false;
108 foreach ($this->getTranslations() as $translation) {
109 if ($translation !== '') {
110 $has_translation = true;
111 break;
112 }
113 }
114 return !$this->getLength() && !$has_translation;
115 }

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

97 : ?bool
98 {
99 return null;
100 }

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

◆ reset()

ilADTLocalizedText::reset ( )

Init property defaults.

Reimplemented from ilADTText.

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

58 : void
59 {
60 parent::reset();
61 $this->translations = [];
62 }

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