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