19declare(strict_types=1);
40 public function render(
Component $component, RendererInterface $default_renderer): string
43 return $this->renderNotification($component, $default_renderer);
44 } elseif ($component instanceof
Group) {
45 return $this->
renderGroup($component, $default_renderer);
46 } elseif ($component instanceof
Standard) {
48 } elseif ($component instanceof
Shy) {
49 return $this->
renderShy($component, $default_renderer);
54 protected function renderGroup(
Group $component, RendererInterface $default_renderer): string
61 foreach ($items as $item) {
75 if ($actions !==
null) {
93 $color = $component->getColor();
94 if ($color !==
null) {
101 $lead = $component->getLead();
102 $progress = $component->getProgress();
104 if (is_string($lead)) {
105 if ($progress !=
null) {
115 if ($lead instanceof
Image) {
116 if ($progress !=
null) {
126 if ($lead instanceof
Icon || $lead instanceof
Avatar) {
136 if ($progress !=
null && ($lead instanceof
Icon || $lead instanceof
Avatar)) {
140 } elseif ($progress !=
null) {
147 } elseif ($progress !=
null) {
155 $main_action = $component->getMainAction();
156 if ($main_action !==
null) {
158 $tpl->
setVariable(
"MAIN_ACTION", $default_renderer->render($main_action));
163 $actions = $component->getActions();
164 if ($actions !==
null) {
173 protected function renderShy(
Shy $component, RendererInterface $default_renderer): string
180 if ($component->getProperties() !== []) {
181 foreach ($component->getProperties() as $name => $value) {
182 $name = htmlentities($name);
184 $value = $default_renderer->render($value);
186 $value = htmlentities($value);
197 if ($component->getLeadIcon() !==
null) {
199 $tpl->
setVariable(
"LEAD_ICON", $default_renderer->render($component->getLeadIcon()));
203 if ($component->getClose() !==
null) {
205 $tpl->
setVariable(
"CLOSE", $default_renderer->render($component->getClose()));
218 protected function renderNotification(
Notification $component, RendererInterface $default_renderer): string
223 if (!is_null($desc) && trim($desc) !=
"") {
233 if ($actions !==
null) {
246 $aggregates_html = $default_renderer->render(
258 $component = $component->withAdditionalOnLoadCode(
259 fn(
$id) =>
"il.UI.item.notification.getNotificationItemObject($('#$id')).registerAggregates($toggleable);"
276 $close_action = $this->
getUIFactory()->button()->close()->withAdditionalOnLoadCode(
277 fn(
$id) =>
"il.UI.item.notification.getNotificationItemObject($('#$id')).registerCloseAction('$url',1);"
279 $tpl->
setVariable(
"CLOSE_ACTION", $default_renderer->render($close_action));
292 if ($title instanceof
Button\
Shy || $title instanceof
Link) {
293 $title = $default_renderer->render($title);
295 $title = htmlentities($title);
304 if (!is_null($desc) && trim($desc) !=
"") {
313 RendererInterface $default_renderer,
317 $audio = $component->getAudioPlayer();
318 if (!is_null($audio)) {
328 if (count($props) > 0) {
330 foreach ($props as $name => $value) {
331 $name = htmlentities($name);
333 $value = $default_renderer->render($value);
363 parent::registerResources($registry);
364 $registry->
register(
'assets/js/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)
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.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
txt(string $id)
Get a text from the language file.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
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.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
touchBlock(string $block)
overwrites ITX::touchBlock.
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.
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.
readonly ilGlobalTemplateInterface $tpl
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.