ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 699 of file class.ilUnitConfigurationGUI.php.

699 : void
700 {
701 if (!$this->isCRUDContext()) {
702 $this->{$this->getDefaultCommand()}();
703 return;
704 }
705
706 $this->initUnitCategoryForm();
707 if ($this->unit_cat_form->checkInput()) {
708 try {
709 $category = new assFormulaQuestionUnitCategory();
710 $category->setCategory($this->unit_cat_form->getInput('category_name'));
711 $this->repository->saveNewUnitCategory($category);
712 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
713
714 $this->{$this->getUnitCategoryOverviewCommand()}();
715 return;
716 } catch (ilException $e) {
717 $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
718 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
719 }
720 }
721
722 $this->unit_cat_form->setValuesByPost();
723
724 $this->tpl->setContent($this->unit_cat_form->getHtml());
725 }
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 323 of file class.ilUnitConfigurationGUI.php.

323 : void
324 {
325 if (!$this->isCRUDContext()) {
326 $this->showUnitsOfCategory();
327 return;
328 }
329
330 $category = $this->getCategoryById($this->request->int('category_id'));
331
332 $this->initUnitForm($category);
333 if ($this->unit_form->checkInput()) {
334 $unit = new assFormulaQuestionUnit();
335 $unit->setUnit($this->unit_form->getInput('unit_title'));
336 $unit->setCategory($category->getId());
337
338 $this->repository->createNewUnit($unit);
339
340 $unit->setBaseUnit((int) $this->unit_form->getInput('base_unit'));
341 $unit->setFactor((float) $this->unit_form->getInput('factor'));
342
343 $this->repository->saveUnit($unit);
344
345 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
346 $this->showUnitsOfCategory();
347 return;
348 }
349
350 $this->unit_form->setValuesByPost();
351
352 $this->tpl->setContent($this->unit_form->getHtml());
353 }
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 532 of file class.ilUnitConfigurationGUI.php.

