ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilAwarenessGUI Class Reference

Awareness GUI class. More...

+ Collaboration diagram for ilAwarenessGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 initJS ()
 
 getMainMenuHTML ()
 Get main menu html. More...
 
 getAwarenessList ($return=false)
 Get awareness list (ajax) More...
 

Static Public Member Functions

static getInstance ()
 Get instance. More...
 

Protected Attributes

 $user
 
 $ctrl
 
 $ui
 
 $lng
 

Detailed Description

Awareness GUI class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilAwarenessGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAwarenessGUI::__construct ( )

Constructor.

Definition at line 37 of file class.ilAwarenessGUI.php.

38 {
39 global $DIC;
40
41 $this->user = $DIC->user();
42 global $DIC;
43 $this->ui = $DIC->ui();
44
45 $this->ref_id = (int) $_GET["ref_id"];
46 $this->ctrl = $DIC->ctrl();
47 $this->lng = $DIC->language();
48 $this->lng->loadLanguageModule("awrn");
49 }
user()
Definition: user.php:4
$_GET["client_id"]
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46

References $_GET, $DIC, ui(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilAwarenessGUI::executeCommand ( )

Execute command.

Definition at line 54 of file class.ilAwarenessGUI.php.

55 {
56 $cmd = $this->ctrl->getCmd();
57
58 if (in_array($cmd, array("getAwarenessList"))) {
59 $this->$cmd();
60 }
61 }

◆ getAwarenessList()

ilAwarenessGUI::getAwarenessList (   $return = false)

Get awareness list (ajax)

Definition at line 179 of file class.ilAwarenessGUI.php.

180 {
182
183 $filter = $_GET["filter"];
184
185 $tpl = new ilTemplate("tpl.awareness_list.html", true, true, "Services/Awareness");
186
187 include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
188 $act = ilAwarenessAct::getInstance($ilUser->getId());
189 $act->setRefId($this->ref_id);
190
191 $ad = $act->getAwarenessData($filter);
192
193 // update counter
194 $now = time();
195 $cnt = explode(":", $ad["cnt"]);
196 $hcnt = $cnt[1];
197 $cnt = $cnt[0];
198 ilSession::set("awrn_last_update", $now);
199 ilSession::set("awrn_nr_users", $cnt);
200 ilSession::set("awrn_nr_husers", $hcnt);
201
202
203 $users = $ad["data"];
204
205 $ucnt = 0;
206 $last_uc_title = "";
207 foreach ($users as $u) {
208 if ($u->collector != $last_uc_title) {
209 if ($u->highlighted) {
210 $tpl->touchBlock("highlighted");
211 }
212 $tpl->setCurrentBlock("uc_title");
213 $tpl->setVariable("UC_TITLE", $u->collector);
214 $tpl->parseCurrentBlock();
215 $tpl->setCurrentBlock("item");
216 $tpl->parseCurrentBlock();
217 }
218 $last_uc_title = $u->collector;
219
220 $ucnt++;
221
222 $fcnt = 0;
223 foreach ($u->actions as $act) {
224 $fcnt++;
225 if ($fcnt == 1) {
226 $tpl->touchBlock("arrow");
227 //$tpl->setCurrentBlock("arrow");
228 //$tpl->parseCurrentBlock();
229 }
230 if (is_array($act->data) && count($act->data) > 0) {
231 foreach ($act->data as $k => $v) {
232 $tpl->setCurrentBlock("f_data");
233 $tpl->setVariable("DATA_KEY", $k);
234 $tpl->setVariable("DATA_VAL", ilUtil::prepareFormOutput($v));
235 $tpl->parseCurrentBlock();
236 }
237 }
238 $tpl->setCurrentBlock("feature");
239 $tpl->setVariable("FEATURE_HREF", $act->href);
240 $tpl->setVariable("FEATURE_TEXT", $act->text);
241 $tpl->parseCurrentBlock();
242 }
243
244 if ($u->online) {
245 $tpl->touchBlock("uonline");
246 $tpl->setCurrentBlock("uonline_text");
247 $tpl->setVariable("TXT_ONLINE", $this->lng->txt("awrn_online"));
248 $tpl->parseCurrentBlock();
249 }
250
251 $tpl->setCurrentBlock("user");
252 if ($u->public_profile) {
253 $tpl->setVariable("UNAME", $u->lastname . ", " . $u->firstname);
254 } else {
255 $tpl->setVariable("UNAME", "-");
256 }
257 $tpl->setVariable("UACCOUNT", $u->login);
258
259 $tpl->setVariable("USERIMAGE", $u->img);
260 $tpl->setVariable("CNT", $ucnt);
261 $tpl->parseCurrentBlock();
262 $tpl->setCurrentBlock("item");
263 $tpl->parseCurrentBlock();
264 }
265
266 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
267 $tpl->setCurrentBlock("filter");
268 $tpl->setVariable("GL_FILTER", ilGlyphGUI::get(ilGlyphGUI::FILTER));
269 $tpl->setVariable("FILTER_INPUT_LABEL", $this->lng->txt("awrn_filter"));
270 $tpl->parseCurrentBlock();
271
272
273 $result = ["html" => $tpl->get(),
274 "filter_val" => ilUtil::prepareFormOutput($filter),
275 "cnt" => $ad["cnt"]];
276
277 if ($return) {
278 $this->initJS();
279 return $result;
280 }
281
282 echo json_encode($result);
283 exit;
284 }
$result
static getInstance($a_user_id)
Get instance (for a user)
static get($a_glyph, $a_text="")
Get glyph html.
static set($a_var, $a_val)
Set a value.
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
exit
Definition: login.php:29
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$ilUser
Definition: imgupload.php:18

References $_GET, $ilUser, $result, $tpl, $user, exit, ilGlyphGUI\FILTER, ilGlyphGUI\get(), ilAwarenessAct\getInstance(), initJS(), ilUtil\prepareFormOutput(), and ilSession\set().

+ Here is the call graph for this function:

◆ getInstance()

static ilAwarenessGUI::getInstance ( )
static

Get instance.

Returns
ilAwarenessGUI awareness gui object

Definition at line 69 of file class.ilAwarenessGUI.php.

70 {
71 return new ilAwarenessGUI();
72 }
Awareness GUI class.

Referenced by ilMainMenuGUI\renderAwareness().

+ Here is the caller graph for this function:

◆ getMainMenuHTML()

ilAwarenessGUI::getMainMenuHTML ( )

Get main menu html.

Definition at line 100 of file class.ilAwarenessGUI.php.

101 {
103
104 $awrn_set = new ilSetting("awrn");
105 if (!$awrn_set->get("awrn_enabled", false) || ANONYMOUS_USER_ID == $ilUser->getId()) {
106 return "";
107 }
108
109 $cache_period = (int) $awrn_set->get("caching_period");
110 $last_update = ilSession::get("awrn_last_update");
111 $now = time();
112
113 $this->initJS();
114
115 $tpl = new ilTemplate("tpl.awareness.html", true, true, "Services/Awareness");
116
117 include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
118 $act = ilAwarenessAct::getInstance($ilUser->getId());
119 $act->setRefId($this->ref_id);
120 var_dump("1");
121 exit;
122 if ($last_update == "" || ($now - $last_update) >= $cache_period) {
123 $cnt = explode(":", $act->getAwarenessUserCounter());
124 $hcnt = $cnt[1];
125 $cnt = $cnt[0];
126 $act->notifyOnNewOnlineContacts();
127 ilSession::set("awrn_last_update", $now);
128 ilSession::set("awrn_nr_users", $cnt);
129 ilSession::set("awrn_nr_husers", $hcnt);
130 } else {
131 $cnt = (int) ilSession::get("awrn_nr_users");
132 $hcnt = (int) ilSession::get("awrn_nr_husers");
133 }
134
135 if ($hcnt > 0 || $cnt > 0) {
136 /*
137 $tpl->setCurrentBlock("status_text");
138 $tpl->setVariable("STATUS_TXT", $cnt);
139 if ($cnt == 0)
140 {
141 $tpl->setVariable("HIDDEN", "ilAwrnBadgeHidden");
142 }
143 $tpl->parseCurrentBlock();
144 $tpl->setCurrentBlock("h_status_text");
145 $tpl->setVariable("H_STATUS_TXT", $hcnt);
146 if ($hcnt == 0)
147 {
148 $tpl->setVariable("H_HIDDEN", "ilAwrnBadgeHidden");
149 }
150 $tpl->parseCurrentBlock();
151 $tpl->setVariable("HSP", " ");*/
152
153 $f = $this->ui->factory();
154 $renderer = $this->ui->renderer();
155
156 $glyph = $f->symbol()->glyph()->user("#");
157 if ($cnt > 0) {
158 $glyph = $glyph->withCounter($f->counter()->status((int) $cnt));
159 }
160 if ($hcnt > 0) {
161 $glyph = $glyph->withCounter($f->counter()->novelty((int) $hcnt));
162 }
163 $glyph_html = $renderer->render($glyph);
164 $tpl->setVariable("GLYPH", $glyph_html);
165
166
167
168 $tpl->setVariable("LOADER", ilUtil::getImagePath("loader.svg"));
169
170 return $tpl->get();
171 }
172
173 return "";
174 }
static get($a_var)
Get a value.
ILIAS Setting Class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)

