19 declare(strict_types=1);
53 if ($component instanceof
MainBar) {
54 return $this->renderMainbar($component, $default_renderer);
56 if ($component instanceof
MetaBar) {
57 return $this->renderMetabar($component, $default_renderer);
59 if ($component instanceof
Footer) {
60 return $this->
renderFooter($component, $default_renderer);
62 if ($component instanceof
ModeInfo) {
68 throw new LogicException(
"Cannot render: " . get_class($component));
73 if (!$slate instanceof
Slate && !$slate instanceof
MainBar) {
77 ->withMainBarTreePosition($pos)
79 function ($num, $slate, $is_tool =
false) use ($pos) {
98 $is_removeable = array_key_exists($entry_id, $close_buttons);
99 $is_hidden = in_array($entry_id, $hidden);
101 if ($is_removeable) {
102 $trigger_signal = $component->getTriggerSignal($mb_id, $component::ENTRY_ACTION_REMOVE);
103 $this->trigger_signals[] = $trigger_signal;
104 $btn_removetool = $close_buttons[$entry_id]
105 ->withAdditionalOnloadCode(
106 fn (
$id) =>
"il.UI.maincontrols.mainbar.addPartIdAndEntry('$mb_id', 'remover', '$id', true);" 108 ->withOnClick($trigger_signal);
110 $tpl->setCurrentBlock(
"tool_removal");
111 $tpl->setVariable(
"REMOVE_TOOL", $default_renderer->render($btn_removetool));
112 $tpl->parseCurrentBlock();
115 $is_removeable = $is_removeable ?
'true' :
'false';
116 $is_hidden = $is_hidden ?
'true' :
'false';
117 return "il.UI.maincontrols.mainbar.addToolEntry('$mb_id', $is_removeable, $is_hidden, '$entry_id');";
128 foreach ($entries as $k => $entry) {
133 if ($entry instanceof
Slate) {
135 $mb_id = $entry->getMainBarTreePosition();
136 $is_tool = $block === static::BLOCK_MAINBAR_TOOLS;
138 $js = $this->
renderToolEntry($k, $mb_id, $component, $tpl, $default_renderer);
141 $trigger_signal = $component->getTriggerSignal($mb_id, $component::ENTRY_ACTION_TRIGGER);
142 $this->trigger_signals[] = $trigger_signal;
143 $button =
$f->button()->bulky($entry->getSymbol(), $entry->getName(),
'#')
144 ->withOnClick($trigger_signal);
147 $pos = array_search($k, array_keys($entries));
148 $mb_id =
'0:' . $pos;
152 $button = $button->withAdditionalOnLoadCode(
153 function (
$id) use ($js, $mb_id, $k, $is_tool):
string {
154 $add_as_tool = $is_tool ?
'true' :
'false';
156 il.UI.maincontrols.mainbar.addPartIdAndEntry('$mb_id', 'triggerer', '$id', $add_as_tool); 157 il.UI.maincontrols.mainbar.addMapping('$k','$mb_id'); 161 )->withAriaRole(IBulky::MENUITEM);
163 $tpl->setCurrentBlock($block);
164 $tpl->setVariable(
"BUTTON", $default_renderer->render($button));
165 $tpl->parseCurrentBlock();
168 $entry = $entry->withAriaRole(ISlate::MENU);
170 $tpl->setCurrentBlock(
"slate_item");
171 $tpl->setVariable(
"SLATE", $default_renderer->render($entry));
172 $tpl->parseCurrentBlock();
182 $tpl->setVariable(
"ARIA_LABEL", $this->
txt(
'mainbar_aria_label'));
183 $more_btn_label = $this->
txt(
'mainbar_more_label');
187 $more_slate =
$f->mainControls()->slate()->combined(
189 $f->symbol()->glyph()->more()
191 $more_slate = $more_slate->withAriaRole(ISlate::MENU);
199 static::BLOCK_MAINBAR_ENTRIES => $component->
getEntries(),
203 foreach ($mb_entries as $block => $entries) {
218 $tpl->setCurrentBlock(
"tools_trigger");
219 $tpl->setVariable(
"BUTTON", $default_renderer->render($btn_tools));
220 $tpl->parseCurrentBlock();
224 $btn_disengage =
$f->button()->bulky(
$f->symbol()->glyph()->collapseHorizontal(
"#"), $this->
txt(
'close'),
"#")
226 $tpl->setVariable(
"CLOSE_SLATES", $default_renderer->render($btn_disengage));
246 $more_label = $this->
txt(
'show_more');
247 $more_symbol =
$f->symbol()->glyph()->disclosure()
248 ->withCounter(
$f->counter()->novelty(0))
249 ->withCounter(
$f->counter()->status(0));
253 $more_slate =
$f->mainControls()->slate()->combined($more_label, $more_symbol);
254 $more_slate = $more_slate->withAriaRole(ISlate::MENU);
255 $entries[] = $more_slate;
261 static::BLOCK_METABAR_ENTRIES,
267 function (
$id) use ($signals) {
268 $entry_signal = $signals[
'entry'];
269 $close_slates_signal = $signals[
'close_slates'];
271 il.UI.maincontrols.metabar.registerSignals( 274 '$close_slates_signal', 276 il.UI.maincontrols.metabar.init(); 277 $(window).resize(il.UI.maincontrols.metabar.init); 281 $tpl->setVariable(
'ARIA_LABEL', $this->
txt(
'metabar_aria_label'));
294 $action = $base_URI .
'?' .
$query;
295 $close = $this->
getUIFactory()->symbol()->glyph()->close($action);
296 $tpl->setVariable(
'CLOSE_GLYPH', $default_renderer->render($close));
306 $tpl->setVariable(
'HEADLINE', $component->getHeadLine());
307 $tpl->setVariable(
'BODY', $component->getInformationText());
308 $tpl->setVariable(
'DENOTATION', $component->getDenotation());
309 switch ($component->getDenotation()) {
312 $tpl->setVariable(
'LIVE',
'aria-live="polite"');
315 $tpl->setVariable(
'ROLE',
'role="alert"');
318 if ($component->isDismissable()) {
319 $close = $this->
getUIFactory()->symbol()->glyph()->close(
"#");
320 $signal = $component->getCloseSignal();
321 $close = $close->withOnClick($signal);
322 $tpl->setVariable(
'CLOSE_BUTTON', $default_renderer->render($close));
323 $tpl->setVariable(
'CLOSE_URI', (
string) $component->getDismissAction());
324 $component = $component->withAdditionalOnLoadCode(fn (
$id) =>
"$(document).on('$signal', function() { il.UI.maincontrols.system_info.close('$id'); });");
327 $more = $this->
getUIFactory()->symbol()->glyph()->more(
"#");
328 $tpl->setVariable(
'MORE_BUTTON', $default_renderer->render($more));
330 $component = $component->withAdditionalOnLoadCode(fn (
$id) =>
"il.UI.maincontrols.system_info.init('$id')");
334 $tpl->setVariable(
'ID_HEADLINE',
$id .
"_headline");
335 $tpl->setVariable(
'ID_DESCRIPTION',
$id .
"_description");
347 string $active = null
349 foreach ($entries as
$id => $entry) {
353 if ($entry instanceof
Slate) {
355 $secondary_signal = $entry->getToggleSignal();
356 $clickable =
$f->button()->bulky($entry->getSymbol(), $entry->getName(),
'#')
358 ->withOnClick($entry_signal)
359 ->appendOnClick($secondary_signal)
360 ->withAriaRole(IBulky::MENUITEM);
363 } elseif ($entry instanceof
IBulky) {
365 $clickable = $clickable->withAriaRole(IBulky::MENUITEM);
371 $clickable_html = $default_renderer->render($clickable);
374 $tpl->setCurrentBlock(
"slate_item");
375 $tpl->setVariable(
"SLATE", $default_renderer->render($slate));
376 $tpl->parseCurrentBlock();
379 $tpl->setCurrentBlock($use_block);
380 $tpl->setVariable(
"BUTTON", $clickable_html);
381 $tpl->parseCurrentBlock();
389 $inititally_active = $component->
getActive();
392 function (
$id) use ($component, $trigger_signals, $inititally_active):
string {
396 $js =
"il.UI.maincontrols.mainbar.addTriggerSignal('$disengage_all_signal');";
397 $js .=
"il.UI.maincontrols.mainbar.addTriggerSignal('$tools_toggle_signal');";
399 foreach ($trigger_signals as $signal) {
400 $js .=
"il.UI.maincontrols.mainbar.addTriggerSignal('$signal');";
405 $js .=
"il.UI.maincontrols.mainbar.addTriggerSignal('$signal');";
409 window.addEventListener('resize', il.UI.maincontrols.mainbar.adjustToScreenSize); 410 il.UI.maincontrols.mainbar.init('$inititally_active'); 423 $modalsWithTriggers = $component->
getModals();
424 $links = array_merge($links, array_column($modalsWithTriggers, 1));
427 $link_list = $this->
getUIFactory()->listing()->unordered($links);
428 $tpl->setVariable(
'LINKS', $default_renderer->render($link_list));
431 if ($modalsWithTriggers !== []) {
432 $tpl->setVariable(
'MODALS', $default_renderer->render(
433 array_column($modalsWithTriggers, 0)
440 if ($perm_url instanceof
URI) {
441 $url = $perm_url->__toString();
444 ->standard($this->
txt(
'perma_link'),
$url);
445 $tpl->setVariable(
'PERMANENT', $default_renderer->render($link));
455 parent::registerResources($registry);
456 $registry->
register(
'./src/UI/templates/js/MainControls/dist/mainbar.js');
457 $registry->
register(
'./src/UI/templates/js/MainControls/metabar.js');
458 $registry->
register(
'./src/GlobalScreen/Client/dist/GS.js');
459 $registry->
register(
'./src/UI/templates/js/MainControls/system_info.js');
Registry for resources required by rendered output like Javascript or CSS.
This describes the MainBar.
const DENOTATION_IMPORTANT
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
getDisengageAllSignal()
This signal disengages all slates when triggered.
getInitiallyHiddenToolIds()
There are tools that are rendered invisible before first activation.
calculateMainBarTreePosition($pos, $slate)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getComponentInterfaceName()
renderToolEntry(string $entry_id, string $mb_id, MainBar $component, UITemplateWrapper $tpl, RendererInterface $default_renderer)
const BLOCK_METABAR_ENTRIES
txt(string $id)
Get a text from the language file.
withOnLoadCode(Closure $binder)
getEntryClickSignal()
The Signal is triggered when any Entry is being clicked.
renderFooter(Footer $component, RendererInterface $default_renderer)
const BLOCK_MAINBAR_ENTRIES
getDisengageAllSignal()
This signal disengages all slates when triggered.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
renderSystemInfo(Component\MainControls\SystemInfo $component, RendererInterface $default_renderer)
renderModeInfo(ModeInfo $component, RendererInterface $default_renderer)
The scope of this class is split ilias-conform URI's into components.
const DENOTATION_BREAKING
const BLOCK_MAINBAR_TOOLS
withAdditionalEntry(string $id, $entry)
Append an entry.
bindMainbarJS(MainBar $component)
getToolsButton()
Returns the button of the tools-trigger.
register(string $name)
Add a dependency.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes the MetaBar.
renderMainbarEntry(array $entries, string $block, MainBar $component, UITemplateWrapper $tpl, RendererInterface $default_renderer)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getUIFactory()
Get a UI factory.
render(Component\Component $component, RendererInterface $default_renderer)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
getToggleToolsSignal()
Signal to toggle the tools-section.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
getEngageToolSignal(string $tool_id)
Signal to engage a tool from outside the MainBar.
getCloseButtons()
Buttons to close tools; maybe configure with callback.
Base class for all component renderers.
This describes the Footer.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderTriggerButtonsAndSlates(UITemplateWrapper $tpl, RendererInterface $default_renderer, Signal $entry_signal, string $block, array $entries, string $active=null)
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.