3declare(strict_types=1);
40 public function render(
Component $component, RendererInterface $default_renderer): string
45 return $this->renderNotification($component, $default_renderer);
46 } elseif ($component instanceof
Group) {
47 return $this->
renderGroup($component, $default_renderer);
48 } elseif ($component instanceof
Standard) {
50 } elseif ($component instanceof
Shy) {
51 return $this->
renderShy($component, $default_renderer);
56 protected function renderGroup(
Group $component, RendererInterface $default_renderer): string
63 foreach ($items as $item) {
64 $tpl->setCurrentBlock(
"item");
65 $tpl->setVariable(
"ITEM", $default_renderer->render($item));
66 $tpl->parseCurrentBlock();
70 $tpl->setCurrentBlock(
"title");
71 $tpl->setVariable(
"TITLE", $title);
72 $tpl->parseCurrentBlock();
77 if ($actions !==
null) {
78 $tpl->setVariable(
"ACTIONS", $default_renderer->render($actions));
80 $tpl->setVariable(
"ACTIONS",
"");
95 $color = $component->getColor();
96 if ($color !==
null) {
97 $tpl->setCurrentBlock(
"color");
98 $tpl->setVariable(
"COLOR", $color->asHex());
99 $tpl->parseCurrentBlock();
103 $lead = $component->getLead();
104 $progress = $component->getProgress();
106 if (is_string($lead)) {
107 if ($progress !=
null) {
108 $tpl->setCurrentBlock(
"lead_text_with_progress");
109 $tpl->touchBlock(
"item_with_lead_and_progress");
111 $tpl->setCurrentBlock(
"lead_text");
112 $tpl->touchBlock(
"item_with_lead_only");
114 $tpl->setVariable(
"LEAD_TEXT", $lead);
115 $tpl->parseCurrentBlock();
117 if ($lead instanceof
Image) {
118 if ($progress !=
null) {
119 $tpl->setCurrentBlock(
"lead_image_with_progress");
120 $tpl->touchBlock(
"item_with_lead_and_progress");
122 $tpl->setCurrentBlock(
"lead_image");
123 $tpl->touchBlock(
"item_with_lead_only");
125 $tpl->setVariable(
"LEAD_IMAGE", $default_renderer->render($lead));
126 $tpl->parseCurrentBlock();
128 if ($lead instanceof
Icon || $lead instanceof
Avatar) {
129 $tpl->setCurrentBlock(
"lead_icon");
130 $tpl->setVariable(
"LEAD_ICON", $default_renderer->render($lead));
131 $tpl->parseCurrentBlock();
132 $tpl->setCurrentBlock(
"lead_start_icon");
133 $tpl->parseCurrentBlock();
135 $tpl->setCurrentBlock(
"lead_start");
136 $tpl->parseCurrentBlock();
138 if ($progress !=
null && ($lead instanceof
Icon || $lead instanceof
Avatar)) {
139 $tpl->setCurrentBlock(
"progress_end_with_lead_icon");
140 $tpl->setVariable(
"PROGRESS", $default_renderer->render($progress));
141 $tpl->parseCurrentBlock();
142 } elseif ($progress !=
null) {
143 $tpl->setCurrentBlock(
"progress_end");
144 $tpl->setVariable(
"PROGRESS", $default_renderer->render($progress));
145 $tpl->parseCurrentBlock();
147 $tpl->touchBlock(
"lead_end");
149 } elseif ($progress !=
null) {
150 $tpl->touchBlock(
"item_with_progress_only");
151 $tpl->setCurrentBlock(
"progress_end");
152 $tpl->setVariable(
"PROGRESS", $default_renderer->render($progress));
153 $tpl->parseCurrentBlock();
157 $actions = $component->getActions();
158 if ($actions !==
null) {
159 $tpl->setVariable(
"ACTIONS", $default_renderer->render($actions));
165 protected function renderShy(
Shy $component, RendererInterface $default_renderer): string
172 if ($component->getProperties() !== []) {
173 foreach ($component->getProperties() as
$name => $value) {
176 $value = $default_renderer->render($value);
178 $value = htmlentities($value);
180 $tpl->setCurrentBlock(
"property_row");
182 $tpl->setVariable(
"PROP_VAL_A", $value);
183 $tpl->parseCurrentBlock();
185 $tpl->setCurrentBlock(
"properties");
186 $tpl->parseCurrentBlock();
189 if ($component->getLeadIcon() !==
null) {
190 $tpl->setCurrentBlock(
"lead_icon");
191 $tpl->setVariable(
"LEAD_ICON", $default_renderer->render($component->getLeadIcon()));
192 $tpl->parseCurrentBlock();
195 if ($component->getClose() !==
null) {
196 $tpl->setCurrentBlock(
"close");
197 $tpl->setVariable(
"CLOSE", $default_renderer->render($component->getClose()));
198 $tpl->parseCurrentBlock();
202 $tpl->setCurrentBlock(
"id");
204 $tpl->parseCurrentBlock();
210 protected function renderNotification(
Notification $component, RendererInterface $default_renderer): string
215 if (!is_null($desc) && trim($desc) !=
"") {
216 $tpl->setCurrentBlock(
"desc");
217 $tpl->setVariable(
"DESC", $desc);
218 $tpl->parseCurrentBlock();
221 $tpl->setVariable(
"LEAD_ICON", $default_renderer->render($component->
getLeadIcon()));
225 if ($actions !==
null) {
226 $tpl->setVariable(
"ACTIONS", $default_renderer->render($actions));
231 $tpl->setCurrentBlock(
"additional_content");
233 $tpl->parseCurrentBlock();
238 $aggregates_html = $default_renderer->render(
250 $component = $component->withAdditionalOnLoadCode(
251 fn (
$id) =>
"il.UI.item.notification.getNotificationItemObject($($id)).registerAggregates($toggleable);"
257 $tpl->setCurrentBlock(
"aggregate_notifications");
258 $tpl->setVariable(
"AGGREGATES", $aggregates_html);
259 $tpl->setVariable(
"PARENT_ID", $item_id);
260 $tpl->parseCurrentBlock();
268 $close_action = $this->
getUIFactory()->button()->close()->withAdditionalOnLoadCode(
269 fn (
$id) =>
"il.UI.item.notification.getNotificationItemObject($($id)).registerCloseAction('$url',1);"
271 $tpl->setVariable(
"CLOSE_ACTION", $default_renderer->render($close_action));
274 $tpl->setCurrentBlock(
"id");
275 $tpl->setVariable(
'ID', $item_id);
276 $tpl->parseCurrentBlock();
284 if ($title instanceof
Button\
Shy || $title instanceof
Link) {
285 $title = $default_renderer->render($title);
287 $title = htmlentities($title);
289 $tpl->setVariable(
"TITLE", $title);
296 if (!is_null($desc) && trim($desc) !=
"") {
297 $tpl->setCurrentBlock(
"desc");
298 $tpl->setVariable(
"DESC", htmlentities($desc));
299 $tpl->parseCurrentBlock();
305 RendererInterface $default_renderer,
309 $audio = $component->getAudioPlayer();
310 if (!is_null($audio)) {
311 $tpl->setCurrentBlock(
"audio");
312 $tpl->setVariable(
"AUDIO", $default_renderer->render($audio));
313 $tpl->parseCurrentBlock();
320 if (count($props) > 0) {
322 foreach ($props as
$name => $value) {
325 $value = $default_renderer->render($value);
333 $tpl->setCurrentBlock(
"property_row");
335 $tpl->setVariable(
"PROP_VAL_A", $value);
338 $tpl->setVariable(
"PROP_VAL_B", $value);
339 $tpl->parseCurrentBlock();
343 $tpl->parseCurrentBlock();
345 $tpl->setCurrentBlock(
"properties");
346 $tpl->parseCurrentBlock();
355 parent::registerResources($registry);
356 $registry->
register(
'./src/UI/templates/js/Item/dist/notification.js');
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
renderAudioPlayer(Item $component, RendererInterface $default_renderer, Template $tpl)
renderGroup(Group $component, RendererInterface $default_renderer)
renderShy(Shy $component, RendererInterface $default_renderer)
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
renderStandard(Item $component, RendererInterface $default_renderer)
getComponentInterfaceName()
Get the name of the component-interface this renderer is supposed to render.ATTENTION: Fully qualifie...
render(Component $component, RendererInterface $default_renderer)
renderTitle(Item $component, RendererInterface $default_renderer, Template $tpl)
renderProperties(Item $component, RendererInterface $default_renderer, Template $tpl)
renderDescription(Item $component, Template $tpl)
Base class for all component renderers.
txt(string $id)
Get a text from the language file.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
getUIFactory()
Get a UI factory.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
A component is the most general form of an entity in the UI.
Common interface to item groups.
getTitle()
Gets the title of the group.
getActions()
Get the actions Dropdown of the group.
getItems()
Gets item of the group.
Common interface to all items.
getProperties()
Get the properties of the appointment.
getDescription()
Get the description of the item.
getTitle()
Gets the title of the item.
getAggregateNotifications()
Get the list of Notification Items, this Notification Item aggregates or an empty list.
getAdditionalContent()
Get the additional content of the item or null.
getCloseAction()
Get the url attached to this Notification Item.
getActions()
Get the actions of the item.
getLeadIcon()
Get icon as lead.
getOnLoadCode()
Get the currently bound on load code.
This describes how a letter or a picture avatar could be modified during construction of UI.
This describes how an icon could be modified during construction of UI.
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.
An entity that renders components to a string output.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.