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