ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\ILIASObject\Properties\Translations\TranslationsTable Class Reference
+ Inheritance diagram for ILIAS\ILIASObject\Properties\Translations\TranslationsTable:
+ Collaboration diagram for ILIAS\ILIASObject\Properties\Translations\TranslationsTable:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly SystemLanguage $lng, private readonly Refinery $refinery, private readonly \ilGlobalTemplateInterface $tpl, private readonly HTTPService $http, private readonly \ilCtrl $ctrl, private Translations $translations, private readonly ObjectProperties $object_properties, URI $here_uri)
 
 runAction ()
 
 getTable ()
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Data Fields

const ACTION_EDIT = 'e'
 
const ACTION_MAKE_DEFAULT = 'md'
 
const ACTION_DELETE = 'd'
 

Private Member Functions

 getColumns ()
 
 getActions ()
 
 editTranslation ()
 
 makeDefault ()
 
 deleteTranslations ()
 
 buildEditLanguageModal (string $language_code)
 
 buildConfirmationModal (array $languages_to_delete)
 
 retrieveAffectedItemsFromQueryForDeletion ()
 
 retrieveAffectedItemsFromQuery ()
 
 sendAsync (UIComponent $response)
 

Private Attributes

const QUERY_PARAMETER_NAME_SPACE = ['obj', 'trans']
 
const TOKEN_STRING_ACTION = 'a'
 
const TOKEN_STRING_ROW_ID = 't'
 
const TOKEN_STRING_ACTON_AFFECTED_ITEMS = 'ai'
 
URLBuilder $url_builder
 
URLBuilderToken $token_action
 
URLBuilderToken $token_action_affected_items
 
URLBuilderToken $token_row_id
 
RoundtripModal $modal_with_error = null
 

Detailed Description

Definition at line 42 of file TranslationsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::__construct ( private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly SystemLanguage  $lng,
private readonly Refinery  $refinery,
private readonly \ilGlobalTemplateInterface  $tpl,
private readonly HTTPService  $http,
private readonly \ilCtrl  $ctrl,
private Translations  $translations,
private readonly ObjectProperties  $object_properties,
URI  $here_uri 
)

Member Function Documentation

◆ buildConfirmationModal()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::buildConfirmationModal ( array  $languages_to_delete)
private

Definition at line 306 of file TranslationsTable.php.

306 : InterruptiveModal
307 {
308 return $this->ui_factory->modal()->interruptive(
309 $this->lng->txt('confirm'),
310 $this->lng->txt('obj_conf_delete_lang'),
311 $this->url_builder
312 ->withParameter($this->token_action, self::ACTION_DELETE)
313 ->withParameter($this->token_action_affected_items, $languages_to_delete)
314 ->buildURI()->__toString()
315 )->withAffectedItems(
316 array_map(
317 fn(string $v): InterruptiveItem => $this->ui_factory->modal()
318 ->interruptiveItem()->standard($v, $this->lng->txt("meta_l_{$v}")),
319 $languages_to_delete
320 )
321 );
322 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ buildEditLanguageModal()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::buildEditLanguageModal ( string  $language_code)
private

Definition at line 287 of file TranslationsTable.php.

287 : RoundtripModal
288 {
289 return $this->ui_factory->modal()->roundtrip(
290 $this->lng->txt('edit_language'),
291 null,
292 $this->translations->getLaguageForCode(
293 $language_code
294 )->toForm(
295 $this->lng,
296 $this->ui_factory->input()->field(),
297 $this->refinery
298 ),
299 $this->url_builder
300 ->withParameter($this->token_action, self::ACTION_EDIT)
301 ->withParameter($this->token_action_affected_items, $language_code)
302 ->buildURI()->__toString()
303 );
304 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteTranslations()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::deleteTranslations ( )
private

Definition at line 253 of file TranslationsTable.php.

253 : void
254 {
255 if ($this->http->wrapper()->query()->retrieve(
256 $this->token_action_affected_items->getName(),
257 $this->refinery->byTrying([
258 $this->refinery->kindlyTo()->string(),
259 $this->refinery->kindlyTo()->listOf(
260 $this->refinery->kindlyTo()->string()
261 )
262 ])
263 ) === '') {
264 $this->sendAsync(
267 )
268 );
269 }
270
271 $this->object_properties->storePropertyTranslations(
272 array_reduce(
273 $this->http->wrapper()->post()->retrieve(
274 'interruptive_items',
275 $this->refinery->kindlyTo()->listOf(
276 $this->refinery->kindlyTo()->string()
277 )
278 ),
279 static fn(Translations $c, string $v): Translations => $c->withoutLanguage($v),
280 $this->translations
281 )
282 );
283 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
284 $this->ctrl->redirectByClass($this->ctrl->getCurrentClassPath());
285 }
$c
Definition: deliver.php:25
static http()
Fetches the global http state from ILIAS.

References $c, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editTranslation()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::editTranslation ( )
private

Definition at line 206 of file TranslationsTable.php.

206 : void
207 {
208 if ($this->http->wrapper()->query()->retrieve(
209 $this->token_action_affected_items->getName(),
210 $this->refinery->kindlyTo()->string()
211 ) === '') {
212 $this->sendAsync(
215 )
216 );
217 }
218
219 $modal = $this->buildEditLanguageModal(
220 $this->http->wrapper()->query()->retrieve(
221 $this->token_action_affected_items->getName(),
222 $this->refinery->kindlyTo()->string()
223 )
224 )->withRequest($this->http->request());
225 $data = $modal->getData();
226 if ($data === null) {
227 $this->modal_with_error = $modal->withOnLoad($modal->getShowSignal());
228 return;
229 }
230
231 $this->translations = $this->translations->withLanguage($data[0]);
232 $this->object_properties->storePropertyTranslations(
233 $this->translations
234 );
235
236 $this->object_properties->storePropertyTranslations(
237 $this->translations->withLanguage($data[0])
238 );
239 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
240 $this->ctrl->redirectByClass($this->ctrl->getCurrentClassPath());
241 }