References Vendor\Package\$f, $ilUser, $tpl, $user, exit, ilSession\get(), ilUtil\getImagePath(), ilAwarenessAct\getInstance(), initJS(), ilSession\set(), and ui().

+ Here is the call graph for this function:

◆ initJS()

ilAwarenessGUI::initJS ( )

Definition at line 74 of file class.ilAwarenessGUI.php.

75 {
77 // init js
78 $GLOBALS["tpl"]->addJavascript("./Services/Awareness/js/Awareness.js");
79 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
80 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setBaseUrl('" . $this->ctrl->getLinkTarget(
81 $this,
82 "",
83 "",
84 true,
85 false
86 ) . "');");
87 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setLoaderSrc('" . ilUtil::getImagePath("loader.svg") . "');");
88 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.init();");
89
90 // include user action js
91 include_once("./Services/User/Actions/classes/class.ilUserActionGUI.php");
92 include_once("./Services/Awareness/classes/class.ilAwarenessUserActionContext.php");
94 $ua_gui->init();
95 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Awareness context for user actions.
static getInstance(ilUserActionContext $a_user_action_context, ilGlobalTemplateInterface $a_global_tpl, $a_current_user_id)
Get instance.

References $GLOBALS, $ilUser, $user, ilUtil\getImagePath(), and ilUserActionGUI\getInstance().

Referenced by getAwarenessList(), and getMainMenuHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilAwarenessGUI::$ctrl
protected

Definition at line 22 of file class.ilAwarenessGUI.php.

◆ $lng

ilAwarenessGUI::$lng
protected

Definition at line 32 of file class.ilAwarenessGUI.php.

◆ $ui

ilAwarenessGUI::$ui
protected

Definition at line 27 of file class.ilAwarenessGUI.php.

◆ $user

ilAwarenessGUI::$user
protected

Definition at line 17 of file class.ilAwarenessGUI.php.

Referenced by getAwarenessList(), getMainMenuHTML(), and initJS().


The documentation for this class was generated from the following file: