ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilObjLearningSequenceSettingsGUI Class Reference
+ Collaboration diagram for ilObjLearningSequenceSettingsGUI:

Public Member Functions

 __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)
 
 executeCommand ()
 

Data Fields

const PROP_TITLE = 'title'
 
const PROP_DESC = 'desc'
 
const PROP_ONLINE = 'online'
 
const PROP_AVAIL_FROM = 'start'
 
const PROP_AVAIL_TO = 'end'
 
const PROP_GALLERY = 'gallery'
 
const CMD_EDIT = "settings"
 
const CMD_SAVE = "update"
 
const CMD_CANCEL = "cancel"
 

Protected Member Functions

 settings ()
 
 cancel ()
 
 buildForm (ilObjLearningSequence $lso, string $submit_action)
 
 buildFormElements (ilObjLearningSequence $lso, ILIAS\UI\Component\Input\Factory $if)
 
 update ()
 

Detailed Description

Definition at line 23 of file class.ilObjLearningSequenceSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjLearningSequenceSettingsGUI::__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 
)

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

References ILIAS\Repository\lng().

45  {
46  $this->lng->loadLanguageModule('content');
47  $this->lng->loadLanguageModule('obj');
48  }
+ Here is the call graph for this function:

Member Function Documentation

◆ buildForm()

ilObjLearningSequenceSettingsGUI::buildForm ( ilObjLearningSequence  $lso,
string  $submit_action 
)
protected

Definition at line 80 of file class.ilObjLearningSequenceSettingsGUI.php.

References buildFormElements().

Referenced by settings().

84  $if = $this->ui_factory->input();
85 
86  $form = $if->container()->form()->standard(
87  $submit_action,
88  $this->buildFormElements(
89  $lso,
90  $if
91  )
92  );
93 
94  return $form;
95  }
buildFormElements(ilObjLearningSequence $lso, ILIAS\UI\Component\Input\Factory $if)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFormElements()

ilObjLearningSequenceSettingsGUI::buildFormElements ( ilObjLearningSequence  $lso,
ILIAS\UI\Component\Input\Factory  $if 
)
protected

Definition at line 97 of file class.ilObjLearningSequenceSettingsGUI.php.

References $id, ILIAS\Repository\$refinery, ILIAS\LTI\ToolProvider\$settings, $txt, ilObject\getLongDescription(), ilObjLearningSequence\getLSActivation(), ilObjLearningSequence\getLSSettings(), ilObject\getObjectProperties(), ilObject\getTitle(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation().

Referenced by buildForm().

100  {
101  $txt = fn($id) => $this->lng->txt($id);
102  $settings = $lso->getLSSettings();
103  $activation = $lso->getLSActivation();
104  $formElements = [];
105 
106  // Title & Description
107  $title = $if->field()->text($txt("title"))
108  ->withRequired(true)
109  ->withValue($lso->getTitle());
110  $description = $if->field()->text($txt("description"))
111  ->withValue($lso->getLongDescription());
112  $section_object = $if->field()->section(
113  [
114  self::PROP_TITLE => $title,
115  self::PROP_DESC => $description
116  ],
117  $txt('lso_edit')
118  );
119  $formElements['object'] = $section_object;
120 
121  // Online status
122  $online = $if->field()->checkbox(
123  $txt('online'),
124  $txt('lso_activation_online_info')
125  )->withValue($activation->getIsOnline());
126  $online_start = $if->field()->dateTime($txt('from'))
127  ->withUseTime(true)
128  ->withValue(($activation->getActivationStart()) ? $activation->getActivationStart()->format('Y-m-d H:i') : '');
129  $online_end = $if->field()->dateTime($txt('to'))
130  ->withUseTime(true)
131  ->withValue(($activation->getActivationEnd()) ? $activation->getActivationEnd()->format('Y-m-d H:i') : '');
132  $section_online = $if->field()->section(
133  [
134  self::PROP_ONLINE => $online,
135  self::PROP_AVAIL_FROM => $online_start,
136  self::PROP_AVAIL_TO => $online_end
137  ],
138  $txt('lso_settings_availability')
139  )->withAdditionalTransformation(
140  $this->refinery->custom()->constraint(
141  function ($values) {
142  $start = $values[self::PROP_AVAIL_FROM] ?? '';
143  $end = $values[self::PROP_AVAIL_TO] ?? '';
144  if (($start !== '' && $end !== '') && ($end < $start)) {
145  return false;
146  }
147  return true;
148  },
149  $txt('lso_settings_availability_error')
150  )
151  );
152  $formElements['online'] = $section_online;
153 
154  // Member gallery
155  $gallery = $if->field()->checkbox($txt("members_gallery"), $txt('lso_show_members_info'))
156  ->withValue($settings->getMembersGallery())
158  $this->refinery->byTrying([
159  $this->refinery->kindlyTo()->bool(),
160  $this->refinery->always(false)
161  ])
162  );
163  $section_additional = $if->field()->section(
164  [
165  self::PROP_GALLERY => $gallery
166  ],
167  $txt('obj_features')
168  );
169  $formElements['additional'] = $section_additional;
170 
171  // Common properties
172  $title_icon = $lso->getObjectProperties()->getPropertyTitleAndIconVisibility()->toForm(
173  $this->lng,
174  $if->field(),
176  );
177  $header_actions = $lso->getObjectProperties()->getPropertyHeaderActionVisibility()->toForm(
178  $this->lng,
179  $if->field(),
181  );
182  $custom_icon = $lso->getObjectProperties()->getPropertyIcon()->toForm(
183  $this->lng,
184  $if->field(),
186  );
187  $image = $lso->getObjectProperties()->getPropertyTileImage()->toForm(
188  $this->lng,
189  $if->field(),
191  );
192  $section_common = $if->field()->section(
193  [
194  'icon' => $title_icon,
195  'header_actions' => $header_actions,
196  'custom_icon' => $custom_icon,
197  'image' => $image
198  ],
199  $txt('cont_presentation')
200  );
201  $formElements['common'] = $section_common;
202 
203  return $formElements;
204  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$txt
Definition: error.php:14
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getLongDescription()
get object long description (stored in object_description)
Refinery Factory $refinery
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilObjLearningSequenceSettingsGUI::cancel ( )
protected

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

References ILIAS\Repository\ctrl().

75  : void
76  {
77  $this->ctrl->redirectByClass(ilObjLearningSequenceGUI::class);
78  }
+ Here is the call graph for this function:

◆ executeCommand()

ilObjLearningSequenceSettingsGUI::executeCommand ( )

Definition at line 50 of file class.ilObjLearningSequenceSettingsGUI.php.

References ILIAS\Repository\ctrl().

50  : void
51  {
52  $cmd = $this->ctrl->getCmd('settings');
53 
54  switch ($cmd) {
55  case self::CMD_EDIT:
56  case self::CMD_SAVE:
57  case self::CMD_CANCEL:
58  $content = $this->$cmd();
59  break;
60 
61  default:
62  throw new ilException("ilObjLearningSequenceSettingsGUI: Command not supported: $cmd");
63  }
64  $this->tpl->setContent($content);
65  }
+ Here is the call graph for this function:

◆ settings()

ilObjLearningSequenceSettingsGUI::settings ( )
protected

Definition at line 67 of file class.ilObjLearningSequenceSettingsGUI.php.

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

67  : string
68  {
69  return $this->renderer->render($this->buildForm(
70  $this->obj,
71  $this->ctrl->getFormAction($this, self::CMD_SAVE)
72  ));
73  }
buildForm(ilObjLearningSequence $lso, string $submit_action)
+ Here is the call graph for this function:

◆ update()

ilObjLearningSequenceSettingsGUI::update ( )
protected

Definition at line 206 of file class.ilObjLearningSequenceSettingsGUI.php.

References ILIAS\LTI\ToolProvider\$settings, ILIAS\Repository\ctrl(), ilObjLearningSequenceAccess\isOffline(), and ILIAS\Repository\lng().

206  : ?string
207  {
208  $form = $this
209  ->buildForm($this->obj, $this->ctrl->getFormAction($this, self::CMD_SAVE))
210  ->withRequest($this->request);
211 
212  $result = $form->getInputGroup()->getContent();
213 
214  if ($result->isOK()) {
215  $values = $result->value();
216  $lso = $this->obj;
217 
218  $lso->setTitle($values['object'][self::PROP_TITLE]);
219  $lso->setDescription($values['object'][self::PROP_DESC]);
220 
221  $settings = $lso->getLSSettings()
222  ->withMembersGallery($values['additional'][self::PROP_GALLERY]);
223  $lso->updateSettings($settings);
224 
225  $activation = $lso->getLSActivation()
226  ->withIsOnline($values['online'][self::PROP_ONLINE])
227  ->withActivationStart(null)
228  ->withActivationEnd(null);
229  if ($values['online'][self::PROP_AVAIL_FROM] !== null) {
230  $activation = $activation
231  ->withActivationStart(
232  DateTime::createFromImmutable($values['online'][self::PROP_AVAIL_FROM])
233  );
234  }
235  if ($values['online'][self::PROP_AVAIL_TO] !== null) {
236  $activation = $activation
237  ->withActivationEnd(
238  DateTime::createFromImmutable($values['online'][self::PROP_AVAIL_TO])
239  );
240  }
241  $lso->updateActivation($activation);
242 
243  $status = ilObjLearningSequenceAccess::isOffline($lso->getRefId());
244  $lso->getObjectProperties()->storePropertyIsOnline(
245  new ilObjectPropertyIsOnline(! $status)
246  );
247 
248  $lso->getObjectProperties()->storePropertyTitleAndIconVisibility($values['common']['icon']);
249  $lso->getObjectProperties()->storePropertyHeaderActionVisibility($values['common']['header_actions']);
250  $lso->getObjectProperties()->storePropertyIcon($values['common']['custom_icon']);
251  $lso->getObjectProperties()->storePropertyTileImage($values['common']['image']);
252 
253  $lso->update();
254 
255  $this->tpl->setOnScreenMessage("success", $this->lng->txt("msg_obj_modified"), true);
256  $this->ctrl->redirect($this);
257  return null;
258  } else {
259  $this->tpl->setOnScreenMessage("failure", $this->lng->txt("msg_form_save_error"));
260  return $this->renderer->render($form);
261  }
262  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
+ Here is the call graph for this function:

Field Documentation

◆ CMD_CANCEL

const ilObjLearningSequenceSettingsGUI::CMD_CANCEL = "cancel"

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

◆ CMD_EDIT

const ilObjLearningSequenceSettingsGUI::CMD_EDIT = "settings"

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

◆ CMD_SAVE

const ilObjLearningSequenceSettingsGUI::CMD_SAVE = "update"

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

◆ PROP_AVAIL_FROM

const ilObjLearningSequenceSettingsGUI::PROP_AVAIL_FROM = 'start'

Definition at line 28 of file class.ilObjLearningSequenceSettingsGUI.php.

◆ PROP_AVAIL_TO

const ilObjLearningSequenceSettingsGUI::PROP_AVAIL_TO = 'end'

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

◆ PROP_DESC

const ilObjLearningSequenceSettingsGUI::PROP_DESC = 'desc'

Definition at line 26 of file class.ilObjLearningSequenceSettingsGUI.php.

◆ PROP_GALLERY

const ilObjLearningSequenceSettingsGUI::PROP_GALLERY = 'gallery'

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

◆ PROP_ONLINE

const ilObjLearningSequenceSettingsGUI::PROP_ONLINE = 'online'

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

◆ PROP_TITLE

const ilObjLearningSequenceSettingsGUI::PROP_TITLE = 'title'

Definition at line 25 of file class.ilObjLearningSequenceSettingsGUI.php.


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