ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Renderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
28 {
29  public function render(Component\Component $component, RendererInterface $default_renderer): string
30  {
31  if (!$component instanceof Component\Symbol\Avatar\Avatar) {
32  $this->cannotHandleComponent($component);
33  }
34 
35  $tpl = null;
36 
37  $label = $this->convertSpecialCharacters($component->getLabel());
38  if ($label == "") {
39  $label = $this->txt("user_avatar");
40  }
41 
45  if ($component instanceof Component\Symbol\Avatar\Letter) {
46  $tpl = $this->getTemplate('tpl.avatar_letter.html', true, true);
47  $tpl->setVariable('ARIA_LABEL', $label);
48  $tpl->setVariable('MODE', 'letter');
49  $tpl->setVariable('TEXT', $component->getAbbreviation());
50  $tpl->setVariable('COLOR', (string) $component->getBackgroundColorVariant());
51  } elseif ($component instanceof Component\Symbol\Avatar\Picture) {
52  $tpl = $this->getTemplate('tpl.avatar_picture.html', true, true);
53  $tpl->setVariable('ARIA_LABEL', $label);
54  $tpl->setVariable('MODE', 'picture');
55  $tpl->setVariable('CUSTOMIMAGE', $this->convertSpecialCharacters($component->getPicturePath()));
56  }
57 
58  return $tpl->get();
59  }
60 }
txt(string $id)
Get a text from the language file.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.