ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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)
 
 orderLanguages (array $languages, Order $order)
 

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 314 of file TranslationsTable.php.

314 : InterruptiveModal
315 {
316 return $this->ui_factory->modal()->interruptive(
317 $this->lng->txt('confirm'),
318 $this->lng->txt('obj_conf_delete_lang'),
319 $this->url_builder
320 ->withParameter($this->token_action, self::ACTION_DELETE)
321 ->withParameter($this->token_action_affected_items, $languages_to_delete)
322 ->buildURI()->__toString()
323 )->withAffectedItems(
324 array_map(
325 fn(string $v): InterruptiveItem => $this->ui_factory->modal()
326 ->interruptiveItem()->standard($v, $this->lng->txt("meta_l_{$v}")),
327 $languages_to_delete
328 )
329 );
330 }

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 295 of file TranslationsTable.php.

295 : RoundtripModal
296 {
297 return $this->ui_factory->modal()->roundtrip(
298 $this->lng->txt('edit_language'),
299 null,
300 $this->translations->getLaguageForCode(
301 $language_code
302 )->toForm(
303 $this->lng,
304 $this->ui_factory->input()->field(),
305 $this->refinery
306 ),
307 $this->url_builder
308 ->withParameter($this->token_action, self::ACTION_EDIT)
309 ->withParameter($this->token_action_affected_items, $language_code)
310 ->buildURI()->__toString()
311 );
312 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteTranslations()

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

Definition at line 261 of file TranslationsTable.php.

261 : void
262 {
263 if ($this->http->wrapper()->query()->retrieve(
264 $this->token_action_affected_items->getName(),
265 $this->refinery->byTrying([
266 $this->refinery->kindlyTo()->string(),
267 $this->refinery->kindlyTo()->listOf(
268 $this->refinery->kindlyTo()->string()
269 )
270 ])
271 ) === '') {
272 $this->sendAsync(
275 )
276 );
277 }
278
279 $this->object_properties->storePropertyTranslations(
280 array_reduce(
281 $this->http->wrapper()->post()->retrieve(
282 'interruptive_items',
283 $this->refinery->kindlyTo()->listOf(
284 $this->refinery->kindlyTo()->string()
285 )
286 ),
287 static fn(Translations $c, string $v): Translations => $c->withoutLanguage($v),
288 $this->translations
289 )
290 );
291 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
292 $this->ctrl->redirectByClass($this->ctrl->getCurrentClassPath());
293 }
static http()
Fetches the global http state from ILIAS.

References Vendor\Package\$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 211 of file TranslationsTable.php.

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

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 178 of file TranslationsTable.php.

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

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 152 of file TranslationsTable.php.

152 : array
153 {
154 $cf = $this->ui_factory->table()->column();
155 $columns = [
156 Language::KEY_LANGUAGE => $cf->text($this->lng->txt('language')),
157 ];
158 if ($this->translations->getContentTranslationActivated()) {
159 $columns[Language::KEY_BASE] = $cf->boolean(
160 $this->lng->txt('obj_base_lang'),
161 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_checked.svg', '', 'small'),
162 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_unchecked.svg', '', 'small')
163 );
164 }
165
166 return $columns + [
167 Language::KEY_DEFAULT => $cf->boolean(
168 $this->lng->txt('default'),
169 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_checked.svg', '', 'small'),
170 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_unchecked.svg', '', 'small')
171 ),
172 Language::KEY_TITLE => $cf->text($this->lng->txt('title')),
173 Language::KEY_DESCRIPTION => $cf->text($this->lng->txt('description')),
174 ];
175
176 }

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,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $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.

134 : \Generator {
135 foreach ($this->orderLanguages(
136 $this->translations->getLanguages(),
137 $order
138 ) as $langauge) {
139 yield $langauge->toRow($row_builder, $this->lng);
140 }
141 }

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 ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $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 143 of file TranslationsTable.php.

147 : ?int {
148 return count($this->translations->getLanguages());
149 }

◆ makeDefault()

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

Definition at line 248 of file TranslationsTable.php.

248 : void
249 {
250 $this->translations = $this->translations->withDefaultLanguage(
252 );
253 $this->object_properties->storePropertyTranslations(
254 $this->translations
255 );
256
257 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
258 $this->ctrl->redirectByClass($this->ctrl->getCurrentClassPath());
259 }

References ILIAS\Repository\ctrl(), 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:

◆ orderLanguages()

ILIAS\ILIASObject\Properties\Translations\TranslationsTable::orderLanguages ( array  $languages,
Order  $order 
)
private

Definition at line 386 of file TranslationsTable.php.

389 : array {
390 return $order->join(
391 $languages,
392 function (array $langs, string $field, string $direction): array {
393 usort(
394 $langs,
395 fn(Language $a, Language $b) => $a->getDisplayValueForKey($this->lng, $field)
396 <=> $b->getDisplayValueForKey($this->lng, $field)
397 );
398
399 if ($direction === 'DESC') {
400 return array_reverse($langs);
401 }
402
403 return $langs;
404 }
405 );
406 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

◆ retrieveAffectedItemsFromQuery()

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

Definition at line 346 of file TranslationsTable.php.

346 : array
347 {
348 $affected_items = [];
349 if ($this->http->wrapper()->query()->has($this->token_row_id->getName())) {
350 $affected_items = $this->http->wrapper()->query()->retrieve(
351 $this->token_row_id->getName(),
352 $this->refinery->byTrying(
353 [
354 $this->refinery->container()->mapValues(
355 $this->refinery->kindlyTo()->string()
356 ),
357 $this->refinery->always([])
358 ]
359 )
360 );
361 }
362 if ($affected_items === []) {
363 $this->sendAsync(
364 $this->ui_factory->messageBox()->failure(
365 $this->lng->txt('no_checkbox')
366 )
367 );
368 }
369
370 return $affected_items;
371 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ retrieveAffectedItemsFromQueryForDeletion()

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

Definition at line 332 of file TranslationsTable.php.

332 : array
333 {
334 $affected_items = $this->retrieveAffectedItemsFromQuery();
335 if (in_array($this->translations->getDefaultLanguage(), $affected_items)
336 || in_array($this->translations->getBaseLanguage(), $affected_items)) {
337 $this->sendAsync(
338 $this->ui_factory->messageBox()->failure(
339 $this->lng->txt('default_base_lang_not_deletable')
340 )
341 );
342 }
343 return $affected_items;
344 }

◆ 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 373 of file TranslationsTable.php.

373 : void
374 {
375 $this->http->saveResponse(
376 $this->http->response()->withBody(
378 $this->ui_renderer->renderAsync($response)
379 )
380 )
381 );
382 $this->http->sendResponse();
383 $this->http->close();
384 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
$response
Definition: xapitoken.php:92

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: