ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilAdvancedMDRecordTranslations Class Reference

Class ilAdvancedMDRecordTranslation. More...

+ Collaboration diagram for ilAdvancedMDRecordTranslations:

Public Member Functions

 getDefaultLanguage ()
 
 getRecordId ()
 
 isConfigured (string $lang_key)
 
 getTranslation (string $lang_key)
 
 getTranslations ()
 array<string, ilAdvancedMDRecordTranslation> More...
 
 getDefaultTranslation ()
 
 cloneRecord (int $new_record_id)
 
 addTranslationEntry (string $language_code, bool $default=false)
 
 updateDefault (string $default)
 
 getFormTranslationInfo (string $active_language)
 
 modifyTranslationInfoForTitle (ilPropertyFormGUI $form, ilTextInputGUI $title, string $active_language)
 
 modifyTranslationInfoForDescription (ilPropertyFormGUI $form, ilTextAreaInputGUI $description, string $active_language)
 
 updateTranslations (string $active_language, string $title, string $description)
 
 getTitleForLanguage (string $language)
 
 getDescriptionForLanguage (string $language)
 
 toXML (ilXmlWriter $writer)
 

Static Public Member Functions

static getInstanceByRecordId (int $record_id)
 

Private Member Functions

 __construct (int $record_id)
 
 read ()
 

Private Attributes

int $record_id
 
ilAdvancedMDRecord $record
 
 $translations = []
 
string $default_language = ''
 
ilDBInterface $db
 
ilLanguage $lng
 

Static Private Attributes

static $instances = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDRecordTranslations::__construct ( int  $record_id)
private

Definition at line 44 of file class.ilAdvancedMDRecordTranslations.php.

References $DIC, $record_id, ILIAS\Repository\lng(), and read().

45  {
46  global $DIC;
47 
48  $this->db = $DIC->database();
49  $this->lng = $DIC->language();
50  $this->lng->loadLanguageModule('meta');
51 
52  $this->record_id = $record_id;
53  $this->read();
54  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ addTranslationEntry()

ilAdvancedMDRecordTranslations::addTranslationEntry ( string  $language_code,
bool  $default = false 
)

Definition at line 133 of file class.ilAdvancedMDRecordTranslations.php.

133  : void
134  {
135  $this->translations[$language_code] = new ilAdvancedMDRecordTranslation(
136  $this->record_id,
137  '',
138  '',
139  $language_code,
140  $default
141  );
142  $this->translations[$language_code]->insert();
143  }
Class ilAdvancedMDRecordTranslation.

◆ cloneRecord()

ilAdvancedMDRecordTranslations::cloneRecord ( int  $new_record_id)

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

References getTranslations().

105  : void
106  {
107  foreach ($this->getTranslations() as $recordTranslation) {
108  $recordTranslation->setRecordId($new_record_id);
109  $recordTranslation->insert();
110  }
111  }
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
+ Here is the call graph for this function:

◆ getDefaultLanguage()

ilAdvancedMDRecordTranslations::getDefaultLanguage ( )

Definition at line 64 of file class.ilAdvancedMDRecordTranslations.php.

References $default_language.

Referenced by toXML().

64  : string
65  {
67  }
+ Here is the caller graph for this function:

◆ getDefaultTranslation()

ilAdvancedMDRecordTranslations::getDefaultTranslation ( )

Definition at line 95 of file class.ilAdvancedMDRecordTranslations.php.

References $default_language, getTranslations(), and null.

Referenced by modifyTranslationInfoForDescription(), and modifyTranslationInfoForTitle().

96  {
97  foreach ($this->getTranslations() as $translation) {
98  if ($translation->getLangKey() == $this->default_language) {
99  return $translation;
100  }
101  }
102  return null;
103  }
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilAdvancedMDRecordTranslation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescriptionForLanguage()

ilAdvancedMDRecordTranslations::getDescriptionForLanguage ( string  $language)

Definition at line 229 of file class.ilAdvancedMDRecordTranslations.php.

References getTranslation().

229  : string
230  {
231  if ($this->getTranslation($language) && strlen($this->getTranslation($language)->getDescription())) {
232  return $this->getTranslation($language)->getDescription();
233  }
234  return $this->record->getDescription();
235  }
+ Here is the call graph for this function:

◆ getFormTranslationInfo()

ilAdvancedMDRecordTranslations::getFormTranslationInfo ( string  $active_language)

Definition at line 159 of file class.ilAdvancedMDRecordTranslations.php.

References $default_language, $txt, and ILIAS\Repository\lng().

159  : string
160  {
161  if (count($this->translations) <= 1) {
162  return '';
163  }
164  $txt = '';
165  $txt = $this->lng->txt('md_adv_int_current') . ' ' . $this->lng->txt('meta_l_' . $active_language);
166  $txt .= ', ';
167  foreach ($this->translations as $translation) {
168  if ($translation->getLangKey() == $this->default_language) {
169  $txt .= ($this->lng->txt('md_adv_int_default') . ' ' . $this->lng->txt('meta_l_' . $translation->getLangKey()));
170  break;
171  }
172  }
173  return $txt;
174  }
$txt
Definition: error.php:31
+ Here is the call graph for this function:

◆ getInstanceByRecordId()

static ilAdvancedMDRecordTranslations::getInstanceByRecordId ( int  $record_id)
static

◆ getRecordId()

ilAdvancedMDRecordTranslations::getRecordId ( )

Definition at line 69 of file class.ilAdvancedMDRecordTranslations.php.

References $record_id.

Referenced by read().

+ Here is the caller graph for this function:

◆ getTitleForLanguage()

ilAdvancedMDRecordTranslations::getTitleForLanguage ( string  $language)

Definition at line 221 of file class.ilAdvancedMDRecordTranslations.php.

References ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), and getTranslation().

