ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAwarenessMetaBarProvider.php
Go to the documentation of this file.
1<?php
2
25
31{
32 private function getId(): IdentificationInterface
33 {
34 return $this->if->identifier('awareness');
35 }
36
37 public function getAllIdentifications(): array
38 {
39 return [$this->getId()];
40 }
41
42 public function getMetaBarItems(): array
43 {
44 $ilUser = $this->dic->user();
45 $ref_id = $this->dic->awareness()
46 ->internal()
47 ->gui()
48 ->standardRequest()
49 ->getRefId();
50 $gui = $this->dic->awareness()
51 ->internal()
52 ->gui()
53 ->widget();
54 $manager = $this->dic->awareness()
55 ->internal()
56 ->domain()
57 ->widget(
58 $ilUser->getId(),
60 );
61
62 $is_widget_visible = $manager->isWidgetVisible();
63
64 if (!$is_widget_visible) {
65 return [];
66 }
67
68 $counter = $manager->processMetaBar();
69
70 $result = $gui->getAwarenessList(true);
71 $online = explode(":", $result["cnt"]);
72 $online = (int) $online[0];
73 $content = $this->dic->ui()->factory()->legacy()->content($result["html"]);
74 if ($online === 0) {
75 $is_widget_visible = false;
76 }
77
78 $mb = $this->globalScreen()->metaBar();
79
80 $f = $this->dic->ui()->factory();
81
82 $item = $mb
83 ->topLegacyItem($this->getId())
84 ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c): ILIAS\UI\Component\Component {
85 if ($c instanceof BulkyButton || $c instanceof BulkyLink) {
86 return $c->withAdditionalOnLoadCode(static function (string $id): string {
87 return "$('#$id').on('click', function() {
88 console.log('trigger awareness slate');
89 })";
90 });
91 }
92 return $c;
93 })
94 ->withLegacyContent($content)
95 ->withSymbol(
96 $this->dic->ui()->factory()
97 ->symbol()
98 ->glyph()
99 ->user()
100 ->withCounter($f->counter()->status($counter->getCount()))
101 ->withCounter($f->counter()->novelty($counter->getHighlightCount()))
102 )
103 ->withTitle($this->dic->language()->txt("awra"))
104 ->withPosition(2)
105 ->withAvailableCallable(
106 function () use ($is_widget_visible) {
107 return $is_widget_visible;
108 }
109 );
110
111 return [$item];
112 }
113}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Who-Is-Online meta bar provider.
$c
Definition: deliver.php:25
$ref_id
Definition: ltiauth.php:66
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$counter