ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 24 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 37 of file class.ilObjLearningSequenceSettingsGUI.php.

References ILIAS\Repository\lng().

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

Member Function Documentation

◆ buildForm()

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

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

References buildFormElements().

Referenced by settings().

85  $if = $this->ui_factory->input();
86 
87  $form = $if->container()->form()->standard(
88  $submit_action,
89  $this->buildFormElements(
90  $lso,
91  $if
92  )
93  );
94 
95  return $form;
96  }
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 98 of file class.ilObjLearningSequenceSettingsGUI.php.

References $id, ILIAS\UI\examples\Layout\Page\Standard\$refinery, $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().

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

◆ cancel()

ilObjLearningSequenceSettingsGUI::cancel ( )
protected

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

References ILIAS\Repository\ctrl().

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

◆ executeCommand()

ilObjLearningSequenceSettingsGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

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

◆ settings()

ilObjLearningSequenceSettingsGUI::settings ( )
protected

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

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

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

◆ update()

ilObjLearningSequenceSettingsGUI::update ( )
protected

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

References ILIAS\Repository\ctrl(), ilObjLearningSequenceAccess\isOffline(), ILIAS\Repository\lng(), null, and renderer().

207  : ?string
208  {
209  $form = $this
210  ->buildForm($this->obj, $this->ctrl->getFormAction($this, self::CMD_SAVE))
211  ->withRequest($this->request);
212 
213  $result = $form->getInputGroup()->getContent();
214 
215  if ($result->isOK()) {
216  $values = $result->value();
217  $lso = $this->obj;
218 
219  $lso->setTitle($values['object'][self::PROP_TITLE]);
220  $lso->setDescription($values['object'][self::PROP_DESC]);
221 
222  $settings = $lso->getLSSettings()
223  ->withMembersGallery($values['additional'][self::PROP_GALLERY]);
224  $lso->updateSettings($settings);
225 
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])
234  );
235  }
236  if ($values['online'][self::PROP_AVAIL_TO] !== null) {
237  $activation = $activation
238  ->withActivationEnd(
239  DateTime::createFromImmutable($values['online'][self::PROP_AVAIL_TO])
240  );
241  }
242  $lso->updateActivation($activation);
243 
244  $status = ilObjLearningSequenceAccess::isOffline($lso->getRefId());
245  $lso->getObjectProperties()->storePropertyIsOnline(
246  new Online(! $status)
247  );
248 
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']);
253 
254  $lso->update();
255 
256  $this->tpl->setOnScreenMessage("success", $this->lng->txt("msg_obj_modified"), true);
257  $this->ctrl->redirect($this);
258  return null;
259  } else {
260  $this->tpl->setOnScreenMessage("failure", $this->lng->txt("msg_form_save_error"));
261  return $this->renderer->render($form);
262  }
263  }
renderer()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

Field Documentation

◆ CMD_CANCEL

const ilObjLearningSequenceSettingsGUI::CMD_CANCEL = "cancel"

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

◆ CMD_EDIT

const ilObjLearningSequenceSettingsGUI::CMD_EDIT = "settings"

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

◆ CMD_SAVE

const ilObjLearningSequenceSettingsGUI::CMD_SAVE = "update"

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

◆ PROP_AVAIL_FROM

const ilObjLearningSequenceSettingsGUI::PROP_AVAIL_FROM = 'start'

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

◆ PROP_AVAIL_TO

const ilObjLearningSequenceSettingsGUI::PROP_AVAIL_TO = 'end'

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

◆ PROP_DESC

const ilObjLearningSequenceSettingsGUI::PROP_DESC = 'desc'

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

◆ PROP_GALLERY

const ilObjLearningSequenceSettingsGUI::PROP_GALLERY = 'gallery'

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

◆ PROP_ONLINE

const ilObjLearningSequenceSettingsGUI::PROP_ONLINE = 'online'

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

◆ PROP_TITLE

const ilObjLearningSequenceSettingsGUI::PROP_TITLE = 'title'

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


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