ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
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 $debug = false;
95 if ($debug) {
96 $this->main_tpl->addJavaScript("../components/ILIAS/Awareness/resources/Awareness.js");
97 } else {
98 $this->main_tpl->addJavaScript("./assets/js/Awareness.js");
99 }
100 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
101 $this->main_tpl->addOnLoadCode("il.Awareness.setBaseUrl('" . $this->ctrl->getLinkTarget(
102 $this,
103 "",
104 "",
105 true,
106 false
107 ) . "');");
108 $this->main_tpl->addOnLoadCode("il.Awareness.setLoaderSrc('" . ilUtil::getImagePath("media/loader.svg") . "');");
109
110 $this->user_action_gui->init();
111 }
112
118 public function getAwarenessList(bool $return = false): ?array
119 {
120 $filter = $this->request->getFilter();
121
122 $tpl = new ilTemplate("tpl.awareness_list.html", true, true, "components/ILIAS/Awareness");
123
124 $ad = $this->manager->getListData($filter);
125
126 $users = $ad["data"];
127
128 $ucnt = 0;
129 $last_uc_title = "";
130 foreach ($users as $u) {
131 if ($u->collector != $last_uc_title) {
132 if ($u->highlighted) {
133 $tpl->touchBlock("highlighted");
134 }
135 $tpl->setCurrentBlock("uc_title");
136 $tpl->setVariable("UC_TITLE", $u->collector);
138 $tpl->setCurrentBlock("item");
140 }
141 $last_uc_title = $u->collector;
142
143 $ucnt++;
144
145 $fcnt = 0;
146 foreach ($u->actions as $act) {
147 $fcnt++;
148 if ($fcnt == 1) {
149 $tpl->touchBlock("arrow");
150 //$tpl->setCurrentBlock("arrow");
151 //$tpl->parseCurrentBlock();
152 }
153 if (is_array($act->data) && count($act->data) > 0) {
154 foreach ($act->data as $k => $v) {
155 $tpl->setCurrentBlock("f_data");
156 $tpl->setVariable("DATA_KEY", $k);
159 }
160 }
161 $tpl->setCurrentBlock("feature");
162 $tpl->setVariable("FEATURE_HREF", $act->href);
163 $tpl->setVariable("FEATURE_TEXT", $act->text);
165 }
166
167 if ($u->online) {
168 $tpl->touchBlock("uonline");
169 $tpl->setCurrentBlock("uonline_text");
170 $tpl->setVariable("TXT_ONLINE", $this->lng->txt("awrn_online"));
172 }
173
174 $tpl->setCurrentBlock("user");
175 if ($u->public_profile) {
176 $tpl->setVariable("UNAME", $u->lastname . ", " . $u->firstname);
177 } else {
178 $tpl->setVariable("UNAME", "-");
179 }
180 $tpl->setVariable("UACCOUNT", $u->login);
181
182 $tpl->setVariable("USERIMAGE", $u->img);
183 $tpl->setVariable("CNT", $ucnt);
185 $tpl->setCurrentBlock("item");
187 }
188
189 $tpl->setCurrentBlock("filter");
190 $tpl->setVariable("GL_FILTER", $this->gui->symbol()->glyph("filter")->render());
191 $tpl->setVariable("FILTER_INPUT_LABEL", $this->lng->txt("awrn_filter"));
193
194
195 $result = ["html" => $tpl->get(),
196 "filter_val" => ilLegacyFormElementsUtil::prepareFormOutput($filter),
197 "cnt" => $ad["cnt"]];
198
199 if ($return) {
200 $this->initJS();
201 return $result;
202 }
203
204 echo json_encode($result, JSON_THROW_ON_ERROR);
205 exit;
206 }
207}
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)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
touchBlock(string $block)
overwrites ITX::touchBlock.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readonly ilGlobalTemplateInterface $tpl
global $DIC
Definition: shib_login.php:26
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...