ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
TopParentItemDrilldownRenderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
32 
38 {
39  #[\Override]
40  public function getComponentWithContent(isItem $item): Component
41  {
42  $entries = [];
43  foreach ($item->getChildren() as $child) {
44  if (!$child->isVisible()) {
45  continue;
46  }
47  $component = $this->buildEntry($child, $item);
48  if ($component === null) {
49  continue;
50  }
51  $entries[] = $component;
52  }
53 
54  $dd = $this->ui_factory->menu()->drilldown($item->getTitle(), $entries);
55 
56  $slate = $this->ui_factory->mainControls()->slate()->drilldown(
57  $item->getTitle(),
58  $this->getStandardSymbol($item),
59  $dd
60  );
61 
62  return $slate;
63  }
64 
65  protected function buildEntry(AbstractChildItem $item, isTopItem $parent): ?Component
66  {
67  $title = $item->getTitle();
68  $symbol = $this->getStandardSymbol($item);
69  $type = $item::class;
70 
71  switch ($type) {
72  case RepositoryLink::class:
73  case Link::class:
74  // try if the link is already e valid URI
75  try {
76  $act = $this->getDataFactory()->uri($item->getAction());
77  } catch (\Throwable) {
78  $act = $this->getDataFactory()->uri(
79  $this->getBaseURL()
80  . '/'
81  . $item->getAction()
82  );
83  }
84 
85  $entry = $this->ui_factory->link()->bulky($symbol, $title, $act);
86  break;
87 
88  case LinkList::class:
89  $links = [];
90  foreach ($item->getLinks() as $child) {
91  if (!$child->isVisible()) {
92  continue;
93  }
94  $links[] = $this->buildEntry($child, $parent);
95  }
96  $entry = $this->ui_factory->menu()->sub($title, $links);
97  break;
98  case Separator::class:
99  $entry = $this->ui_factory->divider()->horizontal()->withLabel($title);
100  break;
101 
102  default:
103  $entry = $this->ui_factory->divider()->horizontal()->withLabel(
104  sprintf($this->txt('unable_to_render'), $title, $parent->getTitle())
105  );
106  }
107 
108  return $entry;
109  }
110 
111  protected function getDataFactory(): Factory
112  {
113  return new Factory();
114  }
115 
116  private function getBaseURL(): string
117  {
118  return ILIAS_HTTP_PATH;
119  }
120 
121  private function txt(string $key): string
122  {
123  return $this->lng->txt($key);
124  }
125 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Builds data types.
Definition: Factory.php:35
getComponentWithContent(isItem $item)
This is called in cases when the Full Item with it&#39;s content is needed, e.g.