ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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)
 

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

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

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

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

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteTranslations()

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

Definition at line 255 of file TranslationsTable.php.

255 : void
256 {
257 if ($this->http->wrapper()->query()->retrieve(
258 $this->token_action_affected_items->getName(),
259 $this->refinery->byTrying([
260 $this->refinery->kindlyTo()->string(),
261 $this->refinery->kindlyTo()->listOf(
262 $this->refinery->kindlyTo()->string()
263 )
264 ])
265 ) === '') {
266 $this->sendAsync(
269 )
270 );
271 }
272
273 $this->object_properties->storePropertyTranslations(
274 array_reduce(
275 $this->http->wrapper()->post()->retrieve(
276 'interruptive_items',
277 $this->refinery->kindlyTo()->listOf(
278 $this->refinery->kindlyTo()->string()
279 )
280 ),
281 static fn(Translations $c, string $v): Translations => $c->withoutLanguage($v),
282 $this->translations
283 )
284 );
285 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
286 $this->ctrl->redirectByClass($this->ctrl->getCurrentClassPath());
287 }
$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 208 of file TranslationsTable.php.

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

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

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

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

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

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->translations->getLanguages() as $langauge) {
136 yield $langauge->toRow($row_builder, $this->lng);
137 }
138 }

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

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

◆ makeDefault()

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

Definition at line 245 of file TranslationsTable.php.

245 : void
246 {
247 $this->translations = $this->translations->withDefaultLanguage(
249 );
250 $this->object_properties->storePropertyTranslations(
251 $this->translations
252 );
253 }

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

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

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ retrieveAffectedItemsFromQueryForDeletion()

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

Definition at line 326 of file TranslationsTable.php.

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

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

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

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: