19declare(strict_types=1);
37 if (!$component instanceof
Node\
Node) {
44 $tpl_name =
"tpl.node.html";
49 $tpl->setVariable(
"ASYNCURL", $component->getAsyncURL());
53 $icon = $component->getIcon();
54 $label = $component->getLabel();
56 if (!is_null($icon) && $icon->getLabel() === $label) {
61 $link = $component->getLink();
64 $linkAsString = $link->__toString();
66 $tpl->setVariable(
"LINK", $linkAsString);
67 $tpl->setVariable(
"LABEL_LINKED", $label);
69 $tpl->setVariable(
"ICON_LINKED", $default_renderer->render($icon));
72 $tpl->setVariable(
'BYLINE_LINKED', $component->getByline());
74 $tpl->setVariable(
'VALUE_LINKED', $component->getValue());
77 $tpl->setCurrentBlock(
"node_without_link");
78 $tpl->setVariable(
"LABEL", $label);
80 $tpl->setVariable(
"ICON", $default_renderer->render($icon));
83 $tpl->setVariable(
'BYLINE', $component->getByline());
85 $tpl->setVariable(
'VALUE', $component->getValue());
89 if ($component->isHighlighted()) {
90 $tpl->touchBlock(
"highlighted");
96 $triggered_signals = $component->getTriggeredSignals();
97 if (count($triggered_signals) > 0) {
98 $component = $this->triggerFurtherSignals($component, $triggered_signals);
103 $tpl->setCurrentBlock(
"li_id");
104 $tpl->setVariable(
"ID",
$id);
105 $tpl->parseCurrentBlock();
109 $subnodes = $component->getSubnodes();
111 if (count($subnodes) > 0 || $async) {
112 $tpl->touchBlock(
"expandable");
113 $tpl->setCurrentBlock(
"aria_expanded");
114 if ($component->isExpanded()) {
115 $tpl->setVariable(
"ARIA_EXPANDED",
"true");
117 $tpl->setVariable(
"ARIA_EXPANDED",
"false");
119 $tpl->parseCurrentBlock();
121 $subnodes_html = $default_renderer->render($subnodes);
122 $tpl->setVariable(
"SUBNODES", $subnodes_html);
125 if ($async || $link ===
null || count($subnodes) !== 0) {
126 $tpl->touchBlock(
"role_item");
128 $tpl->touchBlock(
"role_none");
139 protected function triggerFurtherSignals(
141 array $triggered_signals
144 foreach ($triggered_signals as $s) {
149 "signal_id" => $s->getSignal()->getId(),
150 "event" => $s->getEvent(),
151 "options" => $s->getSignal()->getOptions()
154 $signals = json_encode($signals);
156 return $component->withAdditionalOnLoadCode(fn(
$id) =>
"
157 $('#$id > span').click(function(e){
158 var node = $('#$id'),
161 for (var i = 0; i < signals.length; i++) {
163 node.trigger(s.signal_id, s);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
The scope of this class is split ilias-conform URI's into components.
Base class for all component renderers.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
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.
Interface to be extended by components that have the possibility to bind to Javascript.
This describes a Tree Node.
getAsyncLoading()
Should this node load its children asynchronously?
This describes a tree node with an byline providing additional information about this node.
getByline()
The byline string that will be displayed as additional information to the current node.
This describes a tree node in which the label is complemented by an additional string,...
getValue()
The value string that will be displayed behind the label of the node.
This describes a Tree Node.
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
An entity that renders components to a string output.