ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\ILIASObject\Properties\Translations\Translations Class Reference

Class handles translation mode for an object. More...

+ Collaboration diagram for ILIAS\ILIASObject\Properties\Translations\Translations:

Public Member Functions

 __construct (private readonly int $obj_id, private array $languages, private string $default_language, private ?string $base_language, private readonly bool $migration_missing=false)
 
 migrationMissing ()
 
 getObjId ()
 
 getDefaultLanguage ()
 
 withDefaultLanguage (string $default_language)
 
 getBaseLanguage ()
 
 withBaseLanguage (string $base_language)
 
 getLanguages ()
 
 getLaguageForCode (string $lang_code)
 
 withLanguage (Language $lang)
 
 withoutLanguage (string $lang)
 
 withResetLanguages ()
 
 getDefaultTitle ()
 
 withDefaultTitle (string $title)
 
 getDefaultDescription ()
 
 withDefaultDescription (string $description)
 
 getContentTranslationActivated ()
 
 withDeactivatedContentTranslation ()
 
 copy (int $obj_id)
 
 getEffectiveCOPageLang (string $lang, string $parent_type)
 

Detailed Description

Class handles translation mode for an object.

Objects may not use any translations at all

  • use translations for title/description only or
  • use translation for (the page editing) content, too.

Currently, supported by container objects and ILIAS learning modules.

