ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningHistoryTimelineItem.php
Go to the documentation of this file.
1<?php
2
23{
25 protected \ILIAS\DI\UIServices $ui;
26 protected int $user_id;
28 protected ilTree $tree;
29
30 public function __construct(
32 \ILIAS\DI\UIServices $ui,
33 int $user_id,
36 ) {
37 $this->access = $access;
38 $this->lh_entry = $lh_entry;
39 $this->ui = $ui;
40 $this->user_id = $user_id;
41 $this->tree = $tree;
42 }
43
44 public function getDatetime(): ilDateTime
45 {
46 return new ilDateTime($this->lh_entry->getTimestamp(), IL_CAL_UNIX);
47 }
48
49 public function render(): string
50 {
52 $parent_ref_id = 0;
53
54 $tpl = new ilTemplate("tpl.timeline_item_inner.html", true, true, "components/ILIAS/LearningHistory");
55
56 $f = $this->ui->factory();
57 $r = $this->ui->renderer();
58
59 $ico = $f->symbol()->icon()->custom($this->lh_entry->getIconPath(), '')->withSize(\ILIAS\UI\Component\Symbol\Icon\Icon::MEDIUM);
60
61 $obj_id = $this->lh_entry->getObjId();
62 $title = ilObject::_lookupTitle($obj_id);
63 if ($this->lh_entry->getRefId() === 0) {
64 $ref_ids = ilObject::_getAllReferences($obj_id);
65 } else {
66 $ref_ids = [$this->lh_entry->getRefId()];
67 }
68 $readable_ref_id = 0;
69 foreach ($ref_ids as $ref_id) {
70 if ($readable_ref_id === 0 && $access->checkAccessOfUser($this->user_id, "read", "", $ref_id)) {
71 $readable_ref_id = $ref_id;
72 }
73 }
74
75 if ($readable_ref_id > 0) {
76 if (ilObject::_lookupType(ilObject::_lookupObjId($readable_ref_id)) === "crs") {
77 $parent_ref_id = $readable_ref_id;
78 } else {
79 $parent_ref_id = $this->tree->checkForParentType($readable_ref_id, "crs", true);
80 }
81 }
82
83 if ($parent_ref_id > 0) {
84 $text = $this->lh_entry->getAchieveInText();
85 $obj_placeholder = "<a href='" . ilLink::_getLink($parent_ref_id) . "'>" .
87 $text = str_replace("$2$", $obj_placeholder, $text);
88 } else {
89 $text = $this->lh_entry->getAchieveText();
90 }
91
92 $obj_placeholder = ($readable_ref_id > 0)
93 ? "<a href='" . ilLink::_getLink($readable_ref_id) . "'>" . $this->getEmphasizedTitle($title) . "</a>"
94 : $this->getEmphasizedTitle($title);
95 $text = str_replace("$1$", $obj_placeholder, $text);
96
97 $tpl->setVariable("TEXT", $text);
98 $tpl->setVariable("ICON", $r->render($ico));
99
100 return $tpl->get();
101 }
102
103 protected function getEmphasizedTitle(string $title): string
104 {
105 $tpl = new ilTemplate("tpl.emphasized_title.php", true, true, "components/ILIAS/LearningHistory");
106 $tpl->setVariable("TITLE", $title);
107 return $tpl->get();
108 }
109
110 public function renderFooter(): string
111 {
112 return "";
113 }
114}
const IL_CAL_UNIX
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilLearningHistoryEntry $lh_entry, \ILIAS\DI\UIServices $ui, int $user_id, ilAccessHandler $access, ilTree $tree)
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
special template class to simplify handling of ITX/PEAR
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
Class HTTPServicesTest.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.