19 declare(strict_types=1);
43 protected ILIAS\
UI\Factory $ui_factory,
47 $this->
lng->loadLanguageModule(
'content');
48 $this->
lng->loadLanguageModule(
'obj');
53 $cmd = $this->
ctrl->getCmd(
'settings');
58 case self::CMD_CANCEL:
59 $content = $this->$cmd();
63 throw new ilException(
"ilObjLearningSequenceSettingsGUI: Command not supported: $cmd");
65 $this->tpl->setContent($content);
72 $this->
ctrl->getFormAction($this, self::CMD_SAVE)
78 $this->
ctrl->redirectByClass(ilObjLearningSequenceGUI::class);
85 $if = $this->ui_factory->input();
87 $form = $if->container()->form()->standard(
108 $title = $if->field()->text(
$txt(
"title"))
111 $description = $if->field()->text(
$txt(
"description"))
113 $section_object = $if->field()->section(
115 self::PROP_TITLE => $title,
116 self::PROP_DESC => $description
120 $formElements[
'object'] = $section_object;
123 $online = $if->field()->checkbox(
125 $txt(
'lso_activation_online_info')
126 )->withValue($activation->getIsOnline());
127 $online_start = $if->field()->dateTime(
$txt(
'from'))
129 ->withValue(($activation->getActivationStart()) ? $activation->getActivationStart()->format(
'Y-m-d H:i') :
'');
130 $online_end = $if->field()->dateTime(
$txt(
'to'))
132 ->withValue(($activation->getActivationEnd()) ? $activation->getActivationEnd()->format(
'Y-m-d H:i') :
'');
133 $section_online = $if->field()->section(
135 self::PROP_ONLINE => $online,
136 self::PROP_AVAIL_FROM => $online_start,
137 self::PROP_AVAIL_TO => $online_end
139 $txt(
'lso_settings_availability')
140 )->withAdditionalTransformation(
141 $this->
refinery->custom()->constraint(
143 $start = $values[self::PROP_AVAIL_FROM] ??
'';
144 $end = $values[self::PROP_AVAIL_TO] ??
'';
145 if (($start !==
'' && $end !==
'') && ($end < $start)) {
150 $txt(
'lso_settings_availability_error')
153 $formElements[
'online'] = $section_online;
156 $gallery = $if->field()->checkbox(
$txt(
"members_gallery"),
$txt(
'lso_show_members_info'))
157 ->withValue($settings->getMembersGallery())
160 $this->refinery->kindlyTo()->bool(),
164 $section_additional = $if->field()->section(
166 self::PROP_GALLERY => $gallery
170 $formElements[
'additional'] = $section_additional;
178 $header_actions = $lso->
getObjectProperties()->getPropertyHeaderActionVisibility()->toForm(
193 $section_common = $if->field()->section(
195 'icon' => $title_icon,
196 'header_actions' => $header_actions,
197 'custom_icon' => $custom_icon,
200 $txt(
'cont_presentation')
202 $formElements[
'common'] = $section_common;
204 return $formElements;
210 ->buildForm($this->obj, $this->
ctrl->getFormAction($this, self::CMD_SAVE))
211 ->withRequest($this->request);
213 $result = $form->getInputGroup()->getContent();
215 if ($result->isOK()) {
216 $values = $result->value();
219 $lso->setTitle($values[
'object'][self::PROP_TITLE]);
220 $lso->setDescription($values[
'object'][self::PROP_DESC]);
222 $settings = $lso->getLSSettings()
223 ->withMembersGallery($values[
'additional'][self::PROP_GALLERY]);
224 $lso->updateSettings($settings);
226 $activation = $lso->getLSActivation()
227 ->withIsOnline($values[
'online'][self::PROP_ONLINE])
228 ->withActivationStart(
null)
229 ->withActivationEnd(
null);
230 if ($values[
'online'][self::PROP_AVAIL_FROM] !==
null) {
231 $activation = $activation
232 ->withActivationStart(
233 DateTime::createFromImmutable($values[
'online'][self::PROP_AVAIL_FROM])
236 if ($values[
'online'][self::PROP_AVAIL_TO] !==
null) {
237 $activation = $activation
239 DateTime::createFromImmutable($values[
'online'][self::PROP_AVAIL_TO])
242 $lso->updateActivation($activation);
245 $lso->getObjectProperties()->storePropertyIsOnline(
249 $lso->getObjectProperties()->storePropertyTitleAndIconVisibility($values[
'common'][
'icon']);
250 $lso->getObjectProperties()->storePropertyHeaderActionVisibility($values[
'common'][
'header_actions']);
251 $lso->getObjectProperties()->storePropertyIcon($values[
'common'][
'custom_icon']);
252 $lso->getObjectProperties()->storePropertyTileImage($values[
'common'][
'image']);
256 $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"msg_obj_modified"),
true);
257 $this->
ctrl->redirect($this);
260 $this->tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
"msg_form_save_error"));
261 return $this->
renderer->render($form);
buildForm(ilObjLearningSequence $lso, string $submit_action)
Interface Observer Contains several chained tasks and infos about them.
__construct(protected ilObjLearningSequence $obj, protected ilCtrl $ctrl, protected ilLanguage $lng, protected ilGlobalTemplateInterface $tpl, protected ILIAS\Refinery\Factory $refinery, protected ILIAS\UI\Factory $ui_factory, protected ILIAS\UI\Renderer $renderer, protected Psr\Http\Message\ServerRequestInterface $request)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static isOffline(int $ref_id)
buildFormElements(ilObjLearningSequence $lso, ILIAS\UI\Component\Input\Factory $if)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getLongDescription()
get object long description (stored in object_description)