221  : string
222  {
223  if ($this->getTranslation($language) && strlen($this->getTranslation($language)->getTitle())) {
224  return $this->getTranslation($language)->getTitle();
225  }
226  return $this->record->getTitle();
227  }
+ Here is the call graph for this function:

◆ getTranslation()

ilAdvancedMDRecordTranslations::getTranslation ( string  $lang_key)

Definition at line 79 of file class.ilAdvancedMDRecordTranslations.php.

References isConfigured(), and null.

Referenced by getDescriptionForLanguage(), getTitleForLanguage(), modifyTranslationInfoForDescription(), modifyTranslationInfoForTitle(), and updateTranslations().

80  {
81  if (!$this->isConfigured($lang_key)) {
82  return null;
83  }
84  return $this->translations[$lang_key];
85  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ilAdvancedMDRecordTranslation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTranslations()

ilAdvancedMDRecordTranslations::getTranslations ( )

array<string, ilAdvancedMDRecordTranslation>

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

References $translations.

Referenced by cloneRecord(), getDefaultTranslation(), toXML(), and updateDefault().

+ Here is the caller graph for this function:

◆ isConfigured()

ilAdvancedMDRecordTranslations::isConfigured ( string  $lang_key)

Definition at line 74 of file class.ilAdvancedMDRecordTranslations.php.

Referenced by getTranslation().

74  : bool
75  {
76  return isset($this->translations[$lang_key]);
77  }
+ Here is the caller graph for this function:

◆ modifyTranslationInfoForDescription()

ilAdvancedMDRecordTranslations::modifyTranslationInfoForDescription ( ilPropertyFormGUI  $form,
ilTextAreaInputGUI  $description,
string  $active_language 
)

Definition at line 193 of file class.ilAdvancedMDRecordTranslations.php.

References getDefaultTranslation(), getTranslation(), ilFormPropertyGUI\setInfo(), and ilTextAreaInputGUI\setValue().

197  : void {
198  if (count($this->translations) <= 1) {
199  return;
200  }
201  $default = $this->getDefaultTranslation();
202  if ($default->getLangKey() != $active_language) {
203  $description->setInfo($default->getLangKey() . ': ' . $default->getDescription());
204  }
205  if ($this->getTranslation($active_language) instanceof ilAdvancedMDRecordTranslation) {
206  $description->setValue($this->getTranslation($active_language)->getDescription());
207  }
208  }
Class ilAdvancedMDRecordTranslation.
+ Here is the call graph for this function:

◆ modifyTranslationInfoForTitle()

ilAdvancedMDRecordTranslations::modifyTranslationInfoForTitle ( ilPropertyFormGUI  $form,
ilTextInputGUI  $title,
string  $active_language 
)

Definition at line 176 of file class.ilAdvancedMDRecordTranslations.php.

References getDefaultTranslation(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), getTranslation(), ilFormPropertyGUI\setInfo(), and ilTextInputGUI\setValue().

180  : void {
181  if (count($this->translations) <= 1) {
182  return;
183  }
184  $default = $this->getDefaultTranslation();
185  if ($default->getLangKey() != $active_language) {
186  $title->setInfo($default->getLangKey() . ': ' . $default->getTitle());
187  }
188  if ($this->getTranslation($active_language) instanceof ilAdvancedMDRecordTranslation) {
189  $title->setValue($this->getTranslation($active_language)->getTitle());
190  }
191  }
Class ilAdvancedMDRecordTranslation.
+ Here is the call graph for this function:

◆ read()

ilAdvancedMDRecordTranslations::read ( )
private

Definition at line 113 of file class.ilAdvancedMDRecordTranslations.php.

References $res, ilAdvancedMDRecord\_getInstanceByRecordId(), ilDBConstants\FETCHMODE_OBJECT, getRecordId(), ilDBConstants\T_INTEGER, and ilAdvancedMDRecordTranslation\TABLE_NAME.

Referenced by __construct().

113  : void
114  {
115  $query = 'select * from ' . ilAdvancedMDRecordTranslation::TABLE_NAME . ' ' .
116  'where record_id = ' . $this->db->quote($this->getRecordId(), ilDBConstants::T_INTEGER);
117  $res = $this->db->query($query);
118 
119  $this->translations = [];
120  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
121  $this->translations[(string) $row->lang_code] = new ilAdvancedMDRecordTranslation(
122  (int) $row->record_id,
123  (string) $row->title,
124  (string) $row->description,
125  (string) $row->lang_code
126  );
127  }
128 
129  $this->record = ilAdvancedMDRecord::_getInstanceByRecordId($this->record_id);
130  $this->default_language = $this->record->getDefaultLanguage();
131  }
$res
Definition: ltiservices.php:66
static _getInstanceByRecordId(int $a_record_id)
Class ilAdvancedMDRecordTranslation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

