19declare(strict_types=1);
52 return $this->
renderButton($component, $default_renderer);
61 $tpl_name =
"tpl.primary.html";
64 $tpl_name =
"tpl.standard.html";
67 $tpl_name =
"tpl.shy.html";
70 $tpl_name =
"tpl.tag.html";
73 $tpl_name =
"tpl.bulky.html";
80 $action = $component->getAction();
83 if (is_string($action)) {
90 $symbol = $component->getSymbol();
91 if ($symbol !==
null) {
93 if (
'' === $component->getLabel() &&
'' === $component->getAriaLabel()) {
94 $component = $component->withAriaLabel($this->
getSymbolLabel($symbol));
97 $symbol = $symbol->withLabel(
'');
101 if ($component->isActive()) {
104 if (is_string($action) && $action !=
"") {
105 $component = $component->withAdditionalOnLoadCode(
function (
$id) use ($action) {
106 $action = str_replace(
"&",
"&", $action);
108 return "$('#$id').on('click', function(event) {
109 window.location = '$action';
116 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"$('#$id').click(function(e) { il.UI.button.activateLoadingAnimation('$id')});");
121 $aria_label = $component->getAriaLabel();
122 if ($aria_label !=
null) {
131 if ($component->isEngaged()) {
133 $aria_pressed =
'true';
135 $aria_pressed =
'false';
139 if (!($component instanceof
Bulky)) {
146 $tooltip_embedding = $this->
getTooltipRenderer()->getHelpTopicTooltipEmbedding(...$component->getHelpTopics());
147 if ($tooltip_embedding) {
148 $component = $component->withAdditionalOnLoadCode($tooltip_embedding[1]);
161 if (!$tooltip_embedding) {
170 return $tooltip_embedding[0]($tooltip_id,
$tpl->
get());
178 parent::registerResources($registry);
179 $registry->
register(
'assets/js/button.js');
207 $on_action = $component->getActionOn();
208 $off_action = $component->getActionOff();
210 $on_url = (is_string($on_action))
214 $off_url = (is_string($off_action))
220 foreach ($component->getTriggeredSignals() as $s) {
222 "signal_id" => $s->getSignal()->getId(),
223 "event" => $s->getEvent(),
224 "options" => $s->getSignal()->getOptions()
228 $signals = json_encode($signals);
230 $button_status =
'off';
231 if ($component->isEngaged()) {
232 $button_status =
'on';
235 if ($component->isActive()) {
236 $component = $component->withAdditionalOnLoadCode(
238 "$('#$id').on('click', function(event) {
239 il.UI.button.handleToggleClick(event, '$id', '$on_url', '$off_url', $signals);
240 return false; // stop event propagation
249 $button_status =
'unavailable';
254 $label = $component->getLabel();
255 if (!empty($label)) {
260 $aria_label = $component->getAriaLabel();
261 if ($aria_label !=
null) {
267 $tooltip_embedding = $this->
getTooltipRenderer()->getHelpTopicTooltipEmbedding(...$component->getHelpTopics());
268 if ($tooltip_embedding) {
269 $component = $component->withAdditionalOnLoadCode($tooltip_embedding[1]);
276 return $tooltip_embedding[0]($tooltip_id,
$tpl->
get());
297 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"il.UI.button.initMonth('$id');");
301 $def = $component->getDefault();
302 $value = implode(
'-', array_reverse(explode(
"-", $def)));
312 $classes = trim(join(
' ', $component->getClasses()));
313 if ($classes !==
'') {
317 $bgcol = $component->getBackgroundColor();
321 $forecol = $component->getForegroundColor();
329 RendererInterface $default_renderer,
332 $aria_role = $component->getAriaRole();
333 if ($aria_role !=
null) {
338 if ($component->isEngageable()) {
344 if ($component->isEngaged()) {
361 if (!$symbol instanceof
Glyph) {
365 $label = $this->txt($symbol->
getLabel());
366 foreach ($symbol->getCounters() as $counter) {
367 if ($counter->getNumber() > 0) {
368 $label .= $this->txt(
"counter_" . $counter->getType()) .
" " . $counter->getNumber() .
"; ";
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Base class for all component renderers.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
txt(string $id)
Get a text from the language file.
createId()
Get a fresh unique id.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
addTriggererOnLoadCode(Triggerer $triggerer)
Add onload-code for triggerer.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
touchBlock(string $block)
overwrites ITX::touchBlock.
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.
Interface to be extended by components that have the possibility to bind to Javascript.
This describes how an icon could be modified during construction of UI.
getLabel()
Get the label of this icon.
Registry for resources required by rendered output like Javascript or CSS.
register(string $name)
Add a dependency.
Interface to templating as it is used in the UI framework.
An entity that renders components to a string output.
readonly ilGlobalTemplateInterface $tpl