532 : void
533 {
534 if (!$this->isCRUDContext()) {
535 $this->{$this->getDefaultCommand()}();
536 return;
537 }
538
539 $category_ids = $category_ids ?? $this->request->getUnitCategoryIds();
540 if (count($category_ids) === 0) {
541 $this->{$this->getUnitCategoryOverviewCommand()}();
542 return;
543 }
544
545 $confirmation = new ilConfirmationGUI();
546 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteCategories'));
547 $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteCategories');
548 $confirmation->setCancel($this->lng->txt('cancel'), $this->getUnitCategoryOverviewCommand());
549
550 $errors = [];
551 $num_to_confirm = 0;
552 foreach ($category_ids as $category_id) {
553 try {
554 $category = $this->repository->getUnitCategoryById($category_id);
555 } catch (ilException $e) {
556 continue;
557 }
558
559 if (!$this->repository->isCRUDAllowed($category_id)) {
560 $errors[] = $category->getDisplayString() . ' - ' . $this->lng->txt('change_adm_categories_not_allowed');
561 continue;
562 }
563
564 $possible_error = $this->repository->checkDeleteCategory($category_id);
565 if (is_string($possible_error) && $possible_error !== '') {
566 $errors[] = $category->getDisplayString() . ' - ' . $possible_error;
567 continue;
568 }
569
570 $confirmation->addItem('category_ids[]', (string) $category->getId(), $category->getDisplayString());
571 ++$num_to_confirm;
572 }
573
574 if ($errors) {
575 $num_errors = count($errors);
576
577 $error_message = array_map(static function (string $message): string {
578 return '<li>' . $message . '</li>';
579 }, $errors);
580 if ($num_errors === 1) {
581 $this->tpl->setOnScreenMessage(
582 'failure',
583 $this->lng->txt('un_cat_deletion_errors_f_s') . '<ul>' . implode('', $error_message) . '<ul>'
584 );
585 } else {
586 $this->tpl->setOnScreenMessage(
587 'failure',
588 $this->lng->txt('un_cat_deletion_errors_f') . '<ul>' . implode('', $error_message) . '<ul>'
589 );
590 }
591 }
592
593 if ($num_to_confirm) {
594 if ($num_to_confirm === 1) {
595 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_categories_s'));
596 } else {
597 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_categories'));
598 }
599
600 $this->tpl->setContent($confirmation->getHTML());
601 } else {
602 $this->{$this->getUnitCategoryOverviewCommand()}();
603 }
604 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$message
Definition: xapiexit.php:31

References Vendor\Package\$e, $message, 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 517 of file class.ilUnitConfigurationGUI.php.

517 : void
518 {
519 if (!$this->request->isset('category_id')) {
520 $this->{$this->getUnitCategoryOverviewCommand()}();
521 return;
522 }
523
524 $this->confirmDeleteCategories([$this->request->int('category_id')]);
525 }
confirmDeleteCategories(?array $category_ids=null)

◆ confirmDeleteUnit()

ilUnitConfigurationGUI::confirmDeleteUnit ( )
protected

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

96 : void
97 {
98 if (!$this->request->isset('unit_id')) {
99 $this->showUnitsOfCategory();
100 return;
101 }
102
103 $this->confirmDeleteUnits([$this->request->int('unit_id')]);
104 }
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 111 of file class.ilUnitConfigurationGUI.php.

111 : void
112 {
113 if (!$this->isCRUDContext()) {
114 $this->showUnitsOfCategory();
115 return;
116 }
117
118 $unit_ids = $unit_ids ?? $this->request->getUnitIds();
119 if (count($unit_ids) === 0) {
120 $this->showUnitsOfCategory();
121 return;
122 }
123
124 $this->ctrl->setParameter($this, 'category_id', $this->request->int('category_id'));
125 $confirmation = new ilConfirmationGUI();
126 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteUnits'));
127 $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteUnits');
128 $confirmation->setCancel($this->lng->txt('cancel'), 'showUnitsOfCategory');
129
130 $errors = [];
131 $num_to_confirm = 0;
132 foreach ($unit_ids as $unit_id) {
133 try {
134 $unit = $this->repository->getUnit((int) $unit_id);
135 if (!$unit) {
136 continue;
137 }
138
139 if ($check_result = $this->repository->checkDeleteUnit($unit->getId())) {
140 $errors[] = $unit->getDisplayString() . ' - ' . $check_result;
141 continue;
142 }
143
144 $confirmation->addItem('unit_ids[]', (string) $unit->getId(), $unit->getDisplayString());
145 ++$num_to_confirm;
146 } catch (ilException $e) {
147 continue;
148 }
149 }
150
151 if ($errors) {
152 $num_errors = count($errors);
153
154 $error_message = array_map(static function (string $message): string {
155 return '<li>' . $message . '</li>';
156 }, $errors);
157 if ($num_errors === 1) {
158 $this->tpl->setOnScreenMessage(
159 'failure',
160 $this->lng->txt('un_unit_deletion_errors_f_s') . '<ul>' . implode('', $error_message) . '<ul>'
161 );
162 } else {
163 $this->tpl->setOnScreenMessage(
164 'failure',
165 $this->lng->txt('un_unit_deletion_errors_f') . '<ul>' . implode('', $error_message) . '<ul>'
166 );
167 }
168 }
169
170 if ($num_to_confirm) {
171 if ($num_to_confirm === 1) {
172 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_units_s'));
173 } else {
174 $confirmation->setHeaderText($this->lng->txt('un_sure_delete_units'));
175 }
176
177 $this->tpl->setContent($confirmation->getHTML());
178 } else {
179 $this->showUnitsOfCategory();
180 }
181 }

References Vendor\Package\$e, $message, 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 606 of file class.ilUnitConfigurationGUI.php.

606 : void
607 {
608 if (!$this->isCRUDContext()) {
609 $this->{$this->getDefaultCommand()}();
610 return;
611 }
612
613 $category_ids = $this->request->getUnitCategoryIds();
614 if (count($category_ids) === 0) {
615 $this->{$this->getUnitCategoryOverviewCommand()}();
616 return;
617 }
618
619 $errors = [];
620 $num_deleted = 0;
621 foreach ($category_ids as $category_id) {
622 try {
623 $category = $this->repository->getUnitCategoryById($category_id);
624 } catch (ilException $e) {
625 continue;
626 }
627
628 if (!$this->repository->isCRUDAllowed($category_id)) {
629 $errors[] = $category->getDisplayString() . ' - ' . $this->lng->txt('change_adm_categories_not_allowed');
630 continue;
631 }
632
633 $possible_error = $this->repository->deleteCategory($category_id);
634 if (is_string($possible_error) && $possible_error !== '') {
635 $errors[] = $category->getDisplayString() . ' - ' . $possible_error;
636 continue;
637 }
638
639 ++$num_deleted;
640 }
641
642 if ($errors) {
643 $num_errors = count($errors);
644
645 $error_message = array_map(static function (string $message): string {
646 return '<li>' . $message . '</li>';
647 }, $errors);
648 if ($num_errors === 1) {
649 $this->tpl->setOnScreenMessage(
650 'failure',
651 $this->lng->txt('un_cat_deletion_errors_p_s') . '<ul>' . implode('', $error_message) . '<ul>'
652 );
653 } else {
654 $this->tpl->setOnScreenMessage(
655 'failure',
656 $this->lng->txt('un_cat_deletion_errors_p') . '<ul>' . implode('', $error_message) . '<ul>'
657 );
658 }
659 }
660
661 if ($num_deleted) {
662 if ($num_deleted === 1) {
663 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_categories_s'));
664 } else {
665 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_categories'));
666 }
667 }
668
669 $this->{$this->getUnitCategoryOverviewCommand()}();
670 }

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

+ Here is the call graph for this function:

◆ deleteUnits()

ilUnitConfigurationGUI::deleteUnits ( )

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

183 : void
184 {
185 if (!$this->isCRUDContext()) {
186 $this->showUnitsOfCategory();
187 return;
188 }
189
190 $unit_ids = $this->request->getUnitIds();
191 if (count($unit_ids) === 0) {
192 $this->showUnitsOfCategory();
193 return;
194 }
195
196 $errors = [];
197 $num_deleted = 0;
198 foreach ($unit_ids as $unit_id) {
199 try {
200 $unit = $this->repository->getUnit($unit_id);
201 if (!$unit) {
202 continue;
203 }
204
205 $check_result = $this->repository->deleteUnit($unit->getId());
206 if (!is_null($check_result)) {
207 $errors[] = $unit->getDisplayString() . ' - ' . $check_result;
208 continue;
209 }
210
211 ++$num_deleted;
212 } catch (ilException $e) {
213 continue;
214 }
215 }
216
217 if ($errors) {
218 $num_errors = count($errors);
219
220 $error_message = array_map(static function (string $message): string {
221 return '<li>' . $message . '</li>';
222 }, $errors);
223 if ($num_errors === 1) {
224 $this->tpl->setOnScreenMessage(
225 'failure',
226 $this->lng->txt('un_unit_deletion_errors_p_s') . '<ul>' . implode('', $error_message) . '<ul>'
227 );
228 } else {
229 $this->tpl->setOnScreenMessage(
230 'failure',
231 $this->lng->txt('un_unit_deletion_errors_p') . '<ul>' . implode('', $error_message) . '<ul>'
232 );
233 }
234 }
235
236 if ($num_deleted) {
237 if ($num_deleted === 1) {
238 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_units_s'));
239 } else {
240 $this->tpl->setOnScreenMessage('success', $this->lng->txt('un_deleted_units'));
241 }
242 }
243
244 $this->showUnitsOfCategory();
245 }

References Vendor\Package\$e, $message, 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 switch ($cmd) {
84 case 'confirmImportGlobalCategories':
85 $category_ids = $this->request->raw('category_ids');
86 $this->$cmd($category_ids);
87 break;
88 default:
89 $this->$cmd();
90 break;
91 }
92
93 $this->handleSubtabs();
94 }

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 672 of file class.ilUnitConfigurationGUI.php.

