ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilUnitConfigurationGUI Class Reference

Class ilUnitConfigurationGUI. More...

+ Inheritance diagram for ilUnitConfigurationGUI:
+ Collaboration diagram for ilUnitConfigurationGUI:

Public Member Functions

 __construct (protected ilUnitConfigurationRepository $repository)
 
 getUnitCategoryOverviewCommand ()
 
 isCRUDContext ()
 
 getUniqueId ()
 
 executeCommand ()
 
 deleteUnits ()
 

Protected Member Functions

 getDefaultCommand ()
 
 showUnitCategories (array $categories)
 
 getCategoryById (int $id, bool $for_CRUD=true)
 
 handleSubtabs ()
 
 checkPermissions (string $cmd)
 
 confirmDeleteUnit ()
 
 confirmDeleteUnits (?array $unit_ids=null)
 
 saveOrder ()
 
 saveUnit ()
 
 showUnitModificationForm ()
 
 addUnit ()
 
 showUnitCreationForm ()
 
 initUnitForm (?assFormulaQuestionUnitCategory $category=null, ?assFormulaQuestionUnit $unit=null)
 
 confirmDeleteCategory ()
 
 confirmDeleteCategories (?array $category_ids=null)
 
 deleteCategories ()
 
 initUnitCategoryForm (?assFormulaQuestionUnitCategory $cat=null)
 
 addCategory ()
 
 showUnitCategoryCreationForm ()
 
 saveCategory ()
 
 showUnitCategoryModificationForm ()
 

Protected Attributes

RequestDataCollector $request
 
ilPropertyFormGUI $unit_cat_form = null
 
ilPropertyFormGUI $unit_form = null
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrlInterface $ctrl
 

Detailed Description

Class ilUnitConfigurationGUI.

Definition at line 27 of file class.ilUnitConfigurationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilUnitConfigurationGUI::__construct ( protected ilUnitConfigurationRepository  $repository)

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

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 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCategory()

ilUnitConfigurationGUI::addCategory ( )
protected

Definition at line 694 of file class.ilUnitConfigurationGUI.php.

694 : 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 }
Base class for ILIAS Exception handling.
initUnitCategoryForm(?assFormulaQuestionUnitCategory $cat=null)

References Vendor\Package\$e, ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ addUnit()

ilUnitConfigurationGUI::addUnit ( )
protected

Definition at line 318 of file class.ilUnitConfigurationGUI.php.

318 : 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 }
getCategoryById(int $id, bool $for_CRUD=true)
initUnitForm(?assFormulaQuestionUnitCategory $category=null, ?assFormulaQuestionUnit $unit=null)

References getCategoryById(), initUnitForm(), isCRUDContext(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ checkPermissions()

ilUnitConfigurationGUI::checkPermissions ( string  $cmd)
protected

Definition at line 75 of file class.ilUnitConfigurationGUI.php.

75 : void
76 {
77 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ confirmDeleteCategories()

ilUnitConfigurationGUI::confirmDeleteCategories ( ?array  $category_ids = null)
protected
Parameters
int[] | null$category_ids
Returns
void
Exceptions
ilCtrlException

Definition at line 527 of file class.ilUnitConfigurationGUI.php.

527 : 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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References Vendor\Package\$e, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ confirmDeleteCategory()

ilUnitConfigurationGUI::confirmDeleteCategory ( )
protected

Definition at line 512 of file class.ilUnitConfigurationGUI.php.

512 : 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 }
confirmDeleteCategories(?array $category_ids=null)

◆ confirmDeleteUnit()

ilUnitConfigurationGUI::confirmDeleteUnit ( )
protected

Definition at line 91 of file class.ilUnitConfigurationGUI.php.

91 : 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 }
confirmDeleteUnits(?array $unit_ids=null)

References confirmDeleteUnits().

+ Here is the call graph for this function:

◆ confirmDeleteUnits()

ilUnitConfigurationGUI::confirmDeleteUnits ( ?array  $unit_ids = null)
protected
Parameters
int[] | null$unit_ids
Returns
void
Exceptions
ilCtrlException

Definition at line 106 of file class.ilUnitConfigurationGUI.php.

106 : 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 }

References Vendor\Package\$e, ILIAS\Repository\ctrl(), isCRUDContext(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

Referenced by confirmDeleteUnit().

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

◆ deleteCategories()

ilUnitConfigurationGUI::deleteCategories ( )
protected

Definition at line 601 of file class.ilUnitConfigurationGUI.php.

601 : 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 }

References Vendor\Package\$e, ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ deleteUnits()

ilUnitConfigurationGUI::deleteUnits ( )

Definition at line 178 of file class.ilUnitConfigurationGUI.php.

178 : 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 }

References Vendor\Package\$e, isCRUDContext(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ executeCommand()

ilUnitConfigurationGUI::executeCommand ( )

Definition at line 79 of file class.ilUnitConfigurationGUI.php.

79 : 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 }

References checkPermissions(), ILIAS\Repository\ctrl(), getDefaultCommand(), and handleSubtabs().

+ Here is the call graph for this function:

◆ getCategoryById()

ilUnitConfigurationGUI::getCategoryById ( int  $id,
bool  $for_CRUD = true 
)
protected

