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