673 {
674 if ($this->unit_cat_form instanceof ilPropertyFormGUI) {
676 }
677
678 $this->unit_cat_form = new ilPropertyFormGUI();
679
680 $title = new ilTextInputGUI($this->lng->txt('title'), 'category_name');
681 $title->setRequired(true);
682 $this->unit_cat_form->addItem($title);
683
684 if (null === $cat) {
685 $this->unit_cat_form->setTitle($this->lng->txt('new_category'));
686 $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'addCategory'));
687 $this->unit_cat_form->addCommandButton('addCategory', $this->lng->txt('save'));
688 } else {
689 $this->ctrl->setParameter($this, 'category_id', $cat->getId());
690 $this->unit_cat_form->addCommandButton('saveCategory', $this->lng->txt('save'));
691 $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'saveCategory'));
692 $this->unit_cat_form->setTitle(sprintf($this->lng->txt('selected_category'), $cat->getDisplayString()));
693 }
694
695 $this->unit_cat_form->addCommandButton($this->getUnitCategoryOverviewCommand(), $this->lng->txt('cancel'));
697 }
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 373 of file class.ilUnitConfigurationGUI.php.

377 if ($this->unit_form instanceof ilPropertyFormGUI) {
378 return $this->unit_form;
379 }
380
381 $unit_in_use = false;
382 if ($unit instanceof assFormulaQuestionUnit && $this->repository->isUnitInUse($unit->getId())) {
383 $unit_in_use = true;
384 }
385
386 $this->unit_form = new ilPropertyFormGUI();
387
388 $title = new ilTextInputGUI($this->lng->txt('unit'), 'unit_title');
389 $title->setDisabled($unit_in_use);
390 $title->setRequired(true);
391 $this->unit_form->addItem($title);
392
393 $baseunit = new ilSelectInputGUI($this->lng->txt('baseunit'), 'base_unit');
394 $items = $this->repository->getCategorizedUnits();
395 $options = [];
396 $category_name = '';
397 $new_category = false;
398 foreach ($items as $item) {
399 if (
400 $unit instanceof assFormulaQuestionUnit &&
401 $unit->getId() === $item->getId()
402 ) {
403 continue;
404 }
405
406 if ($item instanceof assFormulaQuestionUnitCategory) {
407 if ($category_name !== $item->getDisplayString()) {
408 $new_category = true;
409 $category_name = $item->getDisplayString();
410 }
411 continue;
412 }
413
414 $options[$item->getId()] = $item->getDisplayString() . ($new_category ? ' (' . $category_name . ')' : '');
415 $new_category = false;
416 }
417 $baseunit->setDisabled($unit_in_use);
418 $baseunit->setOptions([0 => $this->lng->txt('no_selection')] + $options);
419 $this->unit_form->addItem($baseunit);
420
421 $factor = new ilNumberInputGUI($this->lng->txt('factor'), 'factor');
422 $factor->setRequired(true);
423 $factor->setSize(3);
424 $factor->setMinValue(0);
425 $factor->allowDecimals(true);
426 $factor->setDisabled($unit_in_use);
427 $this->unit_form->addItem($factor);
428
429 $this->ctrl->setParameterByClass(get_class($this), 'category_id', $this->request->int('category_id'));
430 if (null === $unit) {
431 $this->unit_form->setTitle($this->lng->txt('new_unit'));
432 $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'addUnit'));
433 $this->unit_form->addCommandButton('addUnit', $this->lng->txt('save'));
434 } else {
435 $this->ctrl->setParameter($this, 'unit_id', $unit->getId());
436 if ($unit_in_use) {
437 $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'showUnitsOfCategory'));
438 } else {
439 $this->unit_form->addCommandButton('saveUnit', $this->lng->txt('save'));
440 $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'saveUnit'));
441 }
442 $this->unit_form->setTitle(sprintf(
443 $this->lng->txt('un_sel_cat_sel_unit'),
444 $category->getDisplayString(),
445 $unit->getDisplayString()
446 ));
447 }
448 $this->ctrl->clearParameterByClass(get_class($this), 'category_id');
449
450 $this->unit_form->addCommandButton('showUnitsOfCategory', $this->lng->txt('cancel'));
451 return $this->unit_form;
452 }
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 739 of file class.ilUnitConfigurationGUI.php.

739 : void
740 {
741 if (!$this->isCRUDContext()) {
742 $this->{$this->getDefaultCommand()}();
743 return;
744 }
745
746 $category = $this->getCategoryById($this->request->int('category_id'));
747
748 $this->initUnitCategoryForm($category);
749 if ($this->unit_cat_form->checkInput()) {
750 try {
751 $category->setCategory($this->unit_cat_form->getInput('category_name'));
752 $this->repository->saveCategory($category);
753 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
754
755 $this->{$this->getUnitCategoryOverviewCommand()}();
756 return;
757 } catch (ilException $e) {
758 $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
759 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
760 }
761 }
762
763 $this->unit_cat_form->setValuesByPost();
764
765 $this->tpl->setContent($this->unit_cat_form->getHtml());
766 }

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 247 of file class.ilUnitConfigurationGUI.php.

247 : void
248 {
249 if (!$this->isCRUDContext()) {
250 $this->showUnitsOfCategory();
251 return;
252 }
253
254 if (!$this->request->isset('sequence') || !is_array($this->request->raw('sequence'))) {
255 $this->showUnitsOfCategory();
256 return;
257 }
258
259 $sequences = $this->request->raw('sequence');
260 foreach ($sequences as $id => $sequence) {
261 $sorting_value = str_replace(',', '.', $sequence);
262 $sorting_value = (int) $sorting_value * 100;
263 $this->repository->saveUnitOrder((int) $id, $sorting_value);
264 }
265
266 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
267 $this->showUnitsOfCategory();
268 }

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 270 of file class.ilUnitConfigurationGUI.php.

