ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMMItemTranslationRepository Class Reference
+ Inheritance diagram for ilMMItemTranslationRepository:
+ Collaboration diagram for ilMMItemTranslationRepository:

Public Member Functions

 __construct (private ilDBInterface $db)
 
 store (Translations $translations)
 
 get (TranslatableItem $item)
 
 blank (TranslatableItem $item, string $language_code, string $translation)
 
 reset ()
 
 retrieveCurrent (Pons $pons)
 
 store (Translations $translations)
 
 get (TranslatableItem $item)
 
 blank (TranslatableItem $item, string $language_code, string $translation)
 
 reset ()
 
 retrieveCurrent (Pons $pons)
 

Private Member Functions

 has (string $identification, string $language_code)
 
 storeSingleTranslation (string $identification, string $language_code, string $translation)
 

Private Attributes

const TABLE_NAME = 'il_mm_translation'
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemTranslationRepository::__construct ( private ilDBInterface  $db)

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

39 {
40 }

Member Function Documentation

◆ blank()

ilMMItemTranslationRepository::blank ( TranslatableItem  $item,
string  $language_code,
string  $translation 
)

◆ get()

ilMMItemTranslationRepository::get ( TranslatableItem  $item)

Implements ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationsRepository.

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

96 {
97 $identification = $item->getId();
98 $r = $this->db->queryF(
99 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE identification = %s',
100 ['text'],
101 [$identification]
102 );
103 $translations = [];
104 while ($row = $this->db->fetchAssoc($r)) {
105 if (empty($row['translation'])) {
106 continue;
107 }
108
109 $translations[] = new TranslationDTO(
110 $row['identification'],
111 $row['language_key'],
112 $row['translation']
113 );
114 }
115
116 return new Translations('en', $item, ...$translations);
117 }

References ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations\getId().

+ Here is the call graph for this function:

◆ has()

ilMMItemTranslationRepository::has ( string  $identification,
string  $language_code 
)
private

Definition at line 55 of file class.ilMMItemTranslationRepository.php.

55 : bool
56 {
57 $language_identification = "{$identification}|$language_code";
58
59 return $this->db->queryF(
60 'SELECT id FROM ' . self::TABLE_NAME . ' WHERE id = %s',
61 ['text'],
62 [$language_identification]
63 )->numRows() > 0;
64 }

◆ reset()

ilMMItemTranslationRepository::reset ( )

Implements ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationsRepository.

Definition at line 128 of file class.ilMMItemTranslationRepository.php.

128 : void
129 {
130 $this->db->manipulate('TRUNCATE TABLE ' . self::TABLE_NAME);
131 }

◆ retrieveCurrent()

ilMMItemTranslationRepository::retrieveCurrent ( Pons  $pons)

Implements ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationsRepository.

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

134 {
135 $pons->tabs()->structure()->current();
136
137 $id = $pons->in()->getFirstFromRequest('top_id');
138 return (new ilMMItemRepository())->getItemFacadeForIdentificationString($id);
139 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, ILIAS\GlobalScreen\GUI\Pons\in(), and ILIAS\GlobalScreen\GUI\Pons\tabs().

+ Here is the call graph for this function:

◆ store()

ilMMItemTranslationRepository::store ( Translations  $translations)

Implements ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationsRepository.

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

43 {
44 foreach ($translations->get() as $translation) {
46 $translations->getId(),
47 $translation->getLanguageCode(),
48 $translation->getTranslation()
49 );
50 }
51
52 return $translations;
53 }
storeSingleTranslation(string $identification, string $language_code, string $translation)

References ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations\get(), ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations\getId(), and storeSingleTranslation().

+ Here is the call graph for this function:

◆ storeSingleTranslation()

ilMMItemTranslationRepository::storeSingleTranslation ( string  $identification,
string  $language_code,
string  $translation 
)
private

Definition at line 66 of file class.ilMMItemTranslationRepository.php.

70 : void {
71 $language_identification = "{$identification}|$language_code";
72 if ($this->has($identification, $language_code)) {
73 $this->db->update(
74 self::TABLE_NAME,
75 [
76 'translation' => ['text', $translation],
77 ],
78 [
79 'id' => ['text', $language_identification]
80 ]
81 );
82 } else {
83 $this->db->insert(
84 self::TABLE_NAME,
85 [
86 'id' => ['text', $language_identification],
87 'identification' => ['text', $identification],
88 'translation' => ['text', $translation],
89 'language_key' => ['text', $language_code],
90 ]
91 );
92 }
93 }
has(string $identification, string $language_code)

Referenced by store().

+ Here is the caller graph for this function:

Field Documentation

◆ TABLE_NAME

const ilMMItemTranslationRepository::TABLE_NAME = 'il_mm_translation'
private

Definition at line 36 of file class.ilMMItemTranslationRepository.php.


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