ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
StandardPagePartProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 use ilUserUtil;
34 use ilUtil;
37 use ilLanguage;
40 
47 {
48  use isSupportedTrait;
50 
51  protected Legacy $content;
52  protected Services $gs;
53  protected UIServices $ui;
54  protected ilLanguage $lang;
55 
56 
57  public function __construct()
58  {
59  global $DIC;
60  $this->ui = $DIC->ui();
61  $this->gs = $DIC->globalScreen();
62  $this->lang = $DIC->language();
63  }
64 
65 
66  public function getContent(): ?Content
67  {
68  return $this->content ?? $this->ui->factory()->legacy()->content("");
69  }
70 
71 
72  public function getMetaBar(): ?MetaBar
73  {
74  $this->gs->collector()->metaBar()->collectOnce();
75  if (!$this->gs->collector()->metaBar()->hasItems()) {
76  return null;
77  }
78  $f = $this->ui->factory();
79  $meta_bar = $f->mainControls()->metaBar();
80 
81  foreach ($this->gs->collector()->metaBar()->getItemsForUIRepresentation() as $item) {
83  $component = $item->getRenderer()->getComponentForItem($item);
84  if ($this->isComponentSupportedForCombinedSlate($component)) {
85  $meta_bar = $meta_bar->withAdditionalEntry($item->getProviderIdentification()->getInternalIdentifier(), $component);
86  }
87  }
88 
89  return $meta_bar;
90  }
91 
92 
93  public function getMainBar(): ?MainBar
94  {
95  // Collect all items which could be displayed in the main bar
96  $this->gs->collector()->mainmenu()->collectOnce();
97  $this->gs->collector()->tool()->collectOnce();
98 
99  // If there are no items to display, return null. By definition, no MainBar is added to the Page in this case.
100  if (!$this->gs->collector()->mainmenu()->hasVisibleItems()
101  && !$this->gs->collector()->tool()->hasVisibleItems()) {
102  return null;
103  }
104 
105  $f = $this->ui->factory();
106  $main_bar = $f->mainControls()->mainBar();
107 
108  foreach ($this->gs->collector()->mainmenu()->getItemsForUIRepresentation() as $item) {
112  $component = $item->getTypeInformation()->getRenderer()->getComponentForItem($item, false);
113  $identifier = $this->hash($item->getProviderIdentification()->serialize());
114 
115  if ($this->isComponentSupportedForCombinedSlate($component)) {
116  $main_bar = $main_bar->withAdditionalEntry($identifier, $component);
117  }
118  }
119 
120  // Tools
121  $grid_icon = $f->symbol()->icon()->custom(ilUtil::getImagePath("standard/icon_tool.svg"), $this->lang->txt('more'));
122 
123  if ($this->gs->collector()->tool()->hasItems()) {
124  $tools_button = $f->button()->bulky($grid_icon, $this->lang->txt('tools'), "#")->withEngagedState(true);
125  $main_bar = $main_bar->withToolsButton($tools_button);
129  foreach ($this->gs->collector()->tool()->getItemsForUIRepresentation() as $tool) {
131  if (!$tool instanceof isToolItem) {
132  continue;
133  }
134  $component = $tool->getTypeInformation()->getRenderer()->getComponentForItem($tool, false);
135 
136  $identifier = $this->hash($tool->getProviderIdentification()->serialize());
137  $close_button = null;
138  if ($tool->hasCloseCallback()) {
139  $close_button = $this->ui->factory()->button()->close()->withOnLoadCode(static function (string $id) use ($identifier): string {
140  $key_item = CallbackHandler::KEY_ITEM;
141  return "$('#$id').on('click', function(){
142  $.ajax({
143  url: 'callback_handler.php?$key_item=$identifier'
144  }).done(function() {
145  console.log('done closing');
146  });
147  });";
148  });
149  }
150  $main_bar = $main_bar->withAdditionalToolEntry($identifier, $component, $tool->isInitiallyHidden(), $close_button);
151  }
152  }
153 
154  return $main_bar;
155  }
156 
157 
158  public function getBreadCrumbs(): ?Breadcrumbs
159  {
160  // TODO this currently gets the items from ilLocatorGUI, should that serve be removed with
161  // something like GlobalScreen\Scope\Locator\Item
162  global $DIC;
163 
164  $f = $this->ui->factory();
165  $crumbs = [];
166  foreach ($DIC['ilLocator']->getItems() as $item) {
167  if (empty($item['title'])) {
168  continue;
169  }
170  if (empty($item['link'])) {
171  continue;
172  }
173  $crumbs[] = $f->link()->standard($item['title'], $item["link"]);
174  }
175 
176  return $f->breadcrumbs($crumbs);
177  }
178 
179 
180  public function getLogo(): ?Image
181  {
182  $std_logo = ilUtil::getImagePath("logo/HeaderIcon.svg");
183 
184  return $this->ui->factory()->image()
185  ->standard($std_logo, $this->lang->txt('rep_main_page'))
186  ->withAction($this->getStartingPointAsUrl());
187  }
188 
189 
190  public function getResponsiveLogo(): ?Image
191  {
192  $responsive_logo = ilUtil::getImagePath("logo/HeaderIconResponsive.svg");
193 
194  return $this->ui->factory()->image()
195  ->standard($responsive_logo, $this->lang->txt('rep_main_page'))
196  ->withAction($this->getStartingPointAsUrl());
197  }
198 
199 
200  public function getFaviconPath(): string
201  {
202  return ilUtil::getImagePath("logo/favicon.ico");
203  }
204 
205  protected function getStartingPointAsUrl(): string
206  {
207  $std_logo_link = ilUserUtil::getStartingPointAsUrl();
208  if ($std_logo_link === '' || $std_logo_link === '0') {
209  return "./goto.php?target=root_1";
210  }
211  return $std_logo_link;
212  }
213 
214 
215  public function getSystemInfos(): array
216  {
217  $system_infos = [];
218 
219  foreach ($this->gs->collector()->notifications()->getAdministrativeNotifications() as $adn) {
220  $system_infos[] = $adn->getRenderer($this->ui->factory())->getNotificationComponentForItem($adn);
221  }
222 
223  return $system_infos;
224  }
225 
226 
227  public function getFooter(): ?Footer
228  {
229  $footer = $this->ui->factory()->mainControls()->footer();
230  $renderer_factory = new FooterRendererFactory($this->ui);
231  $collector = $this->gs->collector()->footer();
232 
233  $collector->collectOnce();
234 
235  foreach ($collector->getItemsForUIRepresentation() as $item) {
236  $footer = $renderer_factory->addToFooter($item, $footer);
237  }
238 
239  return $footer;
240  }
241 
242 
243  public function getTitle(): string
244  {
245  return 'title';
246  }
247 
248 
249  public function getShortTitle(): string
250  {
251  return 'short';
252  }
253 
254 
255  public function getViewTitle(): string
256  {
257  return 'view';
258  }
259 
260 
261  public function getToastContainer(): TContainer
262  {
263  $toast_container = $this->ui->factory()->toast()->container();
264 
265  foreach ($this->gs->collector()->toasts()->getToasts() as $toast) {
266  $renderer = $toast->getRenderer();
267  $toast_container = $toast_container->withAdditionalToast($renderer->getToastComponentForItem($toast));
268  }
269 
270  return $toast_container;
271  }
272 }
$renderer
This describes the MainBar.
Definition: MainBar.php:33
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
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This describes the MetaBar.
Definition: MetaBar.php:32
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...