4 include_once(
"./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
20 function __construct($a_parent_obj, $a_parent_cmd, array $a_preselect = null, $a_load_items =
true)
24 $this->preselected = $a_preselect;
26 $this->
setId(
"lpobjstattbl");
35 $this->
addColumn($lng->txt(
"trac_title"),
"title");
36 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
38 for($loop = 1; $loop<13; $loop++)
40 $this->
addColumn($lng->txt(
"month_".str_pad($loop, 2,
"0", STR_PAD_LEFT).
"_short"),
"month_".$loop,
"",
false,
"ilRight");
43 $this->
addColumn($lng->txt(
"total"),
"total",
"",
false,
"ilRight");
45 $this->
setTitle($this->lng->txt(
"trac_object_stat_access"));
48 $this->
addMultiCommand(
"showAccessGraph", $lng->txt(
"trac_show_graph"));
52 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
53 $this->
setRowTemplate(
"tpl.lp_object_statistics_row.html",
"Services/Tracking");
62 include_once(
"./Services/Tracking/classes/class.ilLPObjSettings.php");
63 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
67 $link =
" <a href=\"".$ilCtrl->getLinkTarget($a_parent_obj,
"admin").
"\">»".
68 $lng->txt(
"trac_log_info_link").
"</a>";
69 ilUtil::sendInfo(sprintf($lng->txt(
"trac_log_info"), $info_date, $info[
"counter"]).$link);
82 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
84 for($loop = 1; $loop<13; $loop++)
86 $fields[] =
"month_".$loop;
90 if(in_array($a_field, $fields))
107 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
111 $si->readFromSession();
114 $si->setValue(
"crs");
116 $this->filter[
"type"] = $si->getValue();
119 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
120 $ti =
new ilTextInputGUI($lng->txt(
"trac_title_description"),
"query");
124 $ti->readFromSession();
125 $this->filter[
"query"] = $ti->getValue();
129 $si->
setOptions(array(
"read_count"=>$lng->txt(
"trac_read_count"),
130 "spent_seconds"=>$lng->txt(
"trac_spent_seconds")));
132 $si->readFromSession();
135 $si->setValue(
"read_count");
137 $this->filter[
"measure"] = $si->getValue();
140 $si =
new ilSelectInputGUI($lng->txt(
"year").
" / ".$lng->txt(
"month"),
"yearmonth");
142 for($loop = 0; $loop < 10; $loop++)
144 $year = date(
"Y")-$loop;
145 $options[$year] = $year;
146 for($loop2 = 12; $loop2 > 0; $loop2--)
148 $month = str_pad($loop2, 2,
"0", STR_PAD_LEFT);
149 if($year.$month <= date(
"Ym"))
151 $options[$year.
"-".$month] = $year.
" / ".
152 $lng->txt(
"month_".$month.
"_long");
158 $si->readFromSession();
161 $si->setValue(date(
"Y-m"));
163 $this->filter[
"yearmonth"] = $si->getValue();
173 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
175 $yearmonth = explode(
"-", $this->filter[
"yearmonth"]);
176 if(
sizeof($yearmonth) == 1)
180 $data[$obj_id][
"obj_id"] = $obj_id;
183 foreach($months as $month => $values)
185 $data[$obj_id][
"month_".$month] = (int)$values[$this->filter[
"measure"]];
186 $data[$obj_id][
"total"] += (int)$values[$this->filter[
"measure"]];
194 $data[$obj_id][
"obj_id"] = $obj_id;
197 foreach($days as $day => $values)
199 $data[$obj_id][
"day_".$day] = (int)$values[$this->filter[
"measure"]];
200 $data[$obj_id][
"total"] += (int)$values[$this->filter[
"measure"]];
206 foreach($objects as $obj_id => $ref_ids)
208 if(!isset(
$data[$obj_id]))
210 $data[$obj_id][
"obj_id"] = $obj_id;
228 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
230 $this->tpl->setVariable(
"ICON_ALT", $this->lng->txt($type));
231 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
233 if($this->preselected && in_array($a_set[
"obj_id"], $this->preselected))
235 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
239 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
241 $this->tpl->setCurrentBlock(
"month");
242 for($loop = 1; $loop<13; $loop++)
244 $value = (int)$a_set[
"month_".$loop];
245 if($this->filter[
"measure"] ==
"read_count")
249 else if($this->filter[
"measure"] ==
"spent_seconds")
253 $this->tpl->setVariable(
"MONTH_VALUE", $value);
254 $this->tpl->parseCurrentBlock();
258 if($this->filter[
"measure"] ==
"spent_seconds")
266 $this->tpl->setVariable(
"TOTAL", $sum);
273 include_once
"Services/Chart/classes/class.ilChart.php";
274 $chart =
new ilChart(
"objstacc", 700, 500);
280 foreach($this->
getData() as $object)
282 if(in_array($object[
"obj_id"], $a_graph_items))
287 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
289 for($loop = 1; $loop<13; $loop++)
291 $value = (int)$object[
"month_".$loop];
292 $max_value = max($max_value, $value);
293 if($this->filter[
"measure"] ==
"read_count")
297 $series->addPoint($loop, $value);
302 for($loop = 1; $loop<32; $loop++)
304 $value = (int)$object[
"day_".$loop];
305 $max_value = max($max_value, $value);
306 if($this->filter[
"measure"] ==
"read_count")
310 $series->addPoint($loop, $value);
314 $chart->addData($series);
318 $value_ticks = $this->
buildValueScale($max_value, ($this->filter[
"measure"] ==
"read_count"),
319 ($this->filter[
"measure"] ==
"spent_seconds"));
322 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
324 for($loop = 1; $loop<13; $loop++)
326 $labels[$loop] = $lng->txt(
"month_".str_pad($loop, 2,
"0", STR_PAD_LEFT).
"_short");
331 for($loop = 1; $loop<32; $loop++)
333 $labels[$loop] = $loop.
".";
336 $chart->setTicks($labels, $value_ticks,
true);
338 return $chart->getHTML();
351 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
353 for($loop = 1; $loop<13; $loop++)
355 $value = (int)$a_set[
"month_".$loop];
356 if($this->filter[
"measure"] ==
"read_count")
360 else if($this->filter[
"measure"] ==
"spent_seconds")
367 $a_worksheet->write($a_row, $col, $value);
371 if($this->filter[
"measure"] ==
"spent_seconds")
375 $sum = (int)$a_set[
"total"];
382 $a_worksheet->write($a_row, $col, $sum);
394 if(strpos($this->filter[
"yearmonth"],
"-") ===
false)
396 for($loop = 1; $loop<13; $loop++)
398 $value = (int)$a_set[
"month_".$loop];
399 if($this->filter[
"measure"] ==
"read_count")
403 else if($this->filter[
"measure"] ==
"spent_seconds")
409 $a_csv->addColumn($value);
413 if($this->filter[
"measure"] ==
"spent_seconds")
417 $sum = (int)$a_set[
"total"];
423 $a_csv->addColumn($sum);