Definition at line 60 of file class.ilUnitConfigurationGUI.php.

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 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References ILIAS\Repository\ctrl(), getDefaultCommand(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

Referenced by addUnit(), saveUnit(), showUnitCreationForm(), and showUnitModificationForm().

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

◆ getDefaultCommand()

ilUnitConfigurationGUI::getDefaultCommand ( )
abstractprotected

Reimplemented in ilGlobalUnitConfigurationGUI, and ilLocalUnitConfigurationGUI.

Referenced by executeCommand(), and getCategoryById().

+ Here is the caller graph for this function:

◆ getUniqueId()

ilUnitConfigurationGUI::getUniqueId ( )
abstract

◆ getUnitCategoryOverviewCommand()

ilUnitConfigurationGUI::getUnitCategoryOverviewCommand ( )
abstract

◆ handleSubtabs()

ilUnitConfigurationGUI::handleSubtabs ( )
protected

Reimplemented in ilLocalUnitConfigurationGUI.

Definition at line 71 of file class.ilUnitConfigurationGUI.php.

71 : void
72 {
73 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ initUnitCategoryForm()

ilUnitConfigurationGUI::initUnitCategoryForm ( ?assFormulaQuestionUnitCategory  $cat = null)
protected

Definition at line 667 of file class.ilUnitConfigurationGUI.php.

668 {
669 if ($this->unit_cat_form instanceof ilPropertyFormGUI) {
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'));
692 }
This class represents a property form user interface.
This class represents a text property in a property form.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initUnitForm()

ilUnitConfigurationGUI::initUnitForm ( ?assFormulaQuestionUnitCategory  $category = null,
?assFormulaQuestionUnit  $unit = null 
)
protected

Definition at line 368 of file class.ilUnitConfigurationGUI.php.

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 }
This class represents a number property in a property form.
This class represents a selection list property in a property form.

References $unit_form.

Referenced by addUnit(), saveUnit(), showUnitCreationForm(), and showUnitModificationForm().

+ Here is the caller graph for this function:

◆ isCRUDContext()

ilUnitConfigurationGUI::isCRUDContext ( )
abstract

◆ saveCategory()

ilUnitConfigurationGUI::saveCategory ( )
protected

Definition at line 734 of file class.ilUnitConfigurationGUI.php.

734 : 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 }

References Vendor\Package\$e, ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ saveOrder()

ilUnitConfigurationGUI::saveOrder ( )
protected

Definition at line 242 of file class.ilUnitConfigurationGUI.php.

242 : 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 }

References $id, ILIAS\Repository\int(), isCRUDContext(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ saveUnit()

ilUnitConfigurationGUI::saveUnit ( )
protected

Definition at line 265 of file class.ilUnitConfigurationGUI.php.

265 : 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 }

References getCategoryById(), initUnitForm(), isCRUDContext(), ILIAS\Repository\lng(), ILIAS\UI\examples\Deck\repository(), and showUnitModificationForm().

+ Here is the call graph for this function:

◆ showUnitCategories()

ilUnitConfigurationGUI::showUnitCategories ( array  $categories)
abstractprotected

◆ showUnitCategoryCreationForm()

ilUnitConfigurationGUI::showUnitCategoryCreationForm ( )
protected

Definition at line 722 of file class.ilUnitConfigurationGUI.php.

722 : 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 }

◆ showUnitCategoryModificationForm()

ilUnitConfigurationGUI::showUnitCategoryModificationForm ( )
protected

Definition at line 763 of file class.ilUnitConfigurationGUI.php.

763 : 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 }

◆ showUnitCreationForm()

ilUnitConfigurationGUI::showUnitCreationForm ( )
protected

Definition at line 350 of file class.ilUnitConfigurationGUI.php.

350 : 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 }

References getCategoryById(), initUnitForm(), isCRUDContext(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ showUnitModificationForm()

ilUnitConfigurationGUI::showUnitModificationForm ( )
protected

Definition at line 298 of file class.ilUnitConfigurationGUI.php.

298 : 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 }

References getCategoryById(), initUnitForm(), isCRUDContext(), and ILIAS\UI\examples\Deck\repository().

Referenced by saveUnit().

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

Field Documentation

◆ $ctrl

ilCtrlInterface ilUnitConfigurationGUI::$ctrl
protected

Definition at line 34 of file class.ilUnitConfigurationGUI.php.

◆ $lng

ilLanguage ilUnitConfigurationGUI::$lng
protected

Definition at line 33 of file class.ilUnitConfigurationGUI.php.

◆ $request

RequestDataCollector ilUnitConfigurationGUI::$request
protected

Definition at line 29 of file class.ilUnitConfigurationGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilUnitConfigurationGUI::$tpl
protected

Definition at line 32 of file class.ilUnitConfigurationGUI.php.

◆ $unit_cat_form

ilPropertyFormGUI ilUnitConfigurationGUI::$unit_cat_form = null
protected

Definition at line 30 of file class.ilUnitConfigurationGUI.php.

◆ $unit_form

ilPropertyFormGUI ilUnitConfigurationGUI::$unit_form = null
protected

Definition at line 31 of file class.ilUnitConfigurationGUI.php.

Referenced by initUnitForm().


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