3 declare(strict_types=0);
36 ?
object $a_parent_obj,
38 ?array $a_preselect = null
40 $this->preselected = $a_preselect;
42 $this->
setId(
"lpobjstattbl");
46 public function init(): void
52 $this->
addColumn($this->
lng->txt(
"trac_title"),
"title",
'30%');
56 $column_definition = $all_columns[$col_name];
58 $column_definition[
'txt'],
59 $column_definition[
'sortable'] ? $column_definition[
'field'] :
'',
60 $column_definition[
'width']
63 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
66 ) as $num => $caption) {
67 $this->
addColumn($caption,
"month_" . $num);
72 $this->
setTitle($this->
lng->txt(
"trac_object_stat_access"));
77 $this->
lng->txt(
"trac_show_graph")
83 $this->
ctrl->getFormAction(
84 $this->getParentObject(),
89 "tpl.lp_object_statistics_row.html",
103 $columns[
'obj_id'] = [
105 'txt' => $this->
lng->txt(
'object_id'),
111 $columns[
'reference_ids'] = [
112 'field' =>
'reference_ids',
113 'txt' => $this->
lng->txt(
'trac_reference_ids_column'),
119 $columns[
'paths'] = [
121 'txt' => $this->
lng->txt(
'trac_paths'),
132 $alphabetic_ordering = [
135 if (!in_array($a_field, $alphabetic_ordering)) {
151 $si->readFromSession();
152 if (!$si->getValue()) {
153 $si->setValue(
"crs");
155 $this->
filter[
"type"] = $si->getValue();
159 $this->
lng->txt(
"trac_title_description"),
162 $ti->setMaxLength(64);
165 $ti->readFromSession();
166 $this->
filter[
"query"] = $ti->getValue();
171 array(
"read_count" => $this->
lng->txt(
"trac_read_count"),
172 "spent_seconds" => $this->
lng->txt(
"trac_spent_seconds"),
173 "users" => $this->
lng->txt(
"users")
177 $si->readFromSession();
178 if (!$si->getValue()) {
179 $si->setValue(
"read_count");
181 $this->
filter[
"measure"] = $si->getValue();
185 $this->
lng->txt(
"year") .
" / " . $this->
lng->txt(
"month"),
190 $si->readFromSession();
191 if (!$si->getValue()) {
192 $si->setValue(date(
"Y-m"));
194 $this->
filter[
"yearmonth"] = $si->getValue();
207 if ($this->
filter[
"type"] !=
"prtf") {
216 if ($this->
filter[
"type"] ==
"blog") {
220 $objects[$obj_id] = array($obj_id);
228 $objects[$obj_id] = array($obj_id);
233 $yearmonth = explode(
"-", $this->
filter[
"yearmonth"]);
234 if (
sizeof($yearmonth) == 1) {
238 ) as $obj_id => $months) {
239 $data[$obj_id][
"obj_id"] = $obj_id;
243 foreach ($months as $month => $values) {
244 $idx = $yearmonth[0] .
"-" . str_pad(
250 $data[$obj_id][
"month_" . $idx] = (
int) ($values[$this->
filter[
"measure"]] ?? 0);
251 $data[$obj_id][
"total"] = (
$data[$obj_id][
"total"] ?? 0) + (
int) ($values[$this->filter[
"measure"]] ?? 0);
257 (
string) $yearmonth[0],
258 (string) $yearmonth[1]
259 ) as $obj_id => $days) {
260 $data[$obj_id][
"obj_id"] = $obj_id;
264 foreach ($days as $day => $values) {
265 $data[$obj_id][
"day_" . $day] = (
int) ($values[$this->
filter[
"measure"]] ?? 0);
266 $data[$obj_id][
"total"] = (
$data[$obj_id][
"total"] ?? 0) + (
int) ($values[$this->filter[
"measure"]] ?? 0);
272 foreach (array_keys($objects) as $obj_id) {
273 if (!isset(
$data[$obj_id])) {
274 $data[$obj_id][
"obj_id"] = $obj_id;
289 sort($ref_ids, SORT_NUMERIC);
296 protected function fillRow(array $a_set): void
300 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
301 $this->tpl->setVariable(
305 $this->tpl->setVariable(
"ICON_ALT", $this->
lng->txt(
$type));
306 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
308 if ($this->preselected && in_array(
312 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
316 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
317 $this->tpl->setCurrentBlock(
"month");
321 $value = (
int) ($a_set[
"month_" . $num] ?? 0);
322 if (($this->
filter[
"measure"] ??
"") !=
"spent_seconds") {
327 $this->tpl->setVariable(
"MONTH_VALUE", $value);
328 $this->tpl->parseCurrentBlock();
332 if (($this->
filter[
"measure"] ??
"") ==
"spent_seconds") {
333 $sum = $this->
formatSeconds((
int) ($a_set[
"total"] ?? 0),
true);
337 $this->tpl->setVariable(
"TOTAL", $sum);
341 $this->tpl->setVariable(
'OBJ_ID_COL_VALUE', (
string) $a_set[
'obj_id']);
344 $this->tpl->setVariable(
'REF_IDS', (
string) implode(
', ', $a_set[
'reference_ids']));
348 foreach ($a_set[
'reference_ids'] as $reference_id) {
350 $path_gui->enableTextOnly(
false);
351 $path_gui->enableHideLeaf(
false);
352 $path_gui->setUseImages(
true);
355 $this->tpl->setVariable(
'PATHS', implode(
'<br /> ', $paths));
359 public function getGraph(array $a_graph_items): string
362 $chart->setSize(
"700",
"500");
365 $chart->setLegend($legend);
368 foreach ($this->
getData() as $object) {
369 if (in_array($object[
"obj_id"], $a_graph_items)) {
373 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
376 $this->
filter[
"yearmonth"]
379 $value = (
int) ($object[
"month_" . $num] ?? 0);
380 $max_value = max($max_value, $value);
381 if ($this->
filter[
"measure"] !=
"spent_seconds") {
384 $series->addPoint($idx, $value);
387 for ($loop = 1; $loop < 32; $loop++) {
388 $value = (
int) ($object[
"day_" . $loop] ?? 0);
389 $max_value = max($max_value, $value);
390 if ($this->
filter[
"measure"] !=
"spent_seconds") {
393 $series->addPoint($loop, $value);
397 $chart->addData($series);
403 ($this->
filter[
"measure"] !=
"spent_seconds"),
404 ($this->
filter[
"measure"] ==
"spent_seconds")
408 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
409 foreach (array_values(
411 ) as $idx => $caption) {
412 $labels[$idx] = $caption;
415 for ($loop = 1; $loop < 32; $loop++) {
416 $labels[$loop] = $loop .
".";
419 $chart->setTicks($labels, $value_ticks,
true);
421 return $chart->getHTML();
439 $a_excel->
setCell($a_row, ++$col, (
string) $a_set[
'obj_id']);
442 $a_excel->
setCell($a_row, ++$col, implode(
', ', $a_set[
'reference_ids']));
446 foreach ($a_set[
'reference_ids'] as $reference_id) {
448 $path_gui->enableTextOnly(
true);
449 $path_gui->enableHideLeaf(
false);
450 $path_gui->setUseImages(
false);
457 $a_excel->
setCell($a_row, ++$col, substr(implode(
', ', $paths), 0, -1));
460 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
464 $value = (
int) ($a_set[
"month_" . $num] ?? 0);
465 if ($this->
filter[
"measure"] !=
"spent_seconds") {
469 $a_excel->
setCell($a_row, ++$col, $value);
473 if ($this->
filter[
"measure"] ==
"spent_seconds") {
476 $sum = (
int) ($a_set[
"total"] ?? 0);
480 $a_excel->
setCell($a_row, ++$col, $sum);
496 $a_csv->
addColumn(implode(
', ', $a_set[
'reference_ids']));
500 foreach ($a_set[
'reference_ids'] as $reference_id) {
502 $path_gui->enableTextOnly(
true);
503 $path_gui->enableHideLeaf(
false);
504 $path_gui->setUseImages(
false);
511 $a_csv->
addColumn(substr(implode(
', ', $paths), 0, -1));
514 if (strpos($this->
filter[
"yearmonth"],
"-") ===
false) {
518 $value = (
int) ($a_set[
"month_" . $num] ?? 0);
519 if ($this->
filter[
"measure"] !=
"spent_seconds") {
527 if ($this->
filter[
"measure"] ==
"spent_seconds") {
530 $sum = (
int) ($a_set[
"total"] ?? 0);
buildValueScale(int $a_max_value, bool $a_anonymize=false, bool $a_format_seconds=false)
fillRow(array $a_set)
Fill table row.
Creates a path for a start and endnode.
getPossibleTypes(bool $a_split_learning_resources=false, bool $a_include_digilib=false, bool $a_allow_undefined_lp=false)
getCurrentFilter(bool $as_query=false)
setExportFormats(array $formats)
Set available export formats.
isForwardingToFormDispatcher()
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setResetCommand(string $a_val, string $a_caption="")
getMonthsYear($a_year=null, $a_short=false)
searchObjects(array $filter, string $permission, ?array $preset_obj_ids=null, bool $a_check_lp_activation=true)
Search objects that match current filters.
static _getAllReferences(int $id)
get all reference ids for object ID
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
setDisableFilterHiding(bool $a_val=true)
findReferencesForObjId(int $a_obj_id)
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillMetaCSV(ilCSVWriter $a_csv)
fillMetaExcel(ilExcel $a_excel, int &$a_row)
anonymizeValue($a_value, bool $a_force_number=false)
isColumnSelected(string $col)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
static _lookupTitle(int $obj_id)
TableGUI class for learning progress.
static getWorkspaceBlogs(?string $a_title=null)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
setDefaultOrderDirection(string $a_defaultorderdirection)
formatSeconds(int $seconds, bool $a_shorten_zero=false)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
initRepositoryFilter(array $filter)
setEnableNumInfo(bool $a_val)
getMonthsFilter($a_short=false)
__construct(Container $dic, ilPlugin $plugin)
static getPortfolios(?string $a_title=null)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
static _lookupType(int $id, bool $reference=false)
static getObjectAccessStatistics(array $a_ref_ids, string $a_year, ?string $a_month=null)
addMultiCommand(string $a_cmd, string $a_text)
getGraph(array $a_graph_items)
numericOrdering(string $a_field)
setEnableHeader(bool $a_enableheader)
__construct(?object $a_parent_obj, string $a_parent_cmd, ?array $a_preselect=null)
Constructor.
static getInstanceByType(int $a_type, string $a_id)