ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilUnitConfigurationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
28{
31 protected ?ilPropertyFormGUI $unit_form = null;
33 protected ilLanguage $lng;
35
36 public function __construct(
37 protected ilUnitConfigurationRepository $repository
38 ) {
39 global $DIC;
40 $this->lng = $DIC->language();
41 $this->ctrl = $DIC->ctrl();
42 $this->tpl = $DIC->ui()->mainTemplate();
43
44 $local_dic = QuestionPoolDIC::dic();
45 $this->request = $local_dic['request_data_collector'];
46
47 $this->lng->loadLanguageModule('assessment');
48 }
49
50 abstract protected function getDefaultCommand(): string;
51
52 abstract public function getUnitCategoryOverviewCommand(): string;
53
54 abstract public function isCRUDContext(): bool;
55
56 abstract public function getUniqueId(): string;
57
58 abstract protected function showUnitCategories(array $categories): void;
59
60 protected function getCategoryById(int $id, bool $for_CRUD = true): assFormulaQuestionUnitCategory
61 {
62 $category = $this->repository->getUnitCategoryById($id);
63 if ($for_CRUD && $category->getQuestionFi() !== $this->repository->getConsumerId()) {
64 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('change_adm_categories_not_allowed'), true);
65 $this->ctrl->redirect($this, $this->getDefaultCommand());
66 }
67
68 return $category;
69 }
70
71 protected function handleSubtabs(): void
72 {
73 }
74
75 protected function checkPermissions(string $cmd): void
76 {
77 }
78
79 public function executeCommand(): void
80 {
81 $cmd = $this->ctrl->getCmd($this->getDefaultCommand());
82 $this->checkPermissions($cmd);
83 match ($cmd) {
84 'confirmImportGlobalCategories' => $this->$cmd($this->request->getUnitCategoryIds()),
85 default => $this->$cmd(),
86 };
87
88 $this->handleSubtabs();
89 }
90
91 protected function confirmDeleteUnit(): void
92 {
93 if (!$this->request->isset('unit_id')) {
94 $this->showUnitsOfCategory();
95 return;
96 }
97
98 $this->confirmDeleteUnits([$this->request->int('unit_id')]);
99 }
100
106 protected function confirmDeleteUnits(?array $unit_ids = null): void
107 {
108 if (!$this->isCRUDContext()) {
109 $this->showUnitsOfCategory();
110 return;
111 }
112
113 $unit_ids = $unit_ids ?? $this->request->getUnitIds();
114 if (count($unit_ids) === 0) {
115 $this->showUnitsOfCategory();
116 return;
117 }
118
119 $this->ctrl->setParameter($this, 'category_id', $this->request->int('category_id'));
120 $confirmation = new ilConfirmationGUI();
121 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteUnits'));
122 $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteUnits');
123 $confirmation->setCancel($this->lng->txt('cancel'), 'showUnitsOfCategory');
124
125 $errors = [];
126 $num_to_confirm = 0;
127 foreach ($unit_ids as $unit_id) {
128 try {
129 $unit = $this->repository->getUnit((int) $unit_id);
130 if (!$unit) {
131 continue;
132 }
133
134 if ($check_result = $this->repository->checkDeleteUnit($unit->getId())) {
135 $errors[] = $unit->getDisplayString() . ' - ' . $check_result;
136 continue;
137 }
138
139 $confirmation->addItem('unit_ids[]', (string) $unit->getId(), $unit->getDisplayString());
140 ++$num_to_confirm;
141 } catch (ilException $e) {
142 continue;
143 }
144 }
145
146 if ($errors) {
147 $num_errors = count($errors);
148
149 $error_message = array_map(static function (string $message): string {
150 return '<li>' . $message . '</li>';
151 }, $errors);
152 if ($num_errors === 1) {
153 $this->tpl->setOnScreenMessage(
154 'failure',
155 $this->lng->txt('un_unit_deletion_errors_f_s') . '<ul>' . implode('', $error_message) . '<ul>'
156 );
157 } else {
158 $this->tpl->setOnScreenMessage(
159 'failure',
160 $this->lng->txt('un_unit_deletion_errors_f') . '<ul>' . implode('', $error_message) . '<ul>'
161 );
162 }
163 }
164
165 if ($num_to_confirm) {
166 if ($num_to_confirm === 1) {
167 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_units_s'));
168 } else {
169 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_units'));
170 }
171
172 $this->tpl->setContent($confirmation->getHTML());
173 } else {
174 $this->showUnitsOfCategory();
175 }
176 }
177
178 public function deleteUnits(): void
179 {
180 if (!$this->isCRUDContext()) {
181 $this->showUnitsOfCategory();
182 return;
183 }
184
185 $unit_ids = $this->request->getUnitIds();
186 if (count($unit_ids) === 0) {
187 $this->showUnitsOfCategory();
188 return;
189 }
190
191 $errors = [];
192 $num_deleted = 0;
193 foreach ($unit_ids as $unit_id) {
194 try {
195 $unit = $this->repository->getUnit($unit_id);
196 if (!$unit) {
197 continue;
198 }
199
200 $check_result = $this->repository->deleteUnit($unit->getId());
201 if (!is_null($check_result)) {
202 $errors[] = $unit->getDisplayString() . ' - ' . $check_result;
203 continue;
204 }
205
206 ++$num_deleted;
207 } catch (ilException $e) {
208 continue;
209 }
210 }
211
212 if ($errors) {
213 $num_errors = count($errors);
214
215 $error_message = array_map(static function (string $message): string {
216 return '<li>' . $message . '</li>';
217 }, $errors);
218 if ($num_errors === 1) {
219 $this->tpl->setOnScreenMessage(
220 'failure',
221 $this->lng->txt('un_unit_deletion_errors_p_s') . '<ul>' . implode('', $error_message) . '<ul>'
222 );
223 } else {
224 $this->tpl->setOnScreenMessage(
225 'failure',
226 $this->lng->txt('un_unit_deletion_errors_p') . '<ul>' . implode('', $error_message) . '<ul>'
227 );
228 }
229 }
230
231 if ($num_deleted) {
232 if ($num_deleted === 1) {
233 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_units_s'));
234 } else {
235 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_units'));
236 }
237 }
238
239 $this->showUnitsOfCategory();
240 }
241
242 protected function saveOrder(): void
243 {
244 if (!$this->isCRUDContext()) {
245 $this->showUnitsOfCategory();
246 return;
247 }
248
249 if (!$this->request->isset('sequence') || !is_array($this->request->raw('sequence'))) {
250 $this->showUnitsOfCategory();
251 return;
252 }
253
254 $sequences = $this->request->raw('sequence');
255 foreach ($sequences as $id => $sequence) {
256 $sorting_value = str_replace(',', '.', $sequence);
257 $sorting_value = (int) $sorting_value * 100;
258 $this->repository->saveUnitOrder((int) $id, $sorting_value);
259 }
260
261 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
262 $this->showUnitsOfCategory();
263 }
264
265 protected function saveUnit(): void
266 {
267 if (!$this->isCRUDContext()) {
268 $this->showUnitsOfCategory();
269 return;
270 }
271
272 $category = $this->getCategoryById($this->request->int('category_id'));
273 $unit = $this->repository->getUnit($this->request->int('unit_id'));
274
275 if ($this->repository->isUnitInUse($unit->getId())) {
277 return;
278 }
279
280 $this->initUnitForm($category, $unit);
281 if ($this->unit_form->checkInput()) {
282 $unit->setUnit($this->unit_form->getInput('unit_title'));
283 $unit->setFactor((float) $this->unit_form->getInput('factor'));
284 $unit->setBaseUnit((int) $this->unit_form->getInput('base_unit') !== $unit->getId() ? (int) $this->unit_form->getInput('base_unit') : 0);
285 $unit->setCategory($category->getId());
286 $this->repository->saveUnit($unit);
287
288 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
289 $this->showUnitsOfCategory();
290 return;
291 }
292
293 $this->unit_form->setValuesByPost();
294
295 $this->tpl->setContent($this->unit_form->getHtml());
296 }
297
298 protected function showUnitModificationForm(): void
299 {
300 if (!$this->isCRUDContext()) {
301 $this->showUnitsOfCategory();
302 return;
303 }
304
305 $category = $this->getCategoryById($this->request->int('category_id'));
306 $unit = $this->repository->getUnit($this->request->int('unit_id'));
307
308 $this->initUnitForm($category, $unit);
309 $this->unit_form->setValuesByArray([
310 'factor' => $unit->getFactor(),
311 'unit_title' => $unit->getUnit(),
312 'base_unit' => $unit->getBaseUnit() !== $unit->getId() ? $unit->getBaseUnit() : 0
313 ]);
314
315 $this->tpl->setContent($this->unit_form->getHtml());
316 }
317
318 protected function addUnit(): void
319 {
320 if (!$this->isCRUDContext()) {
321 $this->showUnitsOfCategory();
322 return;
323 }
324
325 $category = $this->getCategoryById($this->request->int('category_id'));
326
327 $this->initUnitForm($category);
328 if ($this->unit_form->checkInput()) {
329 $unit = new assFormulaQuestionUnit();
330 $unit->setUnit($this->unit_form->getInput('unit_title'));
331 $unit->setCategory($category->getId());
332
333 $this->repository->createNewUnit($unit);
334
335 $unit->setBaseUnit((int) $this->unit_form->getInput('base_unit'));
336 $unit->setFactor((float) $this->unit_form->getInput('factor'));
337
338 $this->repository->saveUnit($unit);
339
340 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
341 $this->showUnitsOfCategory();
342 return;
343 }
344
345 $this->unit_form->setValuesByPost();
346
347 $this->tpl->setContent($this->unit_form->getHtml());
348 }
349
350 protected function showUnitCreationForm(): void
351 {
352 if (!$this->isCRUDContext()) {
353 $this->showUnitsOfCategory();
354 return;
355 }
356
357 $category = $this->getCategoryById($this->request->int('category_id'));
358
359 $this->initUnitForm($category);
360 $this->unit_form->setValuesByArray([
361 'factor' => 1,
362 'unit_title' => $this->lng->txt('unit_placeholder')
363 ]);
364
365 $this->tpl->setContent($this->unit_form->getHtml());
366 }
367
368 protected function initUnitForm(
369 ?assFormulaQuestionUnitCategory $category = null,
370 ?assFormulaQuestionUnit $unit = null
372 if ($this->unit_form instanceof ilPropertyFormGUI) {
373 return $this->unit_form;
374 }
375
376 $unit_in_use = false;
377 if ($unit instanceof assFormulaQuestionUnit && $this->repository->isUnitInUse($unit->getId())) {
378 $unit_in_use = true;
379 }
380
381 $this->unit_form = new ilPropertyFormGUI();
382
383 $title = new ilTextInputGUI($this->lng->txt('unit'), 'unit_title');
384 $title->setDisabled($unit_in_use);
385 $title->setRequired(true);
386 $this->unit_form->addItem($title);
387
388 $baseunit = new ilSelectInputGUI($this->lng->txt('baseunit'), 'base_unit');
389 $items = $this->repository->getCategorizedUnits();
390 $options = [];
391 $category_name = '';
392 $new_category = false;
393 foreach ($items as $item) {
394 if (
395 $unit instanceof assFormulaQuestionUnit &&
396 $unit->getId() === $item->getId()
397 ) {
398 continue;
399 }
400
401 if ($item instanceof assFormulaQuestionUnitCategory) {
402 if ($category_name !== $item->getDisplayString()) {
403 $new_category = true;
404 $category_name = $item->getDisplayString();
405 }
406 continue;
407 }
408
409 $options[$item->getId()] = $item->getDisplayString() . ($new_category ? ' (' . $category_name . ')' : '');
410 $new_category = false;
411 }
412 $baseunit->setDisabled($unit_in_use);
413 $baseunit->setOptions([0 => $this->lng->txt('no_selection')] + $options);
414 $this->unit_form->addItem($baseunit);
415
416 $factor = new ilNumberInputGUI($this->lng->txt('factor'), 'factor');
417 $factor->setRequired(true);
418 $factor->setSize(3);
419 $factor->setMinValue(0);
420 $factor->allowDecimals(true);
421 $factor->setDisabled($unit_in_use);
422 $this->unit_form->addItem($factor);
423
424 $this->ctrl->setParameterByClass(get_class($this), 'category_id', $this->request->int('category_id'));
425 if (null === $unit) {
426 $this->unit_form->setTitle($this->lng->txt('new_unit'));
427 $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'addUnit'));
428 $this->unit_form->addCommandButton('addUnit', $this->lng->txt('save'));
429 } else {
430 $this->ctrl->setParameter($this, 'unit_id', $unit->getId());
431 if ($unit_in_use) {
432 $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'showUnitsOfCategory'));
433 } else {
434 $this->unit_form->addCommandButton('saveUnit', $this->lng->txt('save'));
435 $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'saveUnit'));
436 }
437 $this->unit_form->setTitle(sprintf(
438 $this->lng->txt('un_sel_cat_sel_unit'),
439 $category->getDisplayString(),
440 $unit->getDisplayString()
441 ));
442 }
443 $this->ctrl->clearParameterByClass(get_class($this), 'category_id');
444
445 $this->unit_form->addCommandButton('showUnitsOfCategory', $this->lng->txt('cancel'));
446 return $this->unit_form;
447 }
448
449 protected function showUnitsOfCategory(): void
450 {
451 global $DIC;
452
453 $ilToolbar = $DIC->toolbar();
454
455 $category = $this->getCategoryById($this->request->int('category_id'), false);
456
457 $this->tpl->addJavaScript("assets/js/Basic.js");
458 $this->tpl->addJavaScript("assets/js/Form.js");
459 $this->lng->loadLanguageModule('form');
460
461 $ilToolbar->addButton(
462 $this->lng->txt('back'),
463 $this->ctrl->getLinkTarget($this, $this->getUnitCategoryOverviewCommand())
464 );
465 if ($this->isCRUDContext()) {
466 $this->ctrl->setParameterByClass(get_class($this), 'category_id', $category->getId());
467 $ilToolbar->addButton(
468 $this->lng->txt('un_add_unit'),
469 $this->ctrl->getLinkTarget($this, 'showUnitCreationForm')
470 );
471 $this->ctrl->clearParameterByClass(get_class($this), 'category_id');
472 }
473 $table = new ilUnitTableGUI($this, 'showUnitsOfCategory', $category);
474 $units = $this->repository->loadUnitsForCategory($category->getId());
475 $data = [];
476 foreach ($units as $unit) {
478 $data[] = [
479 'unit_id' => $unit->getId(),
480 'unit' => $unit->getSanitizedUnit(),
481 'baseunit' => $unit->getSanitizedBaseunitTitle(),
482 'baseunit_id' => $unit->getBaseUnit(),
483 'factor' => $unit->getFactor(),
484 'sequence' => $unit->getSequence(),
485 ];
486 }
487 $table->setData($data);
488
489 $this->tpl->setContent($table->getHTML());
490 }
491
492 protected function showGlobalUnitCategories(): void
493 {
494 $categories = array_filter(
495 $this->repository->getAllUnitCategories(),
496 static function (assFormulaQuestionUnitCategory $category): bool {
497 return !$category->getQuestionFi() ? true : false;
498 }
499 );
500 $data = [];
501 foreach ($categories as $category) {
503 $data[] = [
504 'category_id' => $category->getId(),
505 'category' => $category->getDisplayString()
506 ];
507 }
508
509 $this->showUnitCategories($data);
510 }
511
512 protected function confirmDeleteCategory(): void
513 {
514 if (!$this->request->isset('category_id')) {
515 $this->{$this->getUnitCategoryOverviewCommand()}();
516 return;
517 }
518
519 $this->confirmDeleteCategories([$this->request->int('category_id')]);
520 }
521
527 protected function confirmDeleteCategories(?array $category_ids = null): void
528 {
529 if (!$this->isCRUDContext()) {
530 $this->{$this->getDefaultCommand()}();
531 return;
532 }
533
534 $category_ids = $category_ids ?? $this->request->getUnitCategoryIds();
535 if (count($category_ids) === 0) {
536 $this->{$this->getUnitCategoryOverviewCommand()}();
537 return;
538 }
539
540 $confirmation = new ilConfirmationGUI();
541 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteCategories'));
542 $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteCategories');
543 $confirmation->setCancel($this->lng->txt('cancel'), $this->getUnitCategoryOverviewCommand());
544
545 $errors = [];
546 $num_to_confirm = 0;
547 foreach ($category_ids as $category_id) {
548 try {
549 $category = $this->repository->getUnitCategoryById($category_id);
550 } catch (ilException $e) {
551 continue;
552 }
553
554 if (!$this->repository->isCRUDAllowed($category_id)) {
555 $errors[] = $category->getDisplayString() . ' - ' . $this->lng->txt('change_adm_categories_not_allowed');
556 continue;
557 }
558
559 $possible_error = $this->repository->checkDeleteCategory($category_id);
560 if (is_string($possible_error) && $possible_error !== '') {
561 $errors[] = $category->getDisplayString() . ' - ' . $possible_error;
562 continue;
563 }
564
565 $confirmation->addItem('category_ids[]', (string) $category->getId(), $category->getDisplayString());
566 ++$num_to_confirm;
567 }
568
569 if ($errors) {
570 $num_errors = count($errors);
571
572 $error_message = array_map(static function (string $message): string {
573 return '<li>' . $message . '</li>';
574 }, $errors);
575 if ($num_errors === 1) {
576 $this->tpl->setOnScreenMessage(
577 'failure',
578 $this->lng->txt('un_cat_deletion_errors_f_s') . '<ul>' . implode('', $error_message) . '<ul>'
579 );
580 } else {
581 $this->tpl->setOnScreenMessage(
582 'failure',
583 $this->lng->txt('un_cat_deletion_errors_f') . '<ul>' . implode('', $error_message) . '<ul>'
584 );
585 }
586 }
587
588 if ($num_to_confirm) {
589 if ($num_to_confirm === 1) {
590 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_categories_s'));
591 } else {
592 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_categories'));
593 }
594
595 $this->tpl->setContent($confirmation->getHTML());
596 } else {
597 $this->{$this->getUnitCategoryOverviewCommand()}();
598 }
599 }
600
601 protected function deleteCategories(): void
602 {
603 if (!$this->isCRUDContext()) {
604 $this->{$this->getDefaultCommand()}();
605 return;
606 }
607
608 $category_ids = $this->request->getUnitCategoryIds();
609 if (count($category_ids) === 0) {
610 $this->{$this->getUnitCategoryOverviewCommand()}();
611 return;
612 }
613
614 $errors = [];
615 $num_deleted = 0;
616 foreach ($category_ids as $category_id) {
617 try {
618 $category = $this->repository->getUnitCategoryById($category_id);
619 } catch (ilException $e) {
620 continue;
621 }
622
623 if (!$this->repository->isCRUDAllowed($category_id)) {
624 $errors[] = $category->getDisplayString() . ' - ' . $this->lng->txt('change_adm_categories_not_allowed');
625 continue;
626 }
627
628 $possible_error = $this->repository->deleteCategory($category_id);
629 if (is_string($possible_error) && $possible_error !== '') {
630 $errors[] = $category->getDisplayString() . ' - ' . $possible_error;
631 continue;
632 }
633
634 ++$num_deleted;
635 }
636
637 if ($errors) {
638 $num_errors = count($errors);
639
640 $error_message = array_map(static function (string $message): string {
641 return '<li>' . $message . '</li>';
642 }, $errors);
643 if ($num_errors === 1) {
644 $this->tpl->setOnScreenMessage(
645 'failure',
646 $this->lng->txt('un_cat_deletion_errors_p_s') . '<ul>' . implode('', $error_message) . '<ul>'
647 );
648 } else {
649 $this->tpl->setOnScreenMessage(
650 'failure',
651 $this->lng->txt('un_cat_deletion_errors_p') . '<ul>' . implode('', $error_message) . '<ul>'
652 );
653 }
654 }
655
656 if ($num_deleted) {
657 if ($num_deleted === 1) {
658 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_categories_s'));
659 } else {
660 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_categories'));
661 }
662 }
663
664 $this->{$this->getUnitCategoryOverviewCommand()}();
665 }
666
668 {
669 if ($this->unit_cat_form instanceof ilPropertyFormGUI) {
670 return $this->unit_cat_form;
671 }
672
673 $this->unit_cat_form = new ilPropertyFormGUI();
674
675 $title = new ilTextInputGUI($this->lng->txt('title'), 'category_name');
676 $title->setRequired(true);
677 $this->unit_cat_form->addItem($title);
678
679 if (null === $cat) {
680 $this->unit_cat_form->setTitle($this->lng->txt('new_category'));
681 $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'addCategory'));
682 $this->unit_cat_form->addCommandButton('addCategory', $this->lng->txt('save'));
683 } else {
684 $this->ctrl->setParameter($this, 'category_id', $cat->getId());
685 $this->unit_cat_form->addCommandButton('saveCategory', $this->lng->txt('save'));
686 $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'saveCategory'));
687 $this->unit_cat_form->setTitle(sprintf($this->lng->txt('selected_category'), $cat->getDisplayString()));
688 }
689
690 $this->unit_cat_form->addCommandButton($this->getUnitCategoryOverviewCommand(), $this->lng->txt('cancel'));
691 return $this->unit_cat_form;
692 }
693
694 protected function addCategory(): void
695 {
696 if (!$this->isCRUDContext()) {
697 $this->{$this->getDefaultCommand()}();
698 return;
699 }
700
701 $this->initUnitCategoryForm();
702 if ($this->unit_cat_form->checkInput()) {
703 try {
704 $category = new assFormulaQuestionUnitCategory();
705 $category->setCategory($this->unit_cat_form->getInput('category_name'));
706 $this->repository->saveNewUnitCategory($category);
707 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
708
709 $this->{$this->getUnitCategoryOverviewCommand()}();
710 return;
711 } catch (ilException $e) {
712 $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
713 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
714 }
715 }
716
717 $this->unit_cat_form->setValuesByPost();
718
719 $this->tpl->setContent($this->unit_cat_form->getHtml());
720 }
721
722 protected function showUnitCategoryCreationForm(): void
723 {
724 if (!$this->isCRUDContext()) {
725 $this->{$this->getDefaultCommand()}();
726 return;
727 }
728
729 $this->initUnitCategoryForm();
730
731 $this->tpl->setContent($this->unit_cat_form->getHtml());
732 }
733
734 protected function saveCategory(): void
735 {
736 if (!$this->isCRUDContext()) {
737 $this->{$this->getDefaultCommand()}();
738 return;
739 }
740
741 $category = $this->getCategoryById($this->request->int('category_id'));
742
743 $this->initUnitCategoryForm($category);
744 if ($this->unit_cat_form->checkInput()) {
745 try {
746 $category->setCategory($this->unit_cat_form->getInput('category_name'));
747 $this->repository->saveCategory($category);
748 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
749
750 $this->{$this->getUnitCategoryOverviewCommand()}();
751 return;
752 } catch (ilException $e) {
753 $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
754 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
755 }
756 }
757
758 $this->unit_cat_form->setValuesByPost();
759
760 $this->tpl->setContent($this->unit_cat_form->getHtml());
761 }
762
763 protected function showUnitCategoryModificationForm(): void
764 {
765 if (!$this->isCRUDContext()) {
766 $this->{$this->getDefaultCommand()}();
767 return;
768 }
769
770 $category = $this->getCategoryById($this->request->int('category_id'));
771
772 $this->initUnitCategoryForm($category);
773 $this->unit_cat_form->setValuesByArray([
774 'category_name' => $category->getCategory()
775 ]);
776
777 $this->tpl->setContent($this->unit_cat_form->getHtml());
778 }
779}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Base class for ILIAS Exception handling.
language handling
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text property in a property form.
Class ilUnitConfigurationGUI.
showUnitCategories(array $categories)
initUnitCategoryForm(?assFormulaQuestionUnitCategory $cat=null)
getCategoryById(int $id, bool $for_CRUD=true)
initUnitForm(?assFormulaQuestionUnitCategory $category=null, ?assFormulaQuestionUnit $unit=null)
confirmDeleteUnits(?array $unit_ids=null)
ilGlobalTemplateInterface $tpl
confirmDeleteCategories(?array $category_ids=null)
__construct(protected ilUnitConfigurationRepository $repository)
Class ilUnitConfigurationRepository.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26