Content base lang vs. default language

  • If no translation mode for the content is active no base lang will be set and no record in table obj_content_base_lng will be saved. For the title/descriptions the default will be marked by field lang_default in table object_translation.
  • If translation for content is activated a base language must be set (since consent may already exist the language of this content is defined through setting the base language. Components that use this mode will not get informed about this, so they can not internally assign existing content to the base lang
  • If translation for content is activated additionally a fallback language can be defined. Users will be presented their language, if content available otherwise the fallback language, if content is available, otherwise the base language

Definition at line 52 of file Translations.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ILIASObject\Properties\Translations\Translations::__construct ( private readonly int  $obj_id,
private array  $languages,
private string  $default_language,
private ?string  $base_language,
private readonly bool  $migration_missing = false 
)
Parameters
array$languageslist<Language>

Definition at line 58 of file Translations.php.

64  {
65  }

Member Function Documentation

◆ copy()

ILIAS\ILIASObject\Properties\Translations\Translations::copy ( int  $obj_id)

Definition at line 224 of file Translations.php.

224  : self
225  {
226  return new self(
227  $obj_id,
228  $this->languages,
229  $this->default_language,
230  $this->base_language
231  );
232  }

◆ getBaseLanguage()

ILIAS\ILIASObject\Properties\Translations\Translations::getBaseLanguage ( )

Definition at line 93 of file Translations.php.

Referenced by ilMediaPoolImportGUI\initTranslationImportForm().

93  : string
94  {
95  return $this->base_language ?? '';
96  }
+ Here is the caller graph for this function:

◆ getContentTranslationActivated()

ILIAS\ILIASObject\Properties\Translations\Translations::getContentTranslationActivated ( )

Definition at line 211 of file Translations.php.

References null.

211  : bool
212  {
213  return $this->base_language !== null;
214  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDefaultDescription()

ILIAS\ILIASObject\Properties\Translations\Translations::getDefaultDescription ( )

Definition at line 186 of file Translations.php.

References ILIAS\ILIASObject\Properties\Translations\Translations\getObjId().

Referenced by ilObjStudyProgrammeSettingsGUI\getEditSection().

186  : string
187  {
188  if ($this->default_language !== ''
189  && array_key_exists($this->default_language, $this->languages)) {
190  return $this->languages[$this->default_language]->getDescription();
191  }
192 
193  if ($this->languages === []) {
194  return \ilObject::_lookupTitle($this->getObjId());
195  }
196  return '';
197  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultLanguage()

ILIAS\ILIASObject\Properties\Translations\Translations::getDefaultLanguage ( )

Definition at line 79 of file Translations.php.

Referenced by ilObjStudyProgrammeSettingsGUI\getEditSection(), and ilLMPresentationStatus\getLMPresentationTitle().

79  : string
80  {
81  return $this->default_language;
82  }
+ Here is the caller graph for this function:

◆ getDefaultTitle()

ILIAS\ILIASObject\Properties\Translations\Translations::getDefaultTitle ( )

Definition at line 161 of file Translations.php.

References ILIAS\ILIASObject\Properties\Translations\Translations\getObjId().

Referenced by ilObject\appendCopyInfoToTranslations(), and ilObjStudyProgrammeSettingsGUI\getEditSection().

161  : string
162  {
163  if ($this->default_language !== ''
164  && array_key_exists($this->default_language, $this->languages)) {
165  return $this->languages[$this->default_language]->getTitle();
166  }
167 
168  if ($this->languages === []) {
169  return \ilObject::_lookupTitle($this->getObjId());
170  }
171  return '';
172  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEffectiveCOPageLang()

ILIAS\ILIASObject\Properties\Translations\Translations::getEffectiveCOPageLang ( string  $lang,
string  $parent_type 
)

Definition at line 234 of file Translations.php.

References $lang, ilPageObject\_exists(), ILIAS\ILIASObject\Properties\Translations\Translations\getObjId(), and null.

237  : string {
238  if ($this->base_language === null) {
239  return '-';
240  }
241 
242  $page_lang_key = $lang === $this->base_language
243  ? '-'
244  : $lang;
245 
246  if (isset($this->languages[$lang])
247  && \ilPageObject::_exists($parent_type, $this->getObjId(), $page_lang_key)) {
248  return $page_lang_key;
249  }
250 
251  if (isset($this->languages[$this->default_language])
252  && \ilPageObject::_exists($parent_type, $this->getObjId(), $this->default_language)) {
253  return $this->default_language;
254  }
255  return '-';
256  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ getLaguageForCode()

ILIAS\ILIASObject\Properties\Translations\Translations::getLaguageForCode ( string  $lang_code)

Definition at line 117 of file Translations.php.

References null.

117  : ?Language
118  {
119  return $this->languages[$lang_code] ?? null;
120  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getLanguages()

ILIAS\ILIASObject\Properties\Translations\Translations::getLanguages ( )
Returns
list<Language>

Definition at line 112 of file Translations.php.

Referenced by ilObject\appendCopyInfoToTranslations(), ilLMPresentationStatus\getLMPresentationTitle(), ilMediaPoolImportGUI\initTranslationImportForm(), ILIAS\LearningModule\Export\LMHtmlExport\resetUserLanguage(), and ILIAS\ILIASObject\Properties\Translations\CachedRepository\store().

112  : array
113  {
114  return $this->languages;
115  }
+ Here is the caller graph for this function:

◆ getObjId()

ILIAS\ILIASObject\Properties\Translations\Translations::getObjId ( )

◆ migrationMissing()

ILIAS\ILIASObject\Properties\Translations\Translations::migrationMissing ( )
Todo:
: Remove with ILIAS 12

Definition at line 70 of file Translations.php.

70  : bool
71  {
72  return $this->migration_missing;
73  }

◆ withBaseLanguage()

ILIAS\ILIASObject\Properties\Translations\Translations::withBaseLanguage ( string  $base_language)

Definition at line 98 of file Translations.php.

References null.

98  : self
99  {
100  $clone = clone $this;
101  if ($clone->base_language !== null) {
102  $clone->languages[$clone->base_language] = $clone->languages[$clone->base_language]->withBase(false);
103  }
104  $clone->languages[$base_language] = $clone->languages[$base_language]->withBase(true);
105  $clone->base_language = $base_language;
106  return $clone;
107  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ withDeactivatedContentTranslation()

ILIAS\ILIASObject\Properties\Translations\Translations::withDeactivatedContentTranslation ( )

Definition at line 216 of file Translations.php.

References null.

216  : self
217  {
218  $clone = clone $this;
219  $clone->languages[$clone->base_language] = $clone->languages[$this->base_language]->withBase(false);
220  $clone->base_language = null;
221  return $clone;
222  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ withDefaultDescription()

ILIAS\ILIASObject\Properties\Translations\Translations::withDefaultDescription ( string  $description)

Definition at line 199 of file Translations.php.

199  : self
200  {
201  if ($this->default_language === ''
202  || !isset($this->languages[$this->default_language])) {
203  return $this;
204  }
205 
206  $clone = clone $this;
207  $clone->languages[$clone->default_language] = $clone->languages[$clone->default_language]->withDescription($description);
208  return $clone;
209  }

◆ withDefaultLanguage()

ILIAS\ILIASObject\Properties\Translations\Translations::withDefaultLanguage ( string  $default_language)

Definition at line 84 of file Translations.php.

84  : self
85  {
86  $clone = clone $this;
87  $clone->languages[$clone->default_language] = $clone->languages[$clone->default_language]->withDefault(false);
88  $clone->languages[$default_language] = $clone->languages[$default_language]->withDefault(true);
89  $clone->default_language = $default_language;
90  return $clone;
91  }

◆ withDefaultTitle()

ILIAS\ILIASObject\Properties\Translations\Translations::withDefaultTitle ( string  $title)

Definition at line 174 of file Translations.php.

Referenced by ilCourseXMLParser\handlerEndTag().

174  : self
175  {
176  if ($this->default_language === ''
177  || !isset($this->languages[$this->default_language])) {
178  return $this;
179  }
180 
181  $clone = clone $this;
182  $clone->languages[$clone->default_language] = $clone->languages[$clone->default_language]->withTitle($title);
183  return $clone;
184  }
+ Here is the caller graph for this function:

◆ withLanguage()

ILIAS\ILIASObject\Properties\Translations\Translations::withLanguage ( Language  $lang)

Definition at line 122 of file Translations.php.

References $lang, ILIAS\ILIASObject\Properties\Translations\Language\getLanguageCode(), ILIAS\ILIASObject\Properties\Translations\Language\isBase(), ILIAS\ILIASObject\Properties\Translations\Language\isDefault(), and null.

Referenced by ilObject\appendCopyInfoToTranslations().

122  : self
123  {
124  $clone = $this;
125  $clone->languages[$lang->getLanguageCode()] = $lang;
126  if ($lang->isBase() && $this->base_language !== $lang->getLanguageCode()) {
127  if ($this->base_language !== null) {
128  $clone->languages[$clone->base_language] = $clone->languages[$clone->base_language]->withBase(false);
129  }
130  $clone->base_language = $lang->getLanguageCode();
131  }
132 
133  if ($lang->isDefault() && $this->default_language !== $lang->getLanguageCode()) {
134  if ($this->default_language !== '') {
135  $clone->languages[$clone->default_language] = $this->languages[$clone->default_language]->withDefault(false);
136  }
137  $clone->default_language = $lang->getLanguageCode();
138  }
139 
140  return $clone;
141  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withoutLanguage()

ILIAS\ILIASObject\Properties\Translations\Translations::withoutLanguage ( string  $lang)

Definition at line 143 of file Translations.php.

Referenced by ILIAS\ILIASObject\Properties\Translations\TranslationsTable\deleteTranslations().

143  : self
144  {
145  if ($lang === $this->base_language) {
146  return $this;
147  }
148 
149  $clone = $this;
150  unset($clone->languages[$lang]);
151  return $clone;
152  }
$lang
Definition: xapiexit.php:25
+ Here is the caller graph for this function:

◆ withResetLanguages()

ILIAS\ILIASObject\Properties\Translations\Translations::withResetLanguages ( )

Definition at line 154 of file Translations.php.

154  : self
155  {
156  $clone = clone $this;
157  $clone->languages = [];
158  return $clone;
159  }

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