19declare(strict_types=1);
57 if ($component instanceof
MainBar) {
58 return $this->renderMainbar($component, $default_renderer);
60 if ($component instanceof
MetaBar) {
61 return $this->renderMetabar($component, $default_renderer);
63 if ($component instanceof
Footer) {
64 return $this->
renderFooter($component, $default_renderer);
66 if ($component instanceof
ModeInfo) {
77 if (!$slate instanceof
Slate && !$slate instanceof
MainBar) {
81 ->withMainBarTreePosition($pos)
83 function ($num, $slate, $is_tool =
false) use ($pos) {
96 UITemplateWrapper
$tpl,
97 RendererInterface $default_renderer
99 $hidden = $component->getInitiallyHiddenToolIds();
102 $is_removeable = array_key_exists($entry_id, $close_buttons);
103 $is_hidden = in_array($entry_id, $hidden);
105 if ($is_removeable) {
106 $trigger_signal = $component->getTriggerSignal($mb_id, $component::ENTRY_ACTION_REMOVE);
107 $this->trigger_signals[] = $trigger_signal;
108 $btn_removetool = $close_buttons[$entry_id]
109 ->withAdditionalOnloadCode(
110 fn(
$id) =>
"il.UI.maincontrols.mainbar.addPartIdAndEntry('$mb_id', 'remover', '$id', true);"
112 ->withOnClick($trigger_signal);
115 $tpl->
setVariable(
"REMOVE_TOOL", $default_renderer->render($btn_removetool));
119 $is_removeable = $is_removeable ?
'true' :
'false';
120 $is_hidden = $is_hidden ?
'true' :
'false';
121 return "il.UI.maincontrols.mainbar.addToolEntry('$mb_id', $is_removeable, $is_hidden, '$entry_id');";
128 UITemplateWrapper
$tpl,
129 RendererInterface $default_renderer
132 foreach ($entries as $k => $entry) {
137 if ($entry instanceof
Slate) {
139 $mb_id = $entry->getMainBarTreePosition();
140 $is_tool = $block === static::BLOCK_MAINBAR_TOOLS;
142 $js = $this->renderToolEntry($k, $mb_id, $component,
$tpl, $default_renderer);
145 $trigger_signal = $component->getTriggerSignal($mb_id, $component::ENTRY_ACTION_TRIGGER);
146 $this->trigger_signals[] = $trigger_signal;
147 $button =
$f->button()->bulky($entry->getSymbol(), $entry->getName(),
'#')
148 ->withOnClick($trigger_signal)
149 ->withHelpTopics(...$entry->getHelpTopics());
152 $pos = array_search($k, array_keys($entries));
153 $mb_id =
'0:' . $pos;
157 $button = $button->withAdditionalOnLoadCode(
158 function (
$id) use ($js, $mb_id, $k, $is_tool):
string {
159 $add_as_tool = $is_tool ?
'true' :
'false';
161 il.UI.maincontrols.mainbar.addPartIdAndEntry('$mb_id', 'triggerer', '$id', $add_as_tool);
162 il.UI.maincontrols.mainbar.addMapping('$k','$mb_id');
166 )->withAriaRole(IBulky::MENUITEM);
173 if (!$entry instanceof LegacySlate) {
174 $entry = $entry->withAriaRole(ISlate::MENU);
184 protected function renderMainbar(MainBar $component, RendererInterface $default_renderer): string
187 $tpl = $this->getTemplate(
"tpl.mainbar.html",
true,
true);
190 $more_btn_label = $this->txt(
'mainbar_more_label');
194 $more_slate =
$f->mainControls()->slate()->combined(
196 $f->symbol()->glyph()->more()
198 $more_slate = $more_slate->withAriaRole(ISlate::MENU);
199 $component = $component->withAdditionalEntry(
203 $component = $this->calculateMainBarTreePosition(
"0", $component);
206 static::BLOCK_MAINBAR_ENTRIES => $component->getEntries(),
207 static::BLOCK_MAINBAR_TOOLS => $component->getToolEntries()
210 foreach ($mb_entries as $block => $entries) {
211 $this->renderMainbarEntry(
221 if (count($component->getToolEntries()) > 0) {
222 $btn_tools = $component->getToolsButton()
223 ->withOnClick($component->getToggleToolsSignal());
231 $btn_disengage =
$f->button()->bulky(
$f->symbol()->glyph()->collapseHorizontal(
"#"), $this->txt(
'close'),
"")
232 ->withOnClick($component->getDisengageAllSignal());
233 $tpl->
setVariable(
"CLOSE_SLATES", $default_renderer->render($btn_disengage));
236 $id = $this->bindMainbarJS($component);
242 protected function renderMetabar(MetaBar $component, RendererInterface $default_renderer): string
245 $tpl = $this->getTemplate(
"tpl.metabar.html",
true,
true);
248 'entry' => $component->getEntryClickSignal(),
249 'close_slates' => $component->getDisengageAllSignal()
251 $entries = $component->getEntries();
253 $more_label = $this->txt(
'show_more');
254 $more_symbol =
$f->symbol()->glyph()->disclosure()
255 ->withCounter(
$f->counter()->novelty(0))
256 ->withCounter(
$f->counter()->status(0));
260 $more_slate =
$f->mainControls()->slate()->combined($more_label, $more_symbol);
261 $more_slate = $more_slate->withAriaRole(ISlate::MENU);
262 $entries[] = $more_slate;
264 $this->renderTriggerButtonsAndSlates(
268 static::BLOCK_METABAR_ENTRIES,
273 $component = $component->withOnLoadCode(
274 function (
$id) use ($signals) {
275 $entry_signal = $signals[
'entry'];
276 $close_slates_signal = $signals[
'close_slates'];
278 il.UI.maincontrols.metabar.init('$id');
279 il.UI.maincontrols.metabar.get('$id').registerSignals(
281 '$close_slates_signal',
283 il.UI.maincontrols.metabar.get('$id').init();
284 window.addEventListener(
286 ()=>{il.UI.maincontrols.metabar.get('$id').init()}
293 $id = $this->bindJavaScript($component);
301 $tpl = $this->getTemplate(
"tpl.mode_info.html",
true,
true);
305 $action = $base_URI .
'?' . $query;
309 )->withSymbol(
$f->symbol()->glyph()->close());
317 RendererInterface $default_renderer
319 $tpl = $this->getTemplate(
"tpl.system_info.html", true, true);
323 switch ($component->getDenotation()) {
324 case Component\MainControls\SystemInfo::DENOTATION_NEUTRAL:
325 case Component\MainControls\SystemInfo::DENOTATION_IMPORTANT:
329 case Component\MainControls\SystemInfo::DENOTATION_BREAKING:
333 if ($component->isDismissable()) {
334 $signal = $component->getCloseSignal();
337 $tpl->
setVariable(
'CLOSE_URI', (
string) $component->getDismissAction());
338 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"$(document).on('$signal', function() { il.UI.maincontrols.system_info.close('$id'); });");
345 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"il.UI.maincontrols.system_info.init('$id')");
347 $id = $this->bindJavaScript($component);
357 UITemplateWrapper
$tpl,
358 RendererInterface $default_renderer,
362 ?
string $active =
null
368 if ($entry instanceof
Slate) {
370 $secondary_signal = $entry->getToggleSignal();
371 $clickable =
$f->button()->bulky($entry->getSymbol(), $entry->getName(),
'#')
373 ->withOnClick($entry_signal)
374 ->appendOnClick($secondary_signal)
375 ->withAriaRole(IBulky::MENUITEM)
376 ->withHelpTopics(...$entry->getHelpTopics());
379 } elseif ($entry instanceof IBulky) {
381 $clickable = $clickable->withAriaRole(IBulky::MENUITEM);
387 $clickable_html = $default_renderer->render($clickable);
403 $trigger_signals = $this->trigger_signals;
405 $this->toJS(
'close');
407 $inititally_active = $component->
getActive();
410 function (
$id) use ($component, $trigger_signals, $inititally_active):
string {
414 $js =
"il.UI.maincontrols.mainbar.addTriggerSignal('$disengage_all_signal');";
415 $js .=
"il.UI.maincontrols.mainbar.addTriggerSignal('$tools_toggle_signal');";
417 foreach ($trigger_signals as $signal) {
418 $js .=
"il.UI.maincontrols.mainbar.addTriggerSignal('$signal');";
422 $signal = $component->getEngageToolSignal($k);
423 $js .=
"il.UI.maincontrols.mainbar.addTriggerSignal('$signal');";
427 window.addEventListener('resize', il.UI.maincontrols.mainbar.adjustToScreenSize);
428 il.UI.maincontrols.mainbar.init('$inititally_active');
434 return $this->bindJavaScript($component);
439 if (!$this->isFooterVisible($component)) {
443 $template = $this->getTemplate(
"tpl.footer.html",
true,
true);
446 $permanent_url = $component->getPermanentURL();
447 if (
null !== $permanent_url) {
448 $permanent_link_transfer = $this->
getUIFactory()->transfer()->link(
449 Component\Transfer\TransferMechanism::CLIPBOARD,
451 $this->txt(
'footer_permanent_link'),
452 )->withAdditionalTransferMechanism(
453 Component\Transfer\TransferMechanism::WEB_SHARE,
456 $this->parseAdditionalFooterSectionItems(
460 $this->txt(
'footer_permanent_link'),
462 [$permanent_link_transfer,
null],
464 self::FOOTER_SECTION_SIZE_MEDIUM,
469 $additional_link_groups = $component->getAdditionalLinkGroups();
470 if ([] !== $additional_link_groups) {
472 foreach ($additional_link_groups as [$title, $actions]) {
473 $link_groups[] = [$this->
getUIFactory()->listing()->unordered($actions), $title];
476 $this->parseAdditionalFooterSectionItems(
480 $this->txt(
'footer_link_groups'),
482 self::FOOTER_SECTION_SIZE_SMALL,
487 $additional_links = $component->getAdditionalLinks();
488 if ([] !== $additional_links) {
489 $links = array_map(
static fn($link) => [$link,
null], $additional_links);
490 $this->parseAdditionalFooterSectionItems(
494 $this->txt(
'footer_links'),
496 self::FOOTER_SECTION_SIZE_SMALL,
501 $additional_icons = $component->getAdditionalIcons();
502 if ([] !== $additional_icons) {
504 foreach ($additional_icons as [$icon, $action]) {
505 if (
null !== $action) {
506 if ($action instanceof
URI) {
507 $action = (string) $action;
509 $icons[] = $this->
getUIFactory()->button()->shy(
'', $action)->withSymbol($icon);
515 $this->parseAdditionalFooterSectionIcons(
519 $this->txt(
'footer_icons'),
521 self::FOOTER_SECTION_SIZE_SMALL,
526 $additional_texts = $component->getAdditionalTexts();
527 if ([] !== $additional_texts) {
528 $texts = array_map(
static fn(
$text) => [
$text,
null], $additional_texts);
529 $this->parseAdditionalFooterSectionItems(
533 $this->txt(
'footer_texts'),
535 self::FOOTER_SECTION_SIZE_MEDIUM,
541 return $template->get() . $default_renderer->render($component->getModals());
550 RendererInterface $default_renderer,
551 string $section_type,
552 string $section_label,
553 array $section_items,
554 string $section_size,
556 foreach ($section_items as [$content, $title]) {
558 if (
null !== $title) {
559 $template->
setVariable(
'ITEM_TITLE', $this->convertSpecialCharacters($title));
562 $content = $default_renderer->render($content);
564 $content = $this->convertSpecialCharacters($content);
570 $this->parseFooterSection($template, $section_type, $section_label, $section_size);
579 RendererInterface $default_renderer,
580 string $section_type,
581 string $section_label,
582 array $section_icons,
583 string $section_size,
585 foreach ($section_icons as $icon) {
587 $template->
setVariable(
'ICON', $default_renderer->render($icon));
591 $this->parseFooterSection($template, $section_type, $section_label, $section_size);
597 string $section_type,
598 string $section_label,
599 string $section_size,
601 $template->setCurrentBlock(
'with_additional_section');
602 $template->
setVariable(
'SECTION_TYPE', $section_type);
603 $template->
setVariable(
'SECTION_LABEL', $section_label);
604 $template->
setVariable(
'SECTION_SIZE', $section_size);
610 return $component->getPermanentURL() !==
null
611 || !empty($component->getAdditionalLinkGroups())
612 || !empty($component->getAdditionalLinks())
613 || !empty($component->getAdditionalIcons())
614 || !empty($component->getAdditionalTexts());
622 parent::registerResources($registry);
623 $registry->
register(
'assets/js/mainbar.js');
624 $registry->
register(
'assets/js/maincontrols.min.js');
625 $registry->
register(
'assets/js/GS.js');
626 $registry->
register(
'assets/js/system_info.js');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
The scope of this class is split ilias-conform URI's into components.
renderSystemInfo(Component\MainControls\SystemInfo $component, RendererInterface $default_renderer)
renderToolEntry(string $entry_id, string $mb_id, MainBar $component, UITemplateWrapper $tpl, RendererInterface $default_renderer)
const BLOCK_METABAR_ENTRIES
renderModeInfo(ModeInfo $component, RendererInterface $default_renderer)
renderTriggerButtonsAndSlates(UITemplateWrapper $tpl, RendererInterface $default_renderer, Signal $entry_signal, string $block, array $entries, ?string $active=null)
const BLOCK_MAINBAR_TOOLS
renderFooter(I\Footer $component, RendererInterface $default_renderer)
bindMainbarJS(MainBar $component)
const FOOTER_SECTION_SIZE_SMALL
const FOOTER_SECTION_SIZE_MEDIUM
calculateMainBarTreePosition($pos, $slate)
parseFooterSection(Template $template, string $section_type, string $section_label, string $section_size,)
renderMainbarEntry(array $entries, string $block, MainBar $component, UITemplateWrapper $tpl, RendererInterface $default_renderer)
parseAdditionalFooterSectionIcons(Template $template, RendererInterface $default_renderer, string $section_type, string $section_label, array $section_icons, string $section_size,)
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
render(Component\Component $component, RendererInterface $default_renderer)
isFooterVisible(I\Footer $component)
const BLOCK_MAINBAR_ENTRIES
parseAdditionalFooterSectionItems(Template $template, RendererInterface $default_renderer, string $section_type, string $section_label, array $section_items, string $section_size,)
Base class for all component renderers.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
foreach( $report as $row)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
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.
withOnLoadCode(Closure $binder)
This describes the MainBar.
getCloseButtons()
Buttons to close tools; maybe configure with callback.
getToggleToolsSignal()
Signal to toggle the tools-section.
getDisengageAllSignal()
This signal disengages all slates when triggered.
This describes the MetaBar.
This describes the Legacy-Slate.
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.
readonly ilGlobalTemplateInterface $tpl
@ QR_CODE
Transfer information by copying its contents to the computers clipboard.