References $data, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActions()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::getActions ( )
private

Definition at line 173 of file TranslationsTable.php.

173 : array
174 {
175 if ($this->translations->migrationMissing()) {
176 return [];
177 }
178 return [
179 self::ACTION_EDIT => $this->ui_factory->table()->action()->single(
180 $this->lng->txt('edit'),
181 $this->url_builder->withParameter(
182 $this->token_action,
183 self::ACTION_EDIT
184 ),
185 $this->token_row_id
186 )->withAsync(),
187 self::ACTION_MAKE_DEFAULT => $this->ui_factory->table()->action()->single(
188 $this->lng->txt('make_default_language'),
189 $this->url_builder->withParameter(
190 $this->token_action,
191 self::ACTION_MAKE_DEFAULT
192 ),
193 $this->token_row_id
194 ),
195 self::ACTION_DELETE => $this->ui_factory->table()->action()->standard(
196 $this->lng->txt('delete'),
197 $this->url_builder->withParameter(
198 $this->token_action,
199 self::ACTION_DELETE
200 ),
201 $this->token_row_id
202 )->withAsync()
203 ];
204 }

References ILIAS\Repository\lng().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::getColumns ( )
private

Definition at line 147 of file TranslationsTable.php.

147 : array
148 {
149 $cf = $this->ui_factory->table()->column();
150 $columns = [
151 'language' => $cf->text($this->lng->txt('language')),
152 ];
153 if ($this->translations->getContentTranslationActivated()) {
154 $columns['base'] = $cf->boolean(
155 $this->lng->txt('obj_base_lang'),
156 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_checked.svg', '', 'small'),
157 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_unchecked.svg', '', 'small')
158 );
159 }
160
161 return $columns + [
162 'default' => $cf->boolean(
163 $this->lng->txt('default'),
164 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_checked.svg', '', 'small'),
165 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_unchecked.svg', '', 'small')
166 ),
167 'title' => $cf->text($this->lng->txt('title')),
168 'description' => $cf->text($this->lng->txt('description')),
169 ];
170
171 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::getRows ( DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)

This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 126 of file TranslationsTable.php.

133 : \Generator {
134 foreach ($this->translations->getLanguages() as $langauge) {
135 yield $langauge->toRow($row_builder, $this->lng);
136 }
137 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTable()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::getTable ( )

Definition at line 109 of file TranslationsTable.php.

109 : array
110 {
111 $content = [];
112 if ($this->modal_with_error !== null) {
113 $content[] = $this->modal_with_error;
114 }
115
116 $content[] = $this->ui_factory->table()->data(
117 $this,
118 $this->lng->txt('available_languages'),
119 $this->getColumns()
120 )->withActions($this->getActions())
121 ->withRequest($this->http->request());
122
123 return $content;
124 }

References ILIAS\ILIASObject\Properties\Translations\TranslationsTable\$modal_with_error, ILIAS\ILIASObject\Properties\Translations\TranslationsTable\getActions(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 139 of file TranslationsTable.php.

142 : ?int {
143 return count($this->translations->getLanguages());
144 }

◆ makeDefault()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::makeDefault ( )
private

Definition at line 243 of file TranslationsTable.php.

243 : void
244 {
245 $this->translations = $this->translations->withDefaultLanguage(
247 );
248 $this->object_properties->storePropertyTranslations(
249 $this->translations
250 );
251 }

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

+ Here is the caller graph for this function:

◆ retrieveAffectedItemsFromQuery()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::retrieveAffectedItemsFromQuery ( )
private

Definition at line 338 of file TranslationsTable.php.

338 : array
339 {
340 $affected_items = [];
341 if ($this->http->wrapper()->query()->has($this->token_row_id->getName())) {
342 $affected_items = $this->http->wrapper()->query()->retrieve(
343 $this->token_row_id->getName(),
344 $this->refinery->byTrying(
345 [
346 $this->refinery->container()->mapValues(
347 $this->refinery->kindlyTo()->string()
348 ),
349 $this->refinery->always([])
350 ]
351 )
352 );
353 }
354 if ($affected_items === []) {
355 $this->sendAsync(
356 $this->ui_factory->messageBox()->failure(
357 $this->lng->txt('no_checkbox')
358 )
359 );
360 }
361
362 return $affected_items;
363 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ retrieveAffectedItemsFromQueryForDeletion()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::retrieveAffectedItemsFromQueryForDeletion ( )
private

Definition at line 324 of file TranslationsTable.php.

324 : array
325 {
326 $affected_items = $this->retrieveAffectedItemsFromQuery();
327 if (in_array($this->translations->getDefaultLanguage(), $affected_items)
328 || in_array($this->translations->getBaseLanguage(), $affected_items)) {
329 $this->sendAsync(
330 $this->ui_factory->messageBox()->failure(
331 $this->lng->txt('default_base_lang_not_deletable')
332 )
333 );
334 }
335 return $affected_items;
336 }

◆ runAction()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::runAction ( )

Definition at line 88 of file TranslationsTable.php.

88 : void
89 {
90 $action = $this->http->wrapper()->query()->retrieve(
91 $this->token_action->getName(),
92 $this->refinery->byTrying([
93 $this->refinery->kindlyTo()->string(),
94 $this->refinery->always('')
95 ])
96 );
97
98 if ($action === '') {
99 return;
100 }
101
102 match ($action) {
103 self::ACTION_EDIT => $this->editTranslation(),
104 self::ACTION_MAKE_DEFAULT => $this->makeDefault(),
105 self::ACTION_DELETE => $this->deleteTranslations()
106 };
107 }

References ILIAS\ILIASObject\Properties\Translations\TranslationsTable\deleteTranslations(), ILIAS\ILIASObject\Properties\Translations\TranslationsTable\editTranslation(), ILIAS\FileDelivery\http(), and ILIAS\ILIASObject\Properties\Translations\TranslationsTable\makeDefault().

+ Here is the call graph for this function:

◆ sendAsync()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::sendAsync ( UIComponent  $response)
private

Definition at line 365 of file TranslationsTable.php.

365 : void
366 {
367 $this->http->saveResponse(
368 $this->http->response()->withBody(
370 $this->ui_renderer->renderAsync($response)
371 )
372 )
373 );
374 $this->http->sendResponse();
375 $this->http->close();
376 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
$response
Definition: xapitoken.php:93

References $response, and ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

Field Documentation

◆ $modal_with_error

RoundtripModal ILIAS\ILIASObject\Properties\Translations\TranslationsTable::$modal_with_error = null
private

◆ $token_action

URLBuilderToken ILIAS\ILIASObject\Properties\Translations\TranslationsTable::$token_action
private

◆ $token_action_affected_items

URLBuilderToken ILIAS\ILIASObject\Properties\Translations\TranslationsTable::$token_action_affected_items
private

◆ $token_row_id

URLBuilderToken ILIAS\ILIASObject\Properties\Translations\TranslationsTable::$token_row_id
private

◆ $url_builder

URLBuilder ILIAS\ILIASObject\Properties\Translations\TranslationsTable::$url_builder
private

◆ ACTION_DELETE

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::ACTION_DELETE = 'd'

Definition at line 51 of file TranslationsTable.php.

◆ ACTION_EDIT

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::ACTION_EDIT = 'e'

Definition at line 49 of file TranslationsTable.php.

◆ ACTION_MAKE_DEFAULT

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::ACTION_MAKE_DEFAULT = 'md'

Definition at line 50 of file TranslationsTable.php.

◆ QUERY_PARAMETER_NAME_SPACE

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::QUERY_PARAMETER_NAME_SPACE = ['obj', 'trans']
private

Definition at line 44 of file TranslationsTable.php.

◆ TOKEN_STRING_ACTION

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::TOKEN_STRING_ACTION = 'a'
private

Definition at line 45 of file TranslationsTable.php.

◆ TOKEN_STRING_ACTON_AFFECTED_ITEMS

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::TOKEN_STRING_ACTON_AFFECTED_ITEMS = 'ai'
private

Definition at line 47 of file TranslationsTable.php.

◆ TOKEN_STRING_ROW_ID

const ILIAS\ILIASObject\Properties\Translations\TranslationsTable::TOKEN_STRING_ROW_ID = 't'
private

Definition at line 46 of file TranslationsTable.php.


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