19declare(strict_types=1);
50 $tpl_name =
"tpl.standard.html";
55 if (is_array($items) && count($items) == 0) {
58 $this->
renderItems($items, $tpl, $default_renderer);
62 if ($label !==
null) {
63 $tpl->setVariable(
"LABEL", $component->
getLabel());
65 $tpl->setVariable(
"LABEL",
"");
73 : $this->
txt(
"actions");
74 $tpl->setCurrentBlock(
"aria_label");
75 $tpl->setVariable(
"ARIA_LABEL", $aria_label);
76 $tpl->parseCurrentBlock();
79 $component = $component->withAdditionalOnLoadCode(
81 "il.UI.dropdown.init(document.getElementById(\"$id\"));"
89 protected function renderItems(array $items,
Template $tpl, RendererInterface $default_renderer): void
91 foreach ($items as $item) {
93 $tpl->
setVariable(
"ITEM", $default_renderer->render($item));
117 parent::registerResources($registry);
118 $registry->
register(
'assets/js/dropdown.js');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This implements commonalities between different types of Dropdowns.
renderItems(array $items, Template $tpl, RendererInterface $default_renderer)
renderId(JavaScriptBindable $component, Template $tpl)
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
renderDropdown(Dropdown $component, RendererInterface $default_renderer)
render(Component\Component $component, RendererInterface $default_renderer)
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.
Interface to be extended by components that have the possibility to bind to Javascript.
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.
setVariable(string $name, $value)
Set a variable in the current block.
setCurrentBlock(string $name)
Set the block to work on.
parseCurrentBlock()
Parse the block that is currently worked on.
An entity that renders components to a string output.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.