ILIAS  release_8 Revision v8.24
StandardPagePartProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\GlobalScreen\Collector\Renderer\isSupportedTrait;
35use ilUserUtil;
36use ilUtil;
39use ilLanguage;
41
48{
49 use isSupportedTrait;
51
52 protected Legacy $content;
53 protected Services $gs;
54 protected UIServices $ui;
55 protected ilLanguage $lang;
56
60 public function __construct()
61 {
62 global $DIC;
63 $this->ui = $DIC->ui();
64 $this->gs = $DIC->globalScreen();
65 $this->lang = $DIC->language();
66 }
67
71 public function getContent(): ?Legacy
72 {
73 return $this->content ?? $this->ui->factory()->legacy("");
74 }
75
79 public function getMetaBar(): ?MetaBar
80 {
81 $this->gs->collector()->metaBar()->collectOnce();
82 if (!$this->gs->collector()->metaBar()->hasItems()) {
83 return null;
84 }
85 $f = $this->ui->factory();
86 $meta_bar = $f->mainControls()->metaBar();
87
88 foreach ($this->gs->collector()->metaBar()->getItemsForUIRepresentation() as $item) {
90 $component = $item->getRenderer()->getComponentForItem($item);
91 if ($this->isComponentSupportedForCombinedSlate($component)) {
92 $meta_bar = $meta_bar->withAdditionalEntry($item->getProviderIdentification()->getInternalIdentifier(), $component);
93 }
94 }
95
96 return $meta_bar;
97 }
98
102 public function getMainBar(): ?MainBar
103 {
104 // Collect all items which could be displayed in the main bar
105 $this->gs->collector()->mainmenu()->collectOnce();
106 $this->gs->collector()->tool()->collectOnce();
107
108 // If there are no items to display, return null. By definition, no MainBar is added to the Page in this case.
109 if (!$this->gs->collector()->mainmenu()->hasVisibleItems()
110 && !$this->gs->collector()->tool()->hasVisibleItems()) {
111 return null;
112 }
113
114 $f = $this->ui->factory();
115 $main_bar = $f->mainControls()->mainBar();
116
117 foreach ($this->gs->collector()->mainmenu()->getItemsForUIRepresentation() as $item) {
121 $component = $item->getTypeInformation()->getRenderer()->getComponentForItem($item, false);
122 $identifier = $this->hash($item->getProviderIdentification()->serialize());
123
124 if ($this->isComponentSupportedForCombinedSlate($component)) {
125 $main_bar = $main_bar->withAdditionalEntry($identifier, $component);
126 }
127 }
128
129 // Tools
130 $grid_icon = $f->symbol()->icon()->custom(ilUtil::getImagePath("icon_tool.svg"), $this->lang->txt('more'));
131
132 if ($this->gs->collector()->tool()->hasItems()) {
133 $tools_button = $f->button()->bulky($grid_icon, $this->lang->txt('tools'), "#")->withEngagedState(true);
134 $main_bar = $main_bar->withToolsButton($tools_button);
138 foreach ($this->gs->collector()->tool()->getItemsForUIRepresentation() as $tool) {
140 if (!$tool instanceof isToolItem) {
141 continue;
142 }
143 $component = $tool->getTypeInformation()->getRenderer()->getComponentForItem($tool, false);
144
145 $identifier = $this->hash($tool->getProviderIdentification()->serialize());
146 $close_button = null;
147 if ($tool->hasCloseCallback()) {
148 $close_button = $this->ui->factory()->button()->close()->withOnLoadCode(static function (string $id) use ($identifier) {
149 $key_item = CallbackHandler::KEY_ITEM;
150 return "$('#$id').on('click', function(){
151 $.ajax({
152 url: 'src/GlobalScreen/Client/callback_handler.php?$key_item=$identifier'
153 }).done(function() {
154 console.log('done closing');
155 });
156 });";
157 });
158 }
159 $main_bar = $main_bar->withAdditionalToolEntry($identifier, $component, $tool->isInitiallyHidden(), $close_button);
160 }
161 }
162
163 return $main_bar;
164 }
165
169 public function getBreadCrumbs(): ?Breadcrumbs
170 {
171 // TODO this currently gets the items from ilLocatorGUI, should that serve be removed with
172 // something like GlobalScreen\Scope\Locator\Item
173 global $DIC;
174
175 $f = $this->ui->factory();
176 $crumbs = [];
177 foreach ($DIC['ilLocator']->getItems() as $item) {
178 if (empty($item['title']) || empty($item['link'])) {
179 continue;
180 }
181 $crumbs[] = $f->link()->standard($item['title'], $item["link"]);
182 }
183
184 return $f->breadcrumbs($crumbs);
185 }
186
190 public function getLogo(): ?Image
191 {
192 $std_logo = ilUtil::getImagePath("HeaderIcon.svg");
193
194 return $this->ui->factory()->image()
195 ->standard($std_logo, $this->lang->txt('rep_main_page'))
196 ->withAction($this->getStartingPointAsUrl());
197 }
198
202 public function getResponsiveLogo(): ?Image
203 {
204 $responsive_logo = ilUtil::getImagePath("HeaderIconResponsive.svg");
205
206 return $this->ui->factory()->image()
207 ->standard($responsive_logo, $this->lang->txt('rep_main_page'))
208 ->withAction($this->getStartingPointAsUrl());
209 }
210
214 public function getFaviconPath(): string
215 {
216 return ilUtil::getImagePath("favicon.ico");
217 }
218
219 protected function getStartingPointAsUrl(): string
220 {
221 $std_logo_link = ilUserUtil::getStartingPointAsUrl();
222 if (!$std_logo_link) {
223 $std_logo_link = "./goto.php?target=root_1";
224 }
225 return $std_logo_link;
226 }
227
231 public function getSystemInfos(): array
232 {
233 $system_infos = [];
234
235 foreach ($this->gs->collector()->notifications()->getAdministrativeNotifications() as $adn) {
236 $system_infos[] = $adn->getRenderer($this->ui->factory())->getNotificationComponentForItem($adn);
237 }
238
239 return $system_infos;
240 }
241
245 public function getFooter(): ?Footer
246 {
247 return $this->ui->factory()->mainControls()->footer([]);
248 }
249
253 public function getTitle(): string
254 {
255 return 'title';
256 }
257
261 public function getShortTitle(): string
262 {
263 return 'short';
264 }
265
269 public function getViewTitle(): string
270 {
271 return 'view';
272 }
273
277 public function getToastContainer(): TContainer
278 {
279 $toast_container = $this->ui->factory()->toast()->container();
280
281 foreach ($this->gs->collector()->toasts()->getToasts() as $toast) {
282 $renderer = $toast->getRenderer();
283 $toast_container = $toast_container->withAdditionalToast($renderer->getToastComponentForItem($toast));
284 }
285
286 return $toast_container;
287 }
288}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
language handling
Class ilUserUtil.
Util class various functions, usage as namespace.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
This describes the Footer.
Definition: Footer.php:33
This describes the MainBar.
Definition: MainBar.php:34
This describes the MetaBar.
Definition: MetaBar.php:33
This describes the Combined Slate.
Definition: Combined.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...