ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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\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().

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  $image = $lso->getObjectProperties()->getPropertyTileImage()->toForm(
183  $this->lng,
184  $if->field(),
186  );
187  $section_common = $if->field()->section(
188  [
189  'icon' => $title_icon,
190  'header_actions' => $header_actions,
191  'image' => $image
192  ],
193  $txt('cont_presentation')
194  );
195  $formElements['common'] = $section_common;
196 
197  return $formElements;
198  }
$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 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(), ILIAS\Repository\ctrl(), and renderer().

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)
renderer()
+ Here is the call graph for this function:

◆ update()

ilObjLearningSequenceSettingsGUI::update ( )
protected

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

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

200  : ?string
201  {
202  $form = $this
203  ->buildForm($this->obj, $this->ctrl->getFormAction($this, self::CMD_SAVE))
204  ->withRequest($this->request);
205 
206  $result = $form->getInputGroup()->getContent();
207 
208  if ($result->isOK()) {
209  $values = $result->value();
210  $lso = $this->obj;
211 
212  $lso->setTitle($values['object'][self::PROP_TITLE]);
213  $lso->setDescription($values['object'][self::PROP_DESC]);
214 
215  $settings = $lso->getLSSettings()
216  ->withMembersGallery($values['additional'][self::PROP_GALLERY]);
217  $lso->updateSettings($settings);
218 
219  $activation = $lso->getLSActivation()
220  ->withIsOnline($values['online'][self::PROP_ONLINE])
221  ->withActivationStart(null)
222  ->withActivationEnd(null);
223  if ($values['online'][self::PROP_AVAIL_FROM] !== null) {
224  $activation = $activation
225  ->withActivationStart(
226  DateTime::createFromImmutable($values['online'][self::PROP_AVAIL_FROM])
227  );
228  }
229  if ($values['online'][self::PROP_AVAIL_TO] !== null) {
230  $activation = $activation
231  ->withActivationEnd(
232  DateTime::createFromImmutable($values['online'][self::PROP_AVAIL_TO])
233  );
234  }
235  $lso->updateActivation($activation);
236 
237  $status = ilObjLearningSequenceAccess::isOffline($lso->getRefId());
238  $lso->getObjectProperties()->storePropertyIsOnline(
239  new ilObjectPropertyIsOnline(! $status)
240  );
241 
242  $lso->getObjectProperties()->storePropertyTitleAndIconVisibility($values['common']['icon']);
243  $lso->getObjectProperties()->storePropertyHeaderActionVisibility($values['common']['header_actions']);
244  $lso->getObjectProperties()->storePropertyTileImage($values['common']['image']);
245 
246  $lso->update();
247 
248  $this->tpl->setOnScreenMessage("success", $this->lng->txt("msg_obj_modified"), true);
249  $this->ctrl->redirect($this);
250  return null;
251  } else {
252  $this->tpl->setOnScreenMessage("failure", $this->lng->txt("msg_form_save_error"));
253  return $this->renderer->render($form);
254  }
255  }
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 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: