ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\UI\examples\MainControls\MetaBar Namespace Reference

Functions

 base_metabar ()
 
 buildMetabar (\ILIAS\UI\Factory $f)
 
if( $request_wrapper->has( 'new_metabar_ui') &&$request_wrapper->retrieve( 'new_metabar_ui', $refinery->kindlyTo() ->int())===1) renderMetaBarInFullscreenMode (Container $dic)
 
 pageMetabarDemoContent (\ILIAS\UI\Factory $f)
 
 pageMetabarDemoCrumbs (\ILIAS\UI\Factory $f)
 
 pageMetabarDemoMainbar (\ILIAS\UI\Factory $f)
 
 pageMetabarDemoFooter (\ILIAS\UI\Factory $f)
 
 extended_example_for_developers ()
 
 buildMetabarWithNotifications ($f, $notification_center)
 
 handleAsyncRequestsIfAny (Container $dic)
 Handle async requests for the notification item. More...
 
 renderExtendedMetaBarInFullscreenMode (Container $dic)
 

Variables

global $DIC
 
 $request_wrapper = $DIC->http()->wrapper()->query()
 
 $refinery = $DIC->refinery()
 

Function Documentation

◆ base_metabar()

ILIAS\UI\examples\MainControls\MetaBar\base_metabar ( )

expected output: > ILIAS shows a link "See UI in fullscreen-mode". On clicking the link, a new page opens. The page has no entries in the mainbar and very(!) little content, but shows four icons in the metabar: search, help, notes and user. Only the notes-glyph is operable, it shows a little overlay with "some content"

when clicked.

Definition at line 36 of file base_metabar.php.

36 : string
37{
38 global $DIC;
39 $f = $DIC->ui()->factory();
40 $renderer = $DIC->ui()->renderer();
41
42 $url = $DIC->http()->request()->getUri()->__toString() . '&new_metabar_ui=1';
43 $txt = $f->legacy()->content('<p>
44 The Metabar Example opens in Fullscreen to showcase the behaviour of the metabar best.
45 Note, an comprensive example for developers on how to access the JS API of the Metabar
46 feature bellow in the second example.
47 </p>');
48
49 $page_demo = $f->link()->standard('See UI in fullscreen-mode', $url);
50
51 return $renderer->render([
52 $txt,
53 $page_demo
54 ]);
55}
$renderer
$url
Definition: shib_logout.php:70

References ILIAS\UI\examples\MainControls\MetaBar\$DIC, Vendor\Package\$f, $renderer, and $url.

◆ buildMetabar()

ILIAS\UI\examples\MainControls\MetaBar\buildMetabar ( \ILIAS\UI\Factory  $f)

Definition at line 57 of file base_metabar.php.

58{
59 $help = $f->button()->bulky($f->symbol()->glyph()->help(), 'Help', '#');
60 $search = $f->button()->bulky($f->symbol()->glyph()->search(), 'Search', '#');
61 $user = $f->button()->bulky($f->symbol()->glyph()->user(), 'User', '#');
62
63 $notes = $f->mainControls()->slate()->legacy(
64 'Notification',
65 $f->symbol()->glyph()->notification(),
66 $f->legacy()->content('some content')
67 );
68
69 return $f->mainControls()->metaBar()
70 ->withAdditionalEntry('search', $search)
71 ->withAdditionalEntry('help', $help)
72 ->withAdditionalEntry('notes', $notes)
73 ->withAdditionalEntry('user', $user);
74}
75
76global $DIC;
77$request_wrapper = $DIC->http()->wrapper()->query();
78$refinery = $DIC->refinery();
79if ($request_wrapper->has('new_metabar_ui')
80 && $request_wrapper->retrieve('new_metabar_ui', $refinery->kindlyTo()->int()) === 1
81) {
84 exit();
85}
static initILIAS()
ilias initialisation
exit
This describes the MetaBar.
Definition: MetaBar.php:33
if( $request_wrapper->has( 'new_metabar_ui') &&$request_wrapper->retrieve( 'new_metabar_ui', $refinery->kindlyTo() ->int())===1) renderMetaBarInFullscreenMode(Container $dic)

References Vendor\Package\$f.

Referenced by ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode().

+ Here is the caller graph for this function:

◆ buildMetabarWithNotifications()

ILIAS\UI\examples\MainControls\MetaBar\buildMetabarWithNotifications (   $f,
  $notification_center 
)

Definition at line 82 of file extended_example_for_developers.php.

83{
84 $help = $f->button()->bulky($f->symbol()->glyph()->help(), 'Help', '#');
85 $search = $f->button()->bulky($f->symbol()->glyph()->search(), 'Search', '#');
86 $user = $f->button()->bulky($f->symbol()->glyph()->user(), 'User', '#');
87
88
89 $metabar = $f->mainControls()->metabar()
90 ->withAdditionalEntry('search', $search)
91 ->withAdditionalEntry('help', $help)
92 ->withAdditionalEntry('notification', $notification_center)
93 ->withAdditionalEntry('user', $user);
94
95 return $metabar;
96}

References Vendor\Package\$f.

Referenced by ILIAS\UI\examples\MainControls\MetaBar\renderExtendedMetaBarInFullscreenMode().

+ Here is the caller graph for this function:

◆ extended_example_for_developers()

ILIAS\UI\examples\MainControls\MetaBar\extended_example_for_developers ( )

description: > This is a rather extended example on the usage of the Notification Item async functionality provided by src/UI/templates/js/Item/notification.js. See notification.js for a detailed description of the function. Note that we use some il.DemoScope to store some JS for Demo purposes, it contains the following three items:

  • DemoScopeRemaining: Integer, Counting how many Items are still there
  • DemoScopeAdded: Integer, Counting how many Items have been addedf
  • DemoScopeItem: Most importantly, the Notification Object for executing all the Async logic.

The functions of the public interface of interest featured here are:

  • getNotificationItemObject($item_or_object_inside_item): Most importantly, returning the Item Object, for access to all other functions of the interface.
  • replaceByAsyncItem(url,send_data): Replaces the item completely with a new retrieved async.
  • replaceContentByAsyncItemContent(url,send_data): Only replaces the data around the item (title, description and such)
  • addAsyncAggregate(url,send_data): Adds one aggregate retrieved async (the sub-like items).
  • getCounterObjectIfAny(): Gets an instance of the counter for manual manipulations.

Of further Interest could be (not featured here):

  • getCloseButtonOfItem(): Getting a jQuery instance of the close button, e.g. for attaching more interactions.

expected output: > ILIAS shows a link "See UI in fullscreen-mode". Clicking the link opens a standard page with the MetaBar in the header. The Notification Center in the MetaBar contains the Chat example with async functionality. The page content

provides buttons to add, reset or set chat notifications.

Returns
string

Definition at line 60 of file extended_example_for_developers.php.

60 : string
61{
62 global $DIC;
63 $f = $DIC->ui()->factory();
64 $renderer = $DIC->ui()->renderer();
65
66 $url = $DIC->http()->request()->getUri()->__toString() . '&extended_metabar_ui=1';
67 $txt = $f->legacy()->content('<p>
68 The extended MetaBar example opens in fullscreen to showcase the
69 Notification Item async functionality in the proper page layout.
70 Use the Notification Center (bell icon) in the MetaBar and the
71 buttons below to try the async features.
72 </p>');
73
74 $page_demo = $f->link()->standard('See UI in fullscreen-mode', $url);
75
76 return $renderer->render([
77 $txt,
78 $page_demo
79 ]);
80}
global $DIC
Definition: shib_login.php:26

References ILIAS\UI\examples\MainControls\MetaBar\$DIC, Vendor\Package\$f, $renderer, and $url.

◆ handleAsyncRequestsIfAny()

ILIAS\UI\examples\MainControls\MetaBar\handleAsyncRequestsIfAny ( Container  $dic)

Handle async requests for the notification item.

Exits if request was async.

Definition at line 101 of file extended_example_for_developers.php.

101 : void
102{
103 $f = $dic->ui()->factory();
104 $renderer = $dic->ui()->renderer();
105 $refinery = $dic->refinery();
106 $request_wrapper = $dic->http()->wrapper()->query();
107
108 $icon = $f->symbol()->icon()->standard("chtr", "chtr");
109 $title = $f->link()->standard("Some Title", "#");
110 $item = $f->item()->notification($title, $icon);
111
112 $async_close = $_SERVER['REQUEST_URI'] . '&close_item=true&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=false';
113 $closable_item = $item->withCloseAction($async_close);
114 $async_replace_url = $_SERVER['REQUEST_URI'] . '&close_item=false&async_load_replace=true&async_load_replace_content=false&async_add_aggregate=false';
115 $async_replace_content_load_url = $_SERVER['REQUEST_URI'] . '&close_item=false&async_load_replace=false&async_load_replace_content=true&async_add_aggregate=false';
116 $async_add_aggregate = $_SERVER['REQUEST_URI'] . '&close_item=false&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=true';
117
118 if ($request_wrapper->has('close_item') && $request_wrapper->retrieve('close_item', $refinery->kindlyTo()->string()) === "true") {
119 $js = $f->legacy()->content("")->withOnLoadCode(function ($id) use ($async_replace_content_load_url) {
120 return "
121 il.DemoScopeRemaining--;
122 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_content_load_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded});
123 ";
124 });
125 echo $renderer->renderAsync($js);
126 exit;
127 }
128
129 if ($request_wrapper->has('async_load_replace') && $request_wrapper->retrieve('async_load_replace', $refinery->kindlyTo()->string()) === "true") {
130 $remaining = $request_wrapper->retrieve("remaining", $refinery->kindlyTo()->int());
131 $added = $request_wrapper->retrieve("added", $refinery->kindlyTo()->int());
132
133 $items = [];
134 for ($i = 1; $i < $added + 1; $i++) {
135 $items[] = $closable_item->withDescription("This item is number: " . $i . " of a fix set of 10 entries.");
136 }
137 $replacement = $item->withDescription("Number of Async non-closed Aggregates: " . $remaining . ", totally created: " . $added)
138 ->withAggregateNotifications($items);
139
140 echo $renderer->renderAsync([$replacement]);
141 exit;
142 }
143
144 if ($request_wrapper->has('async_load_replace_content') && $request_wrapper->retrieve('async_load_replace_content', $refinery->kindlyTo()->string()) === "true") {
145 $remaining = $request_wrapper->retrieve("remaining", $refinery->kindlyTo()->int());
146 $added = $request_wrapper->retrieve("added", $refinery->kindlyTo()->int());
147 $replacement = $item->withDescription("Number of Async non-closed Aggregates: " . $remaining . ", totally created: " . $added);
148 echo $renderer->renderAsync([$replacement]);
149 exit;
150 }
151
152 if ($request_wrapper->has('async_add_aggregate') && $request_wrapper->retrieve('async_add_aggregate', $refinery->kindlyTo()->string()) === "true") {
153 $added = $request_wrapper->retrieve("added", $refinery->kindlyTo()->int());
154 $new_aggregate = $closable_item->withDescription("The item has been added, Nr: " . $added);
155 echo $renderer->renderAsync([$new_aggregate]);
156 exit;
157 }
158}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$dic
Definition: ltiresult.php:33
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

References $_SERVER, $dic, Vendor\Package\$f, $id, ILIAS\UI\examples\MainControls\MetaBar\$refinery, $renderer, ILIAS\UI\examples\MainControls\MetaBar\$request_wrapper, and exit.

◆ pageMetabarDemoContent()

ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoContent ( \ILIAS\UI\Factory  $f)

Definition at line 120 of file base_metabar.php.

120 : array
121{
122 return [
123 $f->panel()->standard(
124 'All about the Meta Bar',
125 $f->legacy()->content(
126 "See above"
127 )
128 ),
129 ];
130}

References Vendor\Package\$f.

Referenced by ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode().

+ Here is the caller graph for this function:

◆ pageMetabarDemoCrumbs()

ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoCrumbs ( \ILIAS\UI\Factory  $f)

Definition at line 132 of file base_metabar.php.

References Vendor\Package\$f.

Referenced by ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode().

+ Here is the caller graph for this function:

◆ pageMetabarDemoFooter()

ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoFooter ( \ILIAS\UI\Factory  $f)

Definition at line 142 of file base_metabar.php.

143{
144 $text = 'Footer';
145
146 return $f->mainControls()->footer()->withAdditionalText($text);
147}
$text
Definition: xapiexit.php:21

References Vendor\Package\$f, and $text.

Referenced by ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode().

+ Here is the caller graph for this function:

◆ pageMetabarDemoMainbar()

ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoMainbar ( \ILIAS\UI\Factory  $f)

Definition at line 137 of file base_metabar.php.

138{
139 return $f->mainControls()->mainBar();
140}
This describes the MainBar.
Definition: MainBar.php:34

References Vendor\Package\$f.

Referenced by ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode().

+ Here is the caller graph for this function:

◆ renderExtendedMetaBarInFullscreenMode()

ILIAS\UI\examples\MainControls\MetaBar\renderExtendedMetaBarInFullscreenMode ( Container  $dic)

Definition at line 160 of file extended_example_for_developers.php.

160 : string
161{
162 $f = $dic->ui()->factory();
163 $renderer = $dic->ui()->renderer();
164
165 $async_replace_url = $_SERVER['REQUEST_URI'] . '&close_item=false&async_load_replace=true&async_load_replace_content=false&async_add_aggregate=false';
166 $async_add_aggregate = $_SERVER['REQUEST_URI'] . '&close_item=false&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=true';
167
168 $icon = $f->symbol()->icon()->standard("chtr", "chtr");
169 $title = $f->link()->standard("Some Title", "#");
170 $item = $f->item()->notification($title, $icon);
171 $async_close = $_SERVER['REQUEST_URI'] . '&close_item=true&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=false';
172 $closable_item = $item->withCloseAction($async_close);
173
174 $add_button = $f->button()->standard("Add Chat Notification", "#")
175 ->withAdditionalOnLoadCode(function ($id) use ($async_replace_url, $async_add_aggregate) {
176 return "
177 $('#$id').click(function() {
178 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(1);
179 il.DemoScopeAdded++;
180 il.DemoScopeRemaining++;
181 il.DemoScopeItem.addAsyncAggregate('$async_add_aggregate',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded});
182 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded});
183 });";
184 });
185
186 $reset_button = $f->button()->standard("Reset Chat", "#")
187 ->withAdditionalOnLoadCode(function ($id) use ($async_replace_url) {
188 return "
189 $('#$id').click(function() {
190 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining);
191 il.DemoScopeAdded = 0;
192 il.DemoScopeRemaining = 0;
193 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded});
194 });";
195 });
196
197 $set_button = $f->button()->standard("Set to 10 chat entries", "#")
198 ->withAdditionalOnLoadCode(function ($id) use ($async_replace_url) {
199 return "
200 $('#$id').click(function() {
201 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining);
202 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(10);
203 il.DemoScopeAdded = 10;
204 il.DemoScopeRemaining = 10;
205 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded});
206 });";
207 });
208
209 $async_item = $item
210 ->withDescription("This is the original Version after the Page has loaded. Will be replaced completely.")
211 ->withAdditionalOnLoadCode(function ($id) {
212 return "
213 il.DemoScopeAdded = 0;
214 il.DemoScopeRemaining = 0;
215 il.DemoScopeItem = il.UI.item.notification.getNotificationItemObject($($id));
216 ";
217 });
218
219 $async_slate = $f->mainControls()->slate()->notification("Chat", [$async_item]);
220
221 $mail_icon = $f->symbol()->icon()->standard("mail", "mail");
222 $mail_title = $f->link()->standard("Inbox", "link_to_inbox");
223 $mail_notification_item = $f->item()->notification($mail_title, $mail_icon)
224 ->withDescription("You have 23 unread mails in your inbox")
225 ->withProperties(["Time" => "3 days ago"]);
226 $mail_slate = $f->mainControls()->slate()->notification("Mail", [$mail_notification_item]);
227
228
229 $notification_glyph = $f->symbol()->glyph()->notification("notification", "notification")
230 ->withCounter($f->counter()->novelty(1));
231
232 $notification_center = $f->mainControls()->slate()
233 ->combined("Notification Center", $notification_glyph)
234 ->withAdditionalEntry($async_slate)
235 ->withAdditionalEntry($mail_slate);
236
237 $metabar = buildMetabarWithNotifications($f, $notification_center);
238
239 $logo = $f->image()->responsive("assets/images/logo/HeaderIcon.svg", "ILIAS");
240 $responsive_logo = $f->image()->responsive("assets/images/logo/HeaderIconResponsive.svg", "ILIAS");
241 $breadcrumbs = $f->breadcrumbs([]);
242 $mainbar = $f->mainControls()->mainBar();
243 $footer = $f->mainControls()->footer()->withAdditionalText('Footer');
244 $tc = $dic->ui()->factory()->toast()->container();
245
246 $content = [
247 $f->panel()->standard(
248 'Notification Item Async Demo',
249 $f->legacy()->content(
250 "Use the Notification Center (bell icon) in the MetaBar above, then try these buttons:<br /><br />"
251 . $renderer->render([$add_button, $set_button, $reset_button])
252 )
253 ),
254 ];
255
256 $page = $f->layout()->page()->standard(
257 $content,
258 $metabar,
259 $mainbar,
260 $breadcrumbs,
261 $logo,
262 $responsive_logo,
263 "./assets/images/logo/favicon.ico",
264 $tc,
265 $footer,
266 'UI MetaBar Extended Demo',
267 'ILIAS',
268 'MetaBar Async Demo'
269 )->withUIDemo(true);
270
271 return $renderer->render($page);
272}
273
274global $DIC;
275$request_wrapper = $DIC->http()->wrapper()->query();
276$refinery = $DIC->refinery();
277
279
280if ($request_wrapper->has('extended_metabar_ui')
281 && $request_wrapper->retrieve('extended_metabar_ui', $refinery->kindlyTo()->int()) === 1
282) {
285 exit();
286}
handleAsyncRequestsIfAny(Container $dic)
Handle async requests for the notification item.

References $_SERVER, $dic, Vendor\Package\$f, $id, $renderer, and ILIAS\UI\examples\MainControls\MetaBar\buildMetabarWithNotifications().

+ Here is the call graph for this function:

◆ renderMetaBarInFullscreenMode()

if($request_wrapper->has('new_metabar_ui') && $request_wrapper->retrieve('new_metabar_ui', $refinery->kindlyTo() ->int())===1) ILIAS\UI\examples\MainControls\MetaBar\renderMetaBarInFullscreenMode ( Container  $dic)

Definition at line 87 of file base_metabar.php.

87 : string
88{
89 $f = $dic->ui()->factory();
90 $renderer = $dic->ui()->renderer();
91 $logo = $f->image()->responsive("assets/images/logo/HeaderIcon.svg", "ILIAS");
92 $responsive_logo = $f->image()->responsive("assets/images/logo/HeaderIconResponsive.svg", "ILIAS");
93 $breadcrumbs = pageMetabarDemoCrumbs($f);
94 $metabar = buildMetabar($f);
95 $mainbar = pageMetabarDemoMainbar($f);
96 $footer = pageMetabarDemoFooter($f);
97 $tc = $dic->ui()->factory()->toast()->container();
98
99 $content = pageMetabarDemoContent($f);
100
101 $page = $f->layout()->page()->standard(
102 $content,
103 $metabar,
104 $mainbar,
105 $breadcrumbs,
106 $logo,
107 $responsive_logo,
108 "./assets/images/logo/favicon.ico",
109 $tc,
110 $footer,
111 'UI Meta Bar DEMO', //page title
112 'ILIAS', //short title
113 'ILIAS Meta Bar Demo' //view title
114 )->withUIDemo(true);
115
116 return $renderer->render($page);
117}
pageMetabarDemoContent(\ILIAS\UI\Factory $f)
pageMetabarDemoCrumbs(\ILIAS\UI\Factory $f)
pageMetabarDemoMainbar(\ILIAS\UI\Factory $f)
pageMetabarDemoFooter(\ILIAS\UI\Factory $f)

References $dic, Vendor\Package\$f, $renderer, ILIAS\UI\examples\MainControls\MetaBar\buildMetabar(), ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoContent(), ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoCrumbs(), ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoFooter(), and ILIAS\UI\examples\MainControls\MetaBar\pageMetabarDemoMainbar().

+ Here is the call graph for this function:

Variable Documentation

◆ $DIC

global ILIAS::UI::examples::MainControls::MetaBar::$DIC

◆ $refinery

ILIAS::UI::examples::MainControls::MetaBar\$refinery = $DIC->refinery()

◆ $request_wrapper

ILIAS::UI::examples::MainControls::MetaBar\$request_wrapper = $DIC->http()->wrapper()->query()