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