19 declare(strict_types=1);
49 return $this->
renderButton($component, $default_renderer);
58 $tpl_name =
"tpl.primary.html";
61 $tpl_name =
"tpl.standard.html";
64 $tpl_name =
"tpl.shy.html";
67 $tpl_name =
"tpl.tag.html";
70 $tpl_name =
"tpl.bulky.html";
75 $action = $component->getAction();
78 if (is_string($action)) {
79 $tpl->setCurrentBlock(
"with_data_action");
80 $tpl->setVariable(
"ACTION", $action);
81 $tpl->parseCurrentBlock();
84 $tpl->setVariable(
"LABEL", $component->getLabel());
85 $symbol = $component->getSymbol();
86 if ($symbol !==
null) {
87 if ($component->getLabel() !==
'') {
88 $symbol = $symbol->withLabel(
'');
90 $tpl->setVariable(
"SYMBOL", $default_renderer->render($symbol));
93 if ($component->isActive()) {
96 if (is_string($action) && $action !=
"") {
97 $component = $component->withAdditionalOnLoadCode(
function (
$id) use ($action) {
98 $action = str_replace(
"&",
"&", $action);
100 return "$('#$id').on('click', function(event) { 101 window.location = '$action'; 108 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"$('#$id').click(function(e) { il.UI.button.activateLoadingAnimation('$id')});");
111 $tpl->touchBlock(
"disabled");
113 $aria_label = $component->getAriaLabel();
114 if ($aria_label !=
null) {
115 $tpl->setCurrentBlock(
"with_aria_label");
116 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
117 $tpl->parseCurrentBlock();
121 && $component->isEngageable()
123 if ($component->isEngaged()) {
124 $tpl->touchBlock(
"engaged");
125 $aria_pressed =
'true';
127 $aria_pressed =
'false';
131 if (!($component instanceof Bulky)) {
132 $tpl->setCurrentBlock(
"with_aria_pressed");
133 $tpl->setVariable(
"ARIA_PRESSED", $aria_pressed);
134 $tpl->parseCurrentBlock();
138 $tooltip_embedding = $this->
getTooltipRenderer()->maybeGetTooltipEmbedding(...$component->getHelpTopics());
139 if ($tooltip_embedding) {
140 $component = $component->withAdditionalOnLoadCode($tooltip_embedding[1]);
153 if (!$tooltip_embedding) {
158 $tpl->setCurrentBlock(
"with_aria_describedby");
159 $tpl->setVariable(
"ARIA_DESCRIBED_BY", $tooltip_id);
160 $tpl->parseCurrentBlock();
162 return $tooltip_embedding[0]($tooltip_id, $tpl->get());
170 parent::registerResources($registry);
171 $registry->
register(
'assets/js/button.js');
172 $registry->
register(
"./assets/js/moment-with-locales.min.js");
173 $registry->
register(
"./assets/js/bootstrap-datetimepicker.min.js");
178 $tpl = $this->
getTemplate(
"tpl.close.html",
true,
true);
181 $tpl->setVariable(
"FORCE_RENDERING",
"");
182 $tpl->setVariable(
"ARIA_LABEL", $this->
txt(
"close"));
189 $tpl = $this->
getTemplate(
"tpl.minimize.html",
true,
true);
190 $tpl->setVariable(
"ARIA_LABEL", $this->
txt(
"minimize"));
197 $tpl = $this->
getTemplate(
"tpl.toggle.html",
true,
true);
199 $on_action = $component->getActionOn();
200 $off_action = $component->getActionOff();
202 $on_url = (is_string($on_action))
206 $off_url = (is_string($off_action))
212 foreach ($component->getTriggeredSignals() as $s) {
214 "signal_id" => $s->getSignal()->getId(),
215 "event" => $s->getEvent(),
216 "options" => $s->getSignal()->getOptions()
220 $signals = json_encode($signals);
222 $button_status =
'off';
223 if ($component->isEngaged()) {
224 $button_status =
'on';
227 if ($component->isActive()) {
228 $component = $component->withAdditionalOnLoadCode(
230 "$('#$id').on('click', function(event) { 231 il.UI.button.handleToggleClick(event, '$id', '$on_url', '$off_url', $signals); 232 return false; // stop event propagation 235 $tpl->setCurrentBlock(
"with_on_off_label");
236 $tpl->setVariable(
"ON_LABEL", $this->
txt(
"toggle_on"));
237 $tpl->setVariable(
"OFF_LABEL", $this->
txt(
"toggle_off"));
238 $tpl->parseCurrentBlock();
240 $tpl->touchBlock(
"disabled");
241 $button_status =
'unavailable';
244 $tpl->touchBlock($button_status);
246 $label = $component->getLabel();
247 if (!empty($label)) {
248 $tpl->setCurrentBlock(
"with_label");
249 $tpl->setVariable(
"LABEL", $label);
250 $tpl->parseCurrentBlock();
252 $aria_label = $component->getAriaLabel();
253 if ($aria_label !=
null) {
254 $tpl->setCurrentBlock(
"with_aria_label");
255 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
256 $tpl->parseCurrentBlock();
259 $tooltip_embedding = $this->
getTooltipRenderer()->maybeGetTooltipEmbedding(...$component->getHelpTopics());
260 if ($tooltip_embedding) {
261 $component = $component->withAdditionalOnLoadCode($tooltip_embedding[1]);
263 $tpl->setCurrentBlock(
"with_aria_describedby");
264 $tpl->setVariable(
"ARIA_DESCRIBED_BY", $tooltip_id);
265 $tpl->parseCurrentBlock();
268 return $tooltip_embedding[0]($tooltip_id, $tpl->get());
287 $tpl = $this->
getTemplate(
"tpl.month.html",
true,
true);
289 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"il.UI.button.initMonth('$id');");
291 $tpl->setVariable(
"ID",
$id);
293 $def = $component->getDefault();
294 $value = implode(
'-', array_reverse(explode(
"-", $def)));
295 $tpl->setVariable(
"DEFAULT", $value);
302 $tpl->
touchBlock(
'rel_' . $component->getRelevance());
304 $classes = trim(join(
' ', $component->getClasses()));
305 if ($classes !==
'') {
309 $bgcol = $component->getBackgroundColor();
313 $forecol = $component->getForegroundColor();
324 $aria_role = $component->getAriaRole();
325 if ($aria_role !=
null) {
330 if ($component->isEngageable()) {
336 if ($component->isEngaged()) {
Registry for resources required by rendered output like Javascript or CSS.
txt(string $id)
Get a text from the language file.
setCurrentBlock(string $name)
Set the block to work on.
createId()
Get a fresh unique id.
setVariable(string $name, $value)
Set a variable in the current block.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
register(string $name)
Add a dependency.
parseCurrentBlock()
Parse the block that is currently worked on.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
touchBlock(string $name)
Touch a block without working further on it.
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.