ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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(),
59  $ref_id
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($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 }
Class Factory.
$c
Definition: cli.php:38
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Who-Is-Online meta bar provider.
$ref_id
Definition: ltiauth.php:67
$ilUser
Definition: imgupload.php:34
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23