ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ObjectSelectionListGUI.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
17 
22 {
23  protected \ILIAS\BookingManager\Objects\ObjectsManager $object_manager;
25  protected \ilLanguage $lng;
26  protected \ILIAS\DI\UIServices $ui;
27  protected string $form_action;
28 
29  public function __construct(
30  int $pool_id,
31  string $form_action
32  ) {
33  global $DIC;
34 
35  $this->ui = $DIC->ui();
36  $this->lng = $DIC->language();
37  $this->object_manager = $DIC->bookingManager()->internal()->domain()
38  ->objects($pool_id);
39  $this->form_action = $form_action;
40  $this->object_selection = $DIC->bookingManager()->internal()->domain()
41  ->objectSelection($pool_id);
42  }
43 
44  public function render() : string
45  {
46  $tpl = new \ilTemplate("tpl.obj_selection.html", true, true, "Modules/BookingManager/BookingProcess");
47 
48  $selected = $this->object_selection->getSelectedObjects();
49  foreach ($this->object_manager->getObjectTitles() as $id => $title) {
50  $tpl->setCurrentBlock("item");
51  if (in_array($id, $selected)) {
52  $tpl->setVariable("CHECKED", "checked='checked'");
53  }
54  $tpl->setVariable("ID", $id);
55  $tpl->setVariable("COLOR_NR", $this->object_manager->getColorNrForObject($id));
56  $tpl->setVariable("TITLE", $title);
57  $tpl->parseCurrentBlock();
58  }
59 
60  $tpl->setVariable("FORM_ACTION", $this->form_action);
61  $submit_button = $this->ui->factory()->button()->standard(
62  $this->lng->txt("book_refresh"),
63  "#"
64  )->withAdditionalOnLoadCode(function ($id) {
65  return <<<EOT
66  const book_submit_btn = document.getElementById('$id');
67  book_submit_btn.addEventListener("click", (event) => {
68  book_submit_btn.closest('form').submit(); return false;
69  });
70 EOT;
71  });
72  $tpl->setVariable("BUTTON", $this->ui->renderer()->render($submit_button));
73 
74  $p = $this->ui->factory()->panel()->secondary()->legacy(
75  $this->lng->txt("book_object_selection"),
76  $this->ui->factory()->legacy($tpl->get())
77  );
78  return $this->ui->renderer()->render($p);
79  }
80 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23