ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilIndividualAssessmentCommonSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6{
7 const CMD_EDIT = 'editSettings';
8 const CMD_SAVE = 'saveSettings';
9
13 protected $object;
14
18 protected $ctrl;
19
23 protected $tpl;
24
28 protected $lng;
29
33 protected $object_service;
34
35 public function __construct(
41 ) {
42 $this->object = $object;
43 $this->ctrl = $ctrl;
44 $this->tpl = $tpl;
45 $this->lng = $lng;
46 $this->object_service = $object_service;
47 }
48
49 public function executeCommand()
50 {
51 $cmd = $this->ctrl->getCmd();
52 switch($cmd) {
53 case self::CMD_EDIT:
54 $this->editSettings();
55 break;
56 case self::CMD_SAVE:
57 $this->saveSettings();
58 break;
59 default:
60 throw new Exception('Unknown command '.$cmd);
61 }
62 }
63
64 protected function editSettings(ilPropertyFormGUI $form = null)
65 {
66 if(is_null($form)) {
67 $form = $this->buildForm();
68 }
69 $this->tpl->setContent($form->getHTML());
70 }
71
72 protected function buildForm() : ilPropertyFormGUI
73 {
74 $form = new ilPropertyFormGUI();
75 $form->setFormAction($this->ctrl->getFormAction($this));
76 $form->setTitle($this->txt('obj_features'));
77 $form->addCommandButton(self::CMD_SAVE, $this->txt('save'));
78 $form->addCommandButton(self::CMD_EDIT, $this->txt('cancel'));
79
80 $this->addServiceSettingsToForm($form);
81 $this->addCommonFieldsToForm($form);
82
83 return $form;
84 }
85
87 {
89 $this->object->getId(),
90 $form,
91 [
94 ]
95 );
96 }
97
98 protected function addCommonFieldsToForm(ilPropertyFormGUI $form)
99 {
100 $section_appearance = new ilFormSectionHeaderGUI();
101 $section_appearance->setTitle($this->txt('cont_presentation'));
102 $form->addItem($section_appearance);
103 $form_service = $this->object_service->commonSettings()->legacyForm($form, $this->object);
104 $form = $form_service->addTitleIconVisibility();
105 $form = $form_service->addTopActionsVisibility();
106 $form = $form_service->addIcon();
107 $form = $form_service->addTileImage();
108 }
109
110 protected function saveSettings()
111 {
112 $form = $this->buildForm();
113
114 if(! $form->checkInput()) {
115 $form->setValuesByPost();
116 $this->editSettings($form);
117 return;
118 }
119
121 $this->object->getId(),
122 $form,
123 [
126 ]
127 );
128
129 $form_service = $this->object_service->commonSettings()->legacyForm($form, $this->object);
130 $form_service->saveTitleIconVisibility();
131 $form_service->saveTopActionsVisibility();
132 $form_service->saveIcon();
133 $form_service->saveTileImage();
134
135 ilUtil::sendSuccess($this->lng->txt('iass_settings_saved'), true);
136 $this->ctrl->redirect($this, self::CMD_EDIT);
137 }
138
139 protected function txt(string $code) : string
140 {
141 return $this->lng->txt($code);
142 }
143}
An exception for terminatinating execution or to throw for unit testing.
This class provides processing control methods.
This class represents a section header in a property form.
__construct(ilObjIndividualAssessment $object, ilCtrl $ctrl, ilGlobalTemplateInterface $tpl, ilLanguage $lng, ilObjectService $object_service)
language handling
For the purpose of streamlining the grading and learning-process status definition outside of tests,...
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).