ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLearningHistoryTimelineItem.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $lh_entry;
17
21 protected $ui;
22
26 protected $user_id;
27
31 protected $access;
32
36 protected $tree;
37
43 public function __construct(
45 \ILIAS\DI\UIServices $ui,
49 ) {
50 $this->access = $access;
51 $this->lh_entry = $lh_entry;
52 $this->ui = $ui;
53 $this->user_id = $user_id;
54 $this->tree = $tree;
55 }
56
60 public function getDatetime()
61 {
62 return new ilDateTime($this->lh_entry->getTimestamp(), IL_CAL_UNIX);
63 }
64
68 public function render()
69 {
71
72 $tpl = new ilTemplate("tpl.timeline_item_inner.html", true, true, "Services/LearningHistory");
73
74 $f = $this->ui->factory();
75 $r = $this->ui->renderer();
76
77 $ico = $f->symbol()->icon()->custom($this->lh_entry->getIconPath(), '')->withSize(\ILIAS\UI\Component\Symbol\Icon\Icon::MEDIUM);
78
79 $obj_id = $this->lh_entry->getObjId();
80 $title = ilObject::_lookupTitle($obj_id);
81 if ($this->lh_entry->getRefId() == 0) {
82 $ref_ids = ilObject::_getAllReferences($obj_id);
83 } else {
84 $ref_ids = [$this->lh_entry->getRefId()];
85 }
86 $readable_ref_id = 0;
87 foreach ($ref_ids as $ref_id) {
88 if ($readable_ref_id == 0 && $access->checkAccessOfUser($this->user_id, "read", "", $ref_id)) {
89 $readable_ref_id = $ref_id;
90 }
91 }
92
93 if ($readable_ref_id > 0) {
94 if (ilObject::_lookupType(ilObject::_lookupObjId($readable_ref_id)) == "crs") {
95 $parent_ref_id = $readable_ref_id;
96 } else {
97 $parent_ref_id = $this->tree->checkForParentType($readable_ref_id, "crs", true);
98 }
99 }
100
101 if ($parent_ref_id > 0) {
102 $text = $this->lh_entry->getAchieveInText();
103 $obj_placeholder = "<a href='" . ilLink::_getLink($parent_ref_id) . "'>" .
104 $this->getEmphasizedTitle(ilObject::_lookupTitle(ilObject::_lookupObjId($parent_ref_id))) . "</a>";
105 $text = str_replace("$2$", $obj_placeholder, $text);
106 } else {
107 $text = $this->lh_entry->getAchieveText();
108 }
109
110 $obj_placeholder = ($readable_ref_id > 0)
111 ? "<a href='" . ilLink::_getLink($readable_ref_id) . "'>" . $this->getEmphasizedTitle($title) . "</a>"
112 : $this->getEmphasizedTitle($title);
113 $text = str_replace("$1$", $obj_placeholder, $text);
114
115 $tpl->setVariable("TEXT", $text);
116 $tpl->setVariable("ICON", $r->render($ico));
117
118 return $tpl->get();
119 }
120
127 protected function getEmphasizedTitle($title)
128 {
129 $tpl = new ilTemplate("tpl.emphasized_title.php", true, true, "Services/LearningHistory");
130 $tpl->setVariable("TITLE", $title);
131 ;
132 return $tpl->get();
133 }
134
139 public function renderFooter()
140 {
141 }
142}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
@classDescription Date and time handling
__construct(ilLearningHistoryEntry $lh_entry, \ILIAS\DI\UIServices $ui, $user_id, ilAccessHandler $access, ilTree $tree)
Constructor ilLearningHistoryTimelineItem constructor.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
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.
Interface for timeline items.
Class HTTPServicesTest.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
ui()
Definition: ui.php:5