README.md
1Scope Layout
2============
3The GlobalScreen service takes care of the mediation between the command classes and UI components and is responsible for assembling all necessary elements into a complete `Page` and submitting it to rendering.
4
5> Currently (ILIAS 6.0), the services and modules deliver their content via an `ilGlobalPageTemplate`, an implementation of the `ilGlobalTemplateInterface`. This is done for compatibility reasons. Internally, this instance delegates all relevant elements to the scope layout of the GlobalScreen service.
6
7The Scope `Layout` assumes by default that a completely filled `page` is displayed. This `page` is filled with UI components, which in turn are filled with information from the other areas (e.g. `MetaBar` or `MainBar`). Now not all places in ILIAS need the same `Page` or all elements of a `Page` anymore. For this purpose, a developer can influence the composition of the page from his code before passing it to rendering.
8
9He can do this for the whole page (e.g. without the `MainBar`) or he can provide a completely custom `MainBar` if required (e.g. LTI).
10
11All possibilities to change the components of a `page` can be found via the GlobalScreen service in the `DIC`:
12
13```php
14global $DIC;
15$DIC->globalScreen()->layout()->factory()->...
16```
17
18Currently the following areas can be addressed:
19- Page
20- MetaBar
21- MainBar
22- BreadCrumbs
23- Icon
24- Content
25
26## Register modification
27Like all other scopes, this scope works in the provider/collector procedure. In order to be able to make a change to the page, you implement your own `ModificationProvider`. These providers are `ScreenContextAwareProviders`, further information can be found at [src/GlobalScreen/ScreenContext/README.md](../../ScreenContext/README.md)
28
29```php
30<?php namespace ILIAS\Container\Screen;
31
32//...
33
34class MemberViewLayoutProvider extends AbstractModificationProvider implements ModificationProvider
35{
36
37 public function isInterestedInContexts() : ContextCollection
38 {
39 return $this->context_collection->repository();
40 }
41
42 public function getLogoModification(CalledContexts $screen_context_stack) : ?LogoModification
43 {
44 if (!$screen_context_stack->current()->hasReferenceId()) {
45 return null;
46 }
47
48 $mv = ilMemberViewSettings::getInstance();
49 if ($mv->isActive()) {
50 return $this->globalScreen()->layout()->factory()->logo()->withModification(function (Image $current) use ($mv) : Image {
51 $ref_id = $mv->getCurrentRefId();
52
53 $image = $this->dic->ui()->factory()->image()->responsive("https://www.colourbox.com/preview/5559052-icon-user-red.jpg", "mv");
54 if ($ref_id) {
55 $url = ilLink::_getLink(
56 $ref_id,
57 ilObject::_lookupType(ilObject::_lookupObjId($ref_id)),
58 array('mv' => 0)
59 );
60 $image = $image->withAction($url);
61 }
62
63 return $image;
64 })->withHighPriority();
65 }
66
67 return null;
68 }
69}
70
71```
72
73The example returns - if in the `ScreenContext` 'repository', if a Ref-ID is present and if the MemberView is used in a course, – a change to the logo (which is only offered as an example until a dedicated message for it is offered in the UI service).
74
75Since multiple `ModificationProviders` could modify the same area of the page at the same time, a priority is set for each modification (in this case `->withHighPriority()`). Same priorities lead to an exception and it must be decided in JourFixe which of the two modifications gets the higher priority.
76
77
78
79#Attention
80
81The possibility of influencing the components of the "page" holds dangers:
82- You can never be sure that you will not make any changes before or after the change.
83- Do not use this option to bring menu items or `Tools` into the `MainBar`. Use the methods provided for this purpose as `Providers` in the respective scopes.
84