ilAdvancedMDRecordTranslations::toXML ( ilXmlWriter  $writer)

Definition at line 237 of file class.ilAdvancedMDRecordTranslations.php.

References getDefaultLanguage(), getTranslations(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

237  : ilXmlWriter
238  {
239  if (!count($this->getTranslations())) {
240  return $writer;
241  }
242 
243  $writer->xmlStartTag(
244  'RecordTranslations',
245  [
246  'defaultLanguage' => $this->getDefaultLanguage()
247  ]
248  );
249  foreach ($this->getTranslations() as $translation) {
250  $writer->xmlStartTag(
251  'RecordTranslation',
252  [
253  'language' => $translation->getLangKey()
254  ]
255  );
256  $writer->xmlElement('RecordTranslationTitle', [], $translation->getTitle());
257  $writer->xmlElement('RecordTranslationDescription', [], $translation->getDescription());
258  $writer->xmlEndTag('RecordTranslation');
259  }
260  $writer->xmlEndTag('RecordTranslations');
261  return $writer;
262  }
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:

◆ updateDefault()

ilAdvancedMDRecordTranslations::updateDefault ( string  $default)

Definition at line 145 of file class.ilAdvancedMDRecordTranslations.php.

References getTranslations().

145  : void
146  {
147  foreach ($this->getTranslations() as $translation) {
148  if ($translation->getLangKey() != $default) {
149  $translation->setLangDefault(false);
150  $translation->update();
151  }
152  if ($translation->getLangKey() == $default) {
153  $translation->setLangDefault(true);
154  $translation->update();
155  }
156  }
157  }
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
+ Here is the call graph for this function:

◆ updateTranslations()

ilAdvancedMDRecordTranslations::updateTranslations ( string  $active_language,
string  $title,
string  $description 
)

Definition at line 210 of file class.ilAdvancedMDRecordTranslations.php.

References getTranslation().

210  : void
211  {
212  $translation = $this->getTranslation($active_language);
213  if (!$translation instanceof ilAdvancedMDRecordTranslation) {
214  return;
215  }
216  $translation->setTitle($title);
217  $translation->setDescription($description);
218  $translation->update();
219  }
Class ilAdvancedMDRecordTranslation.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilAdvancedMDRecordTranslations::$db
private

Definition at line 41 of file class.ilAdvancedMDRecordTranslations.php.

◆ $default_language

string ilAdvancedMDRecordTranslations::$default_language = ''
private

◆ $instances

ilAdvancedMDRecordTranslations::$instances = null
staticprivate

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

◆ $lng

ilLanguage ilAdvancedMDRecordTranslations::$lng
private

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

◆ $record

ilAdvancedMDRecord ilAdvancedMDRecordTranslations::$record
private

Definition at line 32 of file class.ilAdvancedMDRecordTranslations.php.

◆ $record_id

int ilAdvancedMDRecordTranslations::$record_id
private

◆ $translations

ilAdvancedMDRecordTranslations::$translations = []
private

Definition at line 37 of file class.ilAdvancedMDRecordTranslations.php.

Referenced by getTranslations().


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