ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAwarenessGUI Class Reference

Awareness GUI class. More...

+ Collaboration diagram for ilAwarenessGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getMainMenuHTML ()
 Get main menu html. More...
 
 getAwarenessList ()
 Get awareness list (ajax) More...
 

Static Public Member Functions

static getInstance ()
 Get instance. More...
 

Protected Attributes

 $ctrl
 
 $ui
 

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 27 of file class.ilAwarenessGUI.php.

References $_GET, and $DIC.

28  {
29  global $DIC;
30  $this->ui = $DIC->ui();
31 
32  $this->ref_id = (int) $_GET["ref_id"];
33  $this->ctrl = $DIC->ctrl();
34  }
$_GET["client_id"]
global $DIC

Member Function Documentation

◆ executeCommand()

ilAwarenessGUI::executeCommand ( )

Execute command.

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

References $cmd, and array.

40  {
41  $cmd = $this->ctrl->getCmd();
42 
43  if (in_array($cmd, array("getAwarenessList")))
44  {
45  $this->$cmd();
46  }
47  }
$cmd
Definition: sahs_server.php:35
Create styles array
The data for the language used.

◆ getAwarenessList()

ilAwarenessGUI::getAwarenessList ( )

Get awareness list (ajax)

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

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

155  {
156  global $ilUser;
157 
158  $filter = $_GET["filter"];
159 
160  $tpl = new ilTemplate("tpl.awareness_list.html", true, true, "Services/Awareness");
161 
162  include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
163  $act = ilAwarenessAct::getInstance($ilUser->getId());
164  $act->setRefId($this->ref_id);
165 
166  $ad = $act->getAwarenessData($filter);
167 
168  // update counter
169  $now = time();
170  $cnt = explode(":",$ad["cnt"]);
171  $hcnt = $cnt[1];
172  $cnt = $cnt[0];
173  ilSession::set("awrn_last_update", $now);
174  ilSession::set("awrn_nr_users", $cnt);
175  ilSession::set("awrn_nr_husers", $hcnt);
176 
177 
178  $users = $ad["data"];
179 
180  $ucnt = 0;
181  $last_uc_title = "";
182  foreach ($users as $u)
183  {
184  if ($u->collector != $last_uc_title)
185  {
186  if ($u->highlighted)
187  {
188  $tpl->touchBlock("highlighted");
189  }
190  $tpl->setCurrentBlock("uc_title");
191  $tpl->setVariable("UC_TITLE", $u->collector);
192  $tpl->parseCurrentBlock();
193  $tpl->setCurrentBlock("item");
194  $tpl->parseCurrentBlock();
195  }
196  $last_uc_title = $u->collector;
197 
198  $ucnt++;
199 
200  $fcnt = 0;
201  foreach ($u->actions as $act)
202  {
203  $fcnt++;
204  if ($fcnt == 1)
205  {
206  $tpl->touchBlock("arrow");
207  //$tpl->setCurrentBlock("arrow");
208  //$tpl->parseCurrentBlock();
209  }
210  if (is_array($act->data) && count($act->data) > 0)
211  {
212  foreach ($act->data as $k => $v)
213  {
214  $tpl->setCurrentBlock("f_data");
215  $tpl->setVariable("DATA_KEY", $k);
216  $tpl->setVariable("DATA_VAL", ilUtil::prepareFormOutput($v));
217  $tpl->parseCurrentBlock();
218  }
219  }
220  $tpl->setCurrentBlock("feature");
221  $tpl->setVariable("FEATURE_HREF", $act->href);
222  $tpl->setVariable("FEATURE_TEXT", $act->text);
223  $tpl->parseCurrentBlock();
224  }
225 
226  if ($u->online)
227  {
228  $tpl->touchBlock("uonline");
229  }
230 
231  $tpl->setCurrentBlock("user");
232  if ($u->public_profile)
233  {
234  $tpl->setVariable("UNAME", $u->lastname.", ".$u->firstname);
235  }
236  else
237  {
238  $tpl->setVariable("UNAME", " ");
239  }
240  $tpl->setVariable("UACCOUNT", $u->login);
241 
242  $tpl->setVariable("USERIMAGE", $u->img);
243  $tpl->setVariable("CNT", $ucnt);
244  $tpl->parseCurrentBlock();
245  $tpl->setCurrentBlock("item");
246  $tpl->parseCurrentBlock();
247  }
248 
249  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
250  $tpl->setCurrentBlock("filter");
251  $tpl->setVariable("GL_FILTER", ilGlyphGUI::get(ilGlyphGUI::FILTER));
252  $tpl->setVariable("VAL_FILTER", ilUtil::prepareFormOutput($filter));
253  $tpl->parseCurrentBlock();
254 
255  echo json_encode(array("html" => $tpl->get(),
256  "cnt" => $ad["cnt"]));
257  exit;
258  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getInstance($a_user_id)
Get instance (for a user)
$_GET["client_id"]
static get($a_glyph, $a_text="")
Get glyph html.
static set($a_var, $a_val)
Set a value.
global $tpl
Definition: ilias.php:8
special template class to simplify handling of ITX/PEAR
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ getInstance()

static ilAwarenessGUI::getInstance ( )
static

Get instance.

Returns
ilAwarenessGUI awareness gui object

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

Referenced by ilMainMenuGUI\renderAwareness().

56  {
57  return new ilAwarenessGUI();
58  }
Awareness GUI class.
+ Here is the caller graph for this function:

◆ getMainMenuHTML()

ilAwarenessGUI::getMainMenuHTML ( )

Get main menu html.

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

References $GLOBALS, $ilUser, $tpl, ilSession\get(), ilUtil\getImagePath(), ilAwarenessAct\getInstance(), ilSession\set(), and time.

64  {
65  global $ilUser;
66 
67  $awrn_set = new ilSetting("awrn");
68  if (!$awrn_set->get("awrn_enabled", false) || ANONYMOUS_USER_ID == $ilUser->getId())
69  {
70  return "";
71  }
72 
73  $cache_period = (int) $awrn_set->get("caching_period");
74  $last_update = ilSession::get("awrn_last_update");
75  $now = time();
76 
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($this,
81  "", "", true, false)."');");
82  $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setLoaderSrc('".ilUtil::getImagePath("loader.svg")."');");
83  $GLOBALS["tpl"]->addOnloadCode("il.Awareness.init();");
84 
85  $tpl = new ilTemplate("tpl.awareness.html", true, true, "Services/Awareness");
86 
87  include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
88  $act = ilAwarenessAct::getInstance($ilUser->getId());
89  $act->setRefId($this->ref_id);
90 
91  if ($last_update == "" || ($now - $last_update) >= $cache_period)
92  {
93  $cnt = explode(":", $act->getAwarenessUserCounter());
94  $hcnt = $cnt[1];
95  $cnt = $cnt[0];
96  $act->notifyOnNewOnlineContacts();
97  ilSession::set("awrn_last_update", $now);
98  ilSession::set("awrn_nr_users", $cnt);
99  ilSession::set("awrn_nr_husers", $hcnt);
100  }
101  else
102  {
103  $cnt = (int) ilSession::get("awrn_nr_users");
104  $hcnt = (int) ilSession::get("awrn_nr_husers");
105  }
106 
107  if ($hcnt > 0 || $cnt > 0)
108  {
109  /*
110  $tpl->setCurrentBlock("status_text");
111  $tpl->setVariable("STATUS_TXT", $cnt);
112  if ($cnt == 0)
113  {
114  $tpl->setVariable("HIDDEN", "ilAwrnBadgeHidden");
115  }
116  $tpl->parseCurrentBlock();
117  $tpl->setCurrentBlock("h_status_text");
118  $tpl->setVariable("H_STATUS_TXT", $hcnt);
119  if ($hcnt == 0)
120  {
121  $tpl->setVariable("H_HIDDEN", "ilAwrnBadgeHidden");
122  }
123  $tpl->parseCurrentBlock();
124  $tpl->setVariable("HSP", " ");*/
125 
126  $f = $this->ui->factory();
127  $renderer = $this->ui->renderer();
128 
129  $glyph = $f->glyph()->user("#");
130  if ($cnt > 0)
131  {
132  $glyph = $glyph->withCounter($f->counter()->status((int) $cnt));
133  }
134  if ($hcnt > 0)
135  {
136  $glyph =$glyph->withCounter($f->counter()->novelty((int) $hcnt));
137  }
138  $glyph_html = $renderer->render($glyph);
139  $tpl->setVariable("GLYPH", $glyph_html);
140 
141 
142 
143  $tpl->setVariable("LOADER", ilUtil::getImagePath("loader.svg"));
144 
145  return $tpl->get();
146  }
147 
148  return "";
149  }
ILIAS Setting Class.
static getInstance($a_user_id)
Get instance (for a user)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
global $tpl
Definition: ilias.php:8
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
$ilUser
Definition: imgupload.php:18
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilAwarenessGUI::$ctrl
protected

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

◆ $ui

ilAwarenessGUI::$ui
protected

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


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