270 : void
271 {
272 if (!$this->isCRUDContext()) {
273 $this->showUnitsOfCategory();
274 return;
275 }
276
277 $category = $this->getCategoryById($this->request->int('category_id'));
278 $unit = $this->repository->getUnit($this->request->int('unit_id'));
279
280 if ($this->repository->isUnitInUse($unit->getId())) {
282 return;
283 }
284
285 $this->initUnitForm($category, $unit);
286 if ($this->unit_form->checkInput()) {
287 $unit->setUnit($this->unit_form->getInput('unit_title'));
288 $unit->setFactor((float) $this->unit_form->getInput('factor'));
289 $unit->setBaseUnit((int) $this->unit_form->getInput('base_unit') !== $unit->getId() ? (int) $this->unit_form->getInput('base_unit') : 0);
290 $unit->setCategory($category->getId());
291 $this->repository->saveUnit($unit);
292
293 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
294 $this->showUnitsOfCategory();
295 return;
296 }
297
298 $this->unit_form->setValuesByPost();
299
300 $this->tpl->setContent($this->unit_form->getHtml());
301 }

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 727 of file class.ilUnitConfigurationGUI.php.

727 : void
728 {
729 if (!$this->isCRUDContext()) {
730 $this->{$this->getDefaultCommand()}();
731 return;
732 }
733
734 $this->initUnitCategoryForm();
735
736 $this->tpl->setContent($this->unit_cat_form->getHtml());
737 }

◆ showUnitCategoryModificationForm()

ilUnitConfigurationGUI::showUnitCategoryModificationForm ( )
protected

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

768 : void
769 {
770 if (!$this->isCRUDContext()) {
771 $this->{$this->getDefaultCommand()}();
772 return;
773 }
774
775 $category = $this->getCategoryById($this->request->int('category_id'));
776
777 $this->initUnitCategoryForm($category);
778 $this->unit_cat_form->setValuesByArray([
779 'category_name' => $category->getCategory()
780 ]);
781
782 $this->tpl->setContent($this->unit_cat_form->getHtml());
783 }

◆ showUnitCreationForm()

ilUnitConfigurationGUI::showUnitCreationForm ( )
protected

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

355 : void
356 {
357 if (!$this->isCRUDContext()) {
358 $this->showUnitsOfCategory();
359 return;
360 }
361
362 $category = $this->getCategoryById($this->request->int('category_id'));
363
364 $this->initUnitForm($category);
365 $this->unit_form->setValuesByArray([
366 'factor' => 1,
367 'unit_title' => $this->lng->txt('unit_placeholder')
368 ]);
369
370 $this->tpl->setContent($this->unit_form->getHtml());
371 }

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

+ Here is the call graph for this function:

◆ showUnitModificationForm()

ilUnitConfigurationGUI::showUnitModificationForm ( )
protected

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

303 : void
304 {
305 if (!$this->isCRUDContext()) {
306 $this->showUnitsOfCategory();
307 return;
308 }
309
310 $category = $this->getCategoryById($this->request->int('category_id'));
311 $unit = $this->repository->getUnit($this->request->int('unit_id'));
312
313 $this->initUnitForm($category, $unit);
314 $this->unit_form->setValuesByArray([
315 'factor' => $unit->getFactor(),
316 'unit_title' => $unit->getUnit(),
317 'base_unit' => $unit->getBaseUnit() !== $unit->getId() ? $unit->getBaseUnit() : 0
318 ]);
319
320 $this->tpl->setContent($this->unit_form->getHtml());
321 }

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: