ILIAS
trunk Revision v11.0_alpha-2645-g16283d3b3f8
◀ ilDoc Overview
TooltipRenderer.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\UI\Implementation\Render
;
22
23
use
ILIAS\UI\HelpTextRetriever
;
24
use
ILIAS\UI\Help
;
25
30
class
TooltipRenderer
31
{
32
public
function
__construct
(
33
protected
HelpTextRetriever
$help_text_retriever,
34
protected
$get_template
35
) {
36
if
(!is_callable($this->get_template)) {
37
throw
new \InvalidArgumentException(
"\$get_template should be callable."
);
38
}
39
}
40
53
public
function
maybeGetTooltipEmbedding
(Help\
Topic
...
$topics
): ?array
54
{
55
if
(count($topics) === 0) {
56
return
null
;
57
}
58
59
$tooltips = $this->help_text_retriever->getHelpText(Help\Purpose::Tooltip(), ...$topics);
60
if
(count($tooltips) === 0) {
61
return
null
;
62
}
63
64
$get_template = $this->get_template;
65
$embed_html =
static
function
(
string
$tooltip_id,
string
$component_html) use ($tooltips, $get_template):
string
{
66
$tpl = $get_template(
"components/ILIAS/UI/src/templates/default/tpl.tooltip.html"
,
true
,
true
);
67
$tpl->setVariable(
"ELEMENT"
, $component_html);
68
$tpl->setVariable(
"TOOLTIP_ID"
, $tooltip_id);
69
70
foreach
($tooltips as $tooltip) {
71
$tpl->setCurrentBlock(
"tooltip"
);
72
$tpl->setVariable(
"TOOLTIP"
, $tooltip);
73
$tpl->parseCurrentBlock();
74
}
75
76
return
$tpl->get();
77
};
78
79
$embed_js =
static
function
(
$id
) {
80
return
"new il.UI.core.Tooltip(document.getElementById('$id'));"
;
81
};
82
83
return
[$embed_html, $embed_js];
84
}
85
}
ILIAS\UI\Help\Topic
This is just a class that marks a string as a help topic.
Definition:
Topic.php:26
ILIAS\UI\HelpTextRetriever
This describes a facility that the UI framework can use to retrieve some help text.
Definition:
HelpTextRetriever.php:39
null
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Definition:
shib_logout.php:144
ILIAS\UI\Implementation\Render
Definition:
AbstractComponentRenderer.php:21
ILIAS\GlobalScreen\Scope\$topics
array $topics
Definition:
ComponentDecoratorTrait.php:39
ILIAS\UI\Implementation\Render\TooltipRenderer
This class is supposed to unify rendering of tooltips over all components and should also be usable b...
Definition:
TooltipRenderer.php:30
ILIAS\UI\Implementation\Render\TooltipRenderer\__construct
__construct(protected HelpTextRetriever $help_text_retriever, protected $get_template)
Definition:
TooltipRenderer.php:32
$id
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition:
plugin.php:23
HelpTextRetriever
ILIAS\UI\Implementation\Render\TooltipRenderer\maybeGetTooltipEmbedding
maybeGetTooltipEmbedding(Help\Topic ... $topics)
This will provide functions that can be used to embed a components html into some html required for t...
Definition:
TooltipRenderer.php:53
ILIAS\UI\Help
Definition:
Purpose.php:21
components
ILIAS
UI
src
Implementation
Render
TooltipRenderer.php
Generated on Mon Sep 1 2025 23:04:22 for ILIAS by
1.8.13 (using
Doxyfile
)