ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LtiViewLayoutProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\LTI\Screen;
22 
37 
43 {
44  public const GS_EXIT_LTI = 'lti_exit_mode';
45 
47  {
48  return $this->context_collection->lti();
49  }
50 
56  public function getPageBuilderDecorator(CalledContexts $screen_context_stack): ?PageBuilderModification
57  {
58  $this->globalScreen()->layout()->meta()->addCss('./components/ILIAS/LTIProvider/templates/default/lti.css');
59  $is_exit_mode = $this->isLTIExitMode($screen_context_stack);
60  $external_css = ($is_exit_mode) ? '' : $this->dic["lti"]->getExternalCss();
61  if ($external_css !== '') {
62  $this->globalScreen()->layout()->meta()->addCss($external_css);
63  }
64 
65  return $this->factory->page()
66  ->withModification(
67  function (PagePartProvider $parts): Page {
68  $p = new StandardPageBuilder();
69  $page = $p->build($parts);
70 
71  $mv_modeinfo = MemberViewLayoutProvider::getMemberViewModeInfo($this->dic);
72  if ($mv_modeinfo) {
73  $page = $page->withModeInfo($mv_modeinfo);
74  }
75 
76  return $page->withNoFooter();
77  }
78  )
79  ->withHighPriority();
80  }
81 
82  protected function isLTIExitMode(CalledContexts $screen_context_stack): bool
83  {
84  $data_collection = $screen_context_stack->current()->getAdditionalData();
85  $is_exit_mode = $data_collection->is(self::GS_EXIT_LTI, true);
86  return $is_exit_mode;
87  }
88 
92  public function getMainBarModification(CalledContexts $screen_context_stack): ?MainBarModification
93  {
94  $is_exit_mode = $this->isLTIExitMode($screen_context_stack);
95 
96  return $this->globalScreen()->layout()->factory()->mainbar()
97  ->withModification(
98  function (?MainBar $mainbar) use ($is_exit_mode): ?MainBar {
99  $tools = $mainbar->getToolEntries();
100  $mainbar = $mainbar->withClearedEntries();
101  if ($is_exit_mode) {
102  return $mainbar;
103  }
104  foreach ($tools as $id => $entry) {
105  $mainbar = $mainbar->withAdditionalToolEntry($id, $entry);
106  }
107  //$mainbar = $mainbar->withAdditionalEntry('lti_home', $lti_home);
108  return $mainbar;
109  }
110  )
111  ->withHighPriority();
112  }
113 
117  public function getMetaBarModification(CalledContexts $screen_context_stack): ?MetaBarModification
118  {
119  $is_exit_mode = $this->isLTIExitMode($screen_context_stack);
120 
121  return $this->globalScreen()->layout()->factory()->metabar()
122  ->withModification(
123  function (?MetaBar $metabar) use ($is_exit_mode, $screen_context_stack): ?Metabar {
124  $metabar = $metabar->withClearedEntries();
125  if ($is_exit_mode) {
126  return $metabar;
127  }
128  $f = $this->dic->ui()->factory();
129  $exit_symbol = $f->symbol()->glyph()->close();
130  $exit_txt = $this->dic['lti']->lng->txt('lti_exit');
131  $exit = $f->button()->bulky($exit_symbol, $exit_txt, $this->dic["lti"]->getCmdLink('exit'));
132  $metabar = $metabar->withAdditionalEntry('exit', $exit);
133  return $metabar;
134  }
135  )
136  ->withHighPriority();
137  }
138 
143  public function getTitleModification(CalledContexts $screen_context_stack): ?TitleModification
144  {
145  $is_exit_mode = $this->isLTIExitMode($screen_context_stack);
146 
147  return $this->globalScreen()->layout()->factory()->title()
148  ->withModification(
149  function (?string $content) use ($is_exit_mode): string {
150  if ($is_exit_mode) {
151  return $this->dic["lti"]->getTitleForExitPage();
152  }
153  return $this->dic["lti"]->getTitle();
154  }
155  )
156  ->withHighPriority();
157  }
158 }
This describes the MainBar.
Definition: MainBar.php:33
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
withClearedEntries()
Get a copy of this MetaBar without any entries.
withAdditionalEntry(string $id, $entry)
Append an entry.
factory()
getTitleModification(CalledContexts $screen_context_stack)
getMetaBarModification(CalledContexts $screen_context_stack)
withClearedEntries()
Get a copy of this MainBar without any entries.
This describes the Page.
Definition: Page.php:30
This describes the MetaBar.
Definition: MetaBar.php:32
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
withAdditionalToolEntry(string $id, Slate\Slate $entry, bool $initially_hidden=false, ?Button\Close $close_button=null)
Append a tool-entry.
isLTIExitMode(CalledContexts $screen_context_stack)
getPageBuilderDecorator(CalledContexts $screen_context_stack)
getMainBarModification(CalledContexts $screen_context_stack)