ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMMTopParentItemRenderer.php
Go to the documentation of this file.
1 <?php
2 
13 
20 {
21 
25  public function getComponentForItem(isItem $item) : Component
26  {
27  global $DIC;
31  $tpl = new ilTemplate("tpl.mm_top_parent_item.html", false, false, 'Services/MainMenu');
32  $tpl->setVariable("TITLE", $item->getTitle());
33  $tpl->setVariable("ID", "mm_" . $item->getProviderIdentification()->getInternalIdentifier());
34 
35  $gl = new ilGroupedListGUI();
36  $gl->setAsDropDown(true);
37  foreach ($item->getChildren() as $child) {
38  $i = $child->getProviderIdentification()->getInternalIdentifier();
39  switch (true) {
40  case ($child instanceof hasContent && $child->getAsyncContentURL() === ''):
41  $this->handleContent($child, $gl);
42  break;
43  case ($child instanceof hasAsyncContent):
44  $this->handleAsyncContent($child, $gl);
45  break;
46  case ($child instanceof LinkList):
47  $this->handleLinkList($child, $gl, $i);
48  break;
49  case ($child instanceof Separator):
50  $this->handleSeparator($child, $gl);
51  break;
52  case ($child instanceof hasAction && $child instanceof hasTitle):
53  $this->addEntry($gl, $child, $i);
54  break;
55  case($child instanceof isItem):
56  default:
57  $com = $child->getTypeInformation()->getRenderer()->getComponentForItem($child);
58  $identifier = $child->getProviderIdentification()->getInternalIdentifier();
59  $target = $child instanceof hasAction ? ($child->isLinkWithExternalAction() ? "_blank" : "_top") : "_top";
60  $href = ($child instanceof hasAction) ? $child->getAction() : "#";
61  $tooltip = ilHelp::getMainMenuTooltip($identifier);
62  $a_id = "mm_" . $identifier;
63  $gl->addEntry(
64  $DIC->ui()->renderer()->render($com),
65  $href,
66  $target,
67  "",
68  "",
69  $a_id,
70  $tooltip,
71  "left center",
72  "right center",
73  false
74  );
75 
76  break;
77  }
78  }
79  $tpl->setVariable("CONTENT", $gl->getHTML());
80 
81  return $this->ui_factory->legacy($tpl->get());
82  }
83 
84 
89  private function handleSeparator($child, $gl)
90  {
91  if ($child->isTitleVisible()) {
92  $gl->addGroupHeader($child->getTitle());
93  } else {
94  $gl->addSeparator();
95  }
96  }
97 
98 
104  protected function addEntry(ilGroupedListGUI $gl, hasTitle $child, string $identifier)
105  {
106  $target = $child instanceof hasAction ? ($child->isLinkWithExternalAction() ? "_blank" : "_top") : "_top";
107  $href = ($child instanceof hasAction) ? $child->getAction() : "#";
108  $tooltip = ilHelp::getMainMenuTooltip($identifier);
109  $a_id = "mm_" . $child->getProviderIdentification()->getInternalIdentifier();
110  $gl->addEntry(
111  $child->getTitle(),
112  $href,
113  $target,
114  "",
115  "",
116  $a_id,
117  $tooltip,
118  "left center",
119  "right center",
120  false
121  );
122  }
123 
124 
131  private function handleAsyncContent($child, $gl)
132  {
133  $identifier = $child->getProviderIdentification()->getInternalIdentifier();
134  $atpl = new ilTemplate("tpl.self_loading_item.html", false, false, 'Services/MainMenu');
135  $atpl->setVariable("ASYNC_URL", $child->getAsyncContentURL());
136  $gl->addEntry(
137  $atpl->get(),
138  "#",
139  "_top",
140  "",
141  "",
142  $identifier,
143  ilHelp::getMainMenuTooltip($identifier),
144  "left center",
145  "right center",
146  false
147  );
148  }
149 
150 
157  private function handleContent(hasContent $child, $gl)
158  {
159  global $DIC;
160  $identifier = $child->getProviderIdentification()->getInternalIdentifier();
161  $gl->addEntry(
162  $DIC->ui()->renderer()->render($child->getContent()),
163  "#",
164  "_top",
165  "",
166  "",
167  $identifier,
168  ilHelp::getMainMenuTooltip($identifier),
169  "left center",
170  "right center",
171  false
172  );
173  }
174 
175 
181  private function handleLinkList($child, $gl, $i)
182  {
183  if (count($child->getLinks()) > 0) {
184  $gl->addGroupHeader($child->getTitle());
185  foreach ($child->getLinks() as $link) {
186  $this->addEntry($gl, $link, $i);
187  }
188  }
189  }
190 }
addEntry(ilGroupedListGUI $gl, hasTitle $child, string $identifier)
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
addEntry( $a_content, $a_href="", $a_target="", $a_onclick="", $a_add_class="", $a_id="", $a_ttip="", $a_tt_my="right center", $a_tt_at="left center", $a_tt_use_htmlspecialchars=true)
Add entry.
Grouped list GUI class.
special template class to simplify handling of ITX/PEAR
static getMainMenuTooltip($a_item_id)
Get main menu tooltip.
$i
Definition: disco.tpl.php:19
$target
Definition: test.php:19
Class ilMMTopParentItemRenderer.