ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAwarenessGUI.php
Go to the documentation of this file.
1<?php
2
24
30{
33 protected int $ref_id;
34 protected \ILIAS\Awareness\StandardGUIRequest $request;
36 protected ilObjUser $user;
37 protected ilCtrl $ctrl;
38 protected UIServices $ui;
39 protected ilLanguage $lng;
42
43 public function __construct(
45 ?InternalDomainService $domain_service = null,
46 ?InternalGUIService $gui_service = null
47 ) {
48 global $DIC;
49
50 $this->data_service = $data_service
51 ?? $DIC->awareness()->internal()->data();
52 $domain_service = $domain_service
53 ?? $DIC->awareness()->internal()->domain();
54 $gui_service = $gui_service
55 ?? $DIC->awareness()->internal()->gui();
56 $this->user = $domain_service->user();
57 $this->lng = $domain_service->lng();
58 $this->ui = $gui_service->ui();
59 $this->ctrl = $gui_service->ctrl();
60
61 $this->lng->loadLanguageModule("awrn");
62 $this->request = $gui_service->standardRequest();
63 $this->main_tpl = $gui_service->mainTemplate();
64
65 $this->ref_id = $this->request->getRefId();
66 $this->manager = $domain_service->widget(
67 $this->user->getId(),
68 $this->ref_id
69 );
70 $this->gui = $DIC->awareness()->internal()->gui();
71 $this->user_action_gui = new ilUserActionGUI(
74 $DIC['tpl'],
75 $this->ui->factory(),
76 $this->ui->renderer(),
77 $this->lng,
78 $DIC['ilDB'],
79 $this->user->getId()
80 );
81 }
82
83 public function executeCommand(): void
84 {
85 $cmd = $this->ctrl->getCmd();
86
87 if (in_array($cmd, array("getAwarenessList"))) {
88 $this->$cmd();
89 }
90 }
91
92 public function initJS(): void
93 {
94 $ilUser = $this->user;
95 // init js
96 //$this->main_tpl->addJavaScript("../components/ILIAS/Awareness/resources/Awareness.js");
97 $this->main_tpl->addJavaScript("./assets/js/Awareness.js");
98 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
99 $this->main_tpl->addOnLoadCode("il.Awareness.setBaseUrl('" . $this->ctrl->getLinkTarget(
100 $this,
101 "",
102 "",
103 true,
104 false
105 ) . "');");
106 $this->main_tpl->addOnLoadCode("il.Awareness.setLoaderSrc('" . ilUtil::getImagePath("media/loader.svg") . "');");
107 $this->main_tpl->addOnLoadCode("il.Awareness.init();");
108
109 $this->user_action_gui->init();
110 }
111
117 public function getAwarenessList(bool $return = false): ?array
118 {
119 $filter = $this->request->getFilter();
120
121 $tpl = new ilTemplate("tpl.awareness_list.html", true, true, "components/ILIAS/Awareness");
122
123 $ad = $this->manager->getListData($filter);
124
125 $users = $ad["data"];
126
127 $ucnt = 0;
128 $last_uc_title = "";
129 foreach ($users as $u) {
130 if ($u->collector != $last_uc_title) {
131 if ($u->highlighted) {
132 $tpl->touchBlock("highlighted");
133 }
134 $tpl->setCurrentBlock("uc_title");
135 $tpl->setVariable("UC_TITLE", $u->collector);
136 $tpl->parseCurrentBlock();
137 $tpl->setCurrentBlock("item");
138 $tpl->parseCurrentBlock();
139 }
140 $last_uc_title = $u->collector;
141
142 $ucnt++;
143
144 $fcnt = 0;
145 foreach ($u->actions as $act) {
146 $fcnt++;
147 if ($fcnt == 1) {
148 $tpl->touchBlock("arrow");
149 //$tpl->setCurrentBlock("arrow");
150 //$tpl->parseCurrentBlock();
151 }
152 if (is_array($act->data) && count($act->data) > 0) {
153 foreach ($act->data as $k => $v) {
154 $tpl->setCurrentBlock("f_data");
155 $tpl->setVariable("DATA_KEY", $k);
156 $tpl->setVariable("DATA_VAL", ilLegacyFormElementsUtil::prepareFormOutput($v));
157 $tpl->parseCurrentBlock();
158 }
159 }
160 $tpl->setCurrentBlock("feature");
161 $tpl->setVariable("FEATURE_HREF", $act->href);
162 $tpl->setVariable("FEATURE_TEXT", $act->text);
163 $tpl->parseCurrentBlock();
164 }
165
166 if ($u->online) {
167 $tpl->touchBlock("uonline");
168 $tpl->setCurrentBlock("uonline_text");
169 $tpl->setVariable("TXT_ONLINE", $this->lng->txt("awrn_online"));
170 $tpl->parseCurrentBlock();
171 }
172
173 $tpl->setCurrentBlock("user");
174 if ($u->public_profile) {
175 $tpl->setVariable("UNAME", $u->lastname . ", " . $u->firstname);
176 } else {
177 $tpl->setVariable("UNAME", "-");
178 }
179 $tpl->setVariable("UACCOUNT", $u->login);
180
181 $tpl->setVariable("USERIMAGE", $u->img);
182 $tpl->setVariable("CNT", $ucnt);
183 $tpl->parseCurrentBlock();
184 $tpl->setCurrentBlock("item");
185 $tpl->parseCurrentBlock();
186 }
187
188 $tpl->setCurrentBlock("filter");
189 $tpl->setVariable("GL_FILTER", $this->gui->symbol()->glyph("filter")->render());
190 $tpl->setVariable("FILTER_INPUT_LABEL", $this->lng->txt("awrn_filter"));
191 $tpl->parseCurrentBlock();
192
193
194 $result = ["html" => $tpl->get(),
195 "filter_val" => ilLegacyFormElementsUtil::prepareFormOutput($filter),
196 "cnt" => $ad["cnt"]];
197
198 if ($return) {
199 $this->initJS();
200 return $result;
201 }
202
203 echo json_encode($result, JSON_THROW_ON_ERROR);
204 exit;
205 }
206}
High level business class, interface to front ends.
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Awareness GUI class.
InternalDataService $data_service
InternalGUIService $gui
ILIAS Awareness StandardGUIRequest $request
__construct(?InternalDataService $data_service=null, ?InternalDomainService $domain_service=null, ?InternalGUIService $gui_service=null)
ilUserActionGUI $user_action_gui
getAwarenessList(bool $return=false)
Get awareness list (ajax)
ilGlobalTemplateInterface $main_tpl
WidgetManager $manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
language handling
static prepareFormOutput($a_str, bool $a_strip=false)
User class.
special template class to simplify handling of ITX/PEAR
A class that provides a collection of actions on users.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26