ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
StandardPagePartProvider.php
Go to the documentation of this file.
2
3use ILIAS\GlobalScreen\Collector\Renderer\isSupportedTrait;
13use ilUserUtil;
14use ilUtil;
15
22{
23 use isSupportedTrait;
25
29 protected $content;
33 protected $gs;
37 protected $ui;
41 protected $lang;
42
46 public function __construct()
47 {
48 global $DIC;
49 $this->ui = $DIC->ui();
50 $this->gs = $DIC->globalScreen();
51 $this->lang = $DIC->language();
52 }
53
57 public function getContent() : ?Legacy
58 {
59 return $this->content ?? $this->ui->factory()->legacy("");
60 }
61
65 public function getMetaBar() : ?MetaBar
66 {
67 $this->gs->collector()->metaBar()->collectOnce();
68 if (!$this->gs->collector()->metaBar()->hasItems()) {
69 return null;
70 }
71 $f = $this->ui->factory();
72 $meta_bar = $f->mainControls()->metaBar();
73
74 foreach ($this->gs->collector()->metaBar()->getItemsForUIRepresentation() as $item) {
75 $component = $item->getRenderer()->getComponentForItem($item);
76 if ($this->isComponentSupportedForCombinedSlate($component)) {
77 $meta_bar = $meta_bar->withAdditionalEntry($item->getProviderIdentification()->getInternalIdentifier(), $component);
78 }
79 }
80
81 return $meta_bar;
82 }
83
87 public function getMainBar() : ?MainBar
88 {
89 $this->gs->collector()->mainmenu()->collectOnce();
90 if (!$this->gs->collector()->mainmenu()->hasItems()) {
91 return null;
92 }
93
94 $f = $this->ui->factory();
95 $main_bar = $f->mainControls()->mainBar();
96
97 foreach ($this->gs->collector()->mainmenu()->getItemsForUIRepresentation() as $item) {
101 $component = $item->getTypeInformation()->getRenderer()->getComponentForItem($item, false);
102 $identifier = $this->hash($item->getProviderIdentification()->serialize());
103
104 if ($this->isComponentSupportedForCombinedSlate($component)) {
105 $main_bar = $main_bar->withAdditionalEntry($identifier, $component);
106 }
107 }
108 $more_glyph = $f->symbol()->glyph()->more("#");
109 $main_bar = $main_bar->withMoreButton(
110 $f->button()->bulky($more_glyph, $this->lang->txt('more'), "#")
111 );
112
113 // Tools
114 $grid_icon = $f->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_tool.svg"), $this->lang->txt('more'));
115 $this->gs->collector()->tool()->collectOnce();
116 if ($this->gs->collector()->tool()->hasItems()) {
117 $tools_button = $f->button()->bulky($grid_icon, $this->lang->txt('tools'), "#")->withEngagedState(true);
118 $main_bar = $main_bar->withToolsButton($tools_button);
122 foreach ($this->gs->collector()->tool()->getItemsForUIRepresentation() as $tool) {
123 if (!$tool instanceof isToolItem) {
124 continue;
125 }
126 $component = $tool->getTypeInformation()->getRenderer()->getComponentForItem($tool, false);
127
128 $identifier = $this->hash($tool->getProviderIdentification()->serialize());
129 $close_button = null;
130 if ($tool->hasCloseCallback()) {
131 $close_button = $this->ui->factory()->button()->close()->withOnLoadCode(static function (string $id) use ($identifier) {
132 return "$('#$id').on('click', function(){
133 $.ajax({
134 url: 'src/GlobalScreen/Client/callback_handler.php?item=$identifier'
135 }).done(function() {
136 console.log('done closing');
137 });
138 });";
139 });
140 }
141 $main_bar = $main_bar->withAdditionalToolEntry($identifier, $component, $tool->isInitiallyHidden(), $close_button);
142 }
143 }
144
145 return $main_bar;
146 }
147
151 public function getBreadCrumbs() : ?Breadcrumbs
152 {
153 // TODO this currently gets the items from ilLocatorGUI, should that serve be removed with
154 // something like GlobalScreen\Scope\Locator\Item
155 global $DIC;
156
157 $f = $this->ui->factory();
158 $crumbs = [];
159 foreach ($DIC['ilLocator']->getItems() as $item) {
160 if (empty($item['title']) || empty($item['link'])) {
161 continue;
162 }
163 $crumbs[] = $f->link()->standard($item['title'], $item["link"]);
164 }
165
166 return $f->breadcrumbs($crumbs);
167 }
168
172 public function getLogo() : ?Image
173 {
174 $std_logo = ilUtil::getImagePath("HeaderIcon.svg");
175
176 return $this->ui->factory()->image()
177 ->standard($std_logo, "ILIAS")
178 ->withAction($this->getStartingPointAsUrl());
179 }
180
181 public function getResponsiveLogo() : ?Image
182 {
183 $responsive_logo = ilUtil::getImagePath("HeaderIconResponsive.svg");
184
185 return $this->ui->factory()->image()
186 ->standard($responsive_logo, "ILIAS")
187 ->withAction($this->getStartingPointAsUrl());
188 }
189
190 protected function getStartingPointAsUrl() : string
191 {
192 $std_logo_link = ilUserUtil::getStartingPointAsUrl();
193 if (!$std_logo_link) {
194 $std_logo_link = "./goto.php?target=root_1";
195 }
196 return $std_logo_link;
197 }
198
202 public function getFooter() : ?Footer
203 {
204 return $this->ui->factory()->mainControls()->footer([]);
205 }
206
210 public function getTitle() : string
211 {
212 return 'title';
213 }
214
218 public function getShortTitle() : string
219 {
220 return 'short';
221 }
222
226 public function getViewTitle() : string
227 {
228 return 'view';
229 }
230}
An exception for terminatinating execution or to throw for unit testing.
Class ilUserUtil.
static getStartingPointAsUrl()
Get current starting point setting as URL.
Util class various functions, usage as namespace.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This describes the Footer.
Definition: Footer.php:12
This describes the MainBar.
Definition: MainBar.php:16
This describes the MetaBar.
Definition: MetaBar.php:15
This describes the Combined Slate.
Definition: Combined.php:13
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46