ILIAS  release_8 Revision v8.24
class.ilCheckboxListOverlayGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected ilLanguage $lng;
28 private array $items = array();
29 protected string $id;
30 protected string $link_title;
31 protected string $selectionheaderclass;
32 protected string $form_cmd;
33 protected string $field_var;
34 protected string $hidden_var;
35 protected \ilGlobalTemplateInterface $main_tpl;
36
37 public function __construct(
38 string $a_id = ""
39 ) {
40 global $DIC;
41
42 $this->lng = $DIC->language();
43 $this->setId($a_id);
44 $this->main_tpl = $DIC->ui()->mainTemplate();
45 }
46
47 public function setId(string $a_val): void
48 {
49 $this->id = $a_val;
50 }
51
52 public function getId(): string
53 {
54 return $this->id;
55 }
56
57 public function setLinkTitle(string $a_val): void
58 {
59 $this->link_title = $a_val;
60 }
61
62 public function getLinkTitle(): string
63 {
64 return $this->link_title;
65 }
66
67 public function setItems(array $a_val): void
68 {
69 $this->items = $a_val;
70 }
71
72 public function getItems(): array
73 {
74 return $this->items;
75 }
76
77 public function setSelectionHeaderClass(
78 string $a_selectionheaderclass
79 ): void {
80 $this->selectionheaderclass = $a_selectionheaderclass;
81 }
82
83 public function getSelectionHeaderClass(): string
84 {
85 return $this->selectionheaderclass;
86 }
87
88 public function setFormCmd(string $a_val): void
89 {
90 $this->form_cmd = $a_val;
91 }
92
93 public function getFormCmd(): string
94 {
95 return $this->form_cmd;
96 }
97
98 public function setFieldVar(string $a_val): void
99 {
100 $this->field_var = $a_val;
101 }
102
103 public function getFieldVar(): string
104 {
105 return $this->field_var;
106 }
107
108 public function setHiddenVar(string $a_val): void
109 {
110 $this->hidden_var = $a_val;
111 }
112
113 public function getHiddenVar(): string
114 {
115 return $this->hidden_var;
116 }
117
118 public function getHTML(bool $pull_right = true): string
119 {
121
122 $items = $this->getItems();
123
124 $tpl = new ilTemplate(
125 "tpl.checkbox_list_overlay.html",
126 true,
127 true,
128 "Services/UIComponent/CheckboxListOverlay",
129 "DEFAULT",
130 false,
131 true
132 );
133
134 $this->main_tpl->addOnLoadCode("$('#chkbxlstovl_" . $this->getId() . "').click(function(event){
135 event.stopPropagation();
136 });");
137
138 $tpl->touchBlock("top_img");
139
140 // do not repeat title (accessibility) -> empty alt
141 $tpl->setVariable("TXT_SEL_TOP", $this->getLinkTitle());
142
143 $tpl->parseCurrentBlock();
144
145 reset($items);
146 $cnt = 0;
147 foreach ($items as $k => $v) {
148 $tpl->setCurrentBlock("list_entry");
149 $tpl->setVariable("VAR", $this->getFieldVar());
150 $tpl->setVariable("VAL_ENTRY", $k);
151 $tpl->setVariable("TXT_ENTRY", $v["txt"]);
152 $tpl->setVariable("IDX_ENTRY", ++$cnt);
153 if ($v["selected"]) {
154 $tpl->setVariable("CHECKED", "checked='checked'");
155 }
156 $tpl->parseCurrentBlock();
157 }
158
159 if ($pull_right) {
160 $tpl->touchBlock("pr");
161 }
162
163 $tpl->setVariable("ID", $this->getId());
164 $tpl->setVariable("HIDDEN_VAR", $this->getHiddenVar());
165 $tpl->setVariable("CMD_SUBMIT", $this->getFormCmd());
166 $tpl->setVariable("VAL_SUBMIT", $lng->txt("refresh"));
167 return $tpl->get();
168 }
169}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSelectionHeaderClass(string $a_selectionheaderclass)
language handling
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$lng