ILIAS  release_8 Revision v8.24
class.ilHistoryTableGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected int $obj_id;
27 protected string $obj_type;
28 protected int $ref_id;
29 protected ilCtrl $ilCtrl;
30 protected bool $comment_visibility = false;
31
32
33 public function __construct(
34 object $a_parent_obj,
35 string $a_parent_cmd,
36 int $a_obj_id,
37 string $a_obj_type = null
38 ) {
39 global $DIC;
40
41 $ilCtrl = $DIC->ctrl();
42 parent::__construct($a_parent_obj, $a_parent_cmd);
43
44 $this->setObjId($a_obj_id);
45 $this->setObjType($a_obj_type);
46 $this->ilCtrl = $ilCtrl;
47 }
48
49 public function getDataFromDb(): void
50 {
51 $entries = ilHistory::_getEntriesForObject($this->getObjId(), $this->getObjType());
52 $this->setData($entries);
53 }
54
55 public function initTable(): void
56 {
57 $this->setRowTemplate("tpl.history_row.html", "Services/History");
58 $this->setFormAction($this->ilCtrl->getFormAction($this->getParentObject()));
59
60 $this->setTitle($this->lng->txt("history"));
61 $this->addColumn($this->lng->txt("user"), "", "25%");
62 $this->addColumn($this->lng->txt("date"), "", "25%");
63 $this->addColumn($this->lng->txt("action"), "", "50%");
64
65 $this->getDataFromDb();
66 }
67
68 protected function fillRow(array $a_set): void
69 {
70 $this->tpl->setVariable("TXT_USER", ilUserUtil::getNamePresentation($a_set["user_id"], false, false));
71 $this->tpl->setVariable(
72 'TXT_DATE',
74 );
75 $this->tpl->setVariable("TXT_ACTION", $this->createInfoText($a_set));
76
77 if ($this->getObjType() == "lm") {
78 $obj_arr = explode(":", $a_set["obj_type"]);
79 switch ($obj_arr[1] ?? "") {
80 case "st":
81 $img_type = "st";
82 $class = "ilstructureobjectgui";
83 $cmd = "view";
84 break;
85
86 case "pg":
87 $img_type = "pg";
88 $class = "illmpageobjectgui";
89 $cmd = "edit";
90 break;
91
92 default:
93 $img_type = $obj_arr[0] ?? "";
94 $class = "";
95 $cmd = "view";
96 break;
97 }
98
99 $this->tpl->setCurrentBlock("item_icon");
100 $this->tpl->setVariable("SRC_ICON",
101 ilUtil::getImagePath("icon_" . $img_type . ".svg")
102 );
103 $this->tpl->parseCurrentBlock();
104
105 if ($class != "") {
106 $this->tpl->setCurrentBlock("item_link");
107 $this->ilCtrl->setParameterByClass($class, "obj_id", $a_set["obj_id"]);
108 $this->tpl->setVariable(
109 "HREF_LINK",
110 $this->ilCtrl->getLinkTargetByClass($class, $cmd)
111 );
112 $this->tpl->setVariable("TXT_LINK", $a_set["title"]);
113 } else {
114 $this->tpl->setCurrentBlock("item_title");
115 $this->tpl->setVariable(
116 "TXT_TITLE",
117 ilObject::_lookupTitle($a_set["obj_id"])
118 );
119 }
120 $this->tpl->parseCurrentBlock();
121 }
122
123 if ($this->isCommentVisible() && $a_set["user_comment"] != "") {
124 $this->tpl->setCurrentBlock("user_comment");
125 $this->tpl->setVariable("TXT_COMMENT", $this->lng->txt("comment"));
126 $this->tpl->setVariable("TXT_USER_COMMENT", $a_set["user_comment"]);
127 $this->tpl->parseCurrentBlock();
128 }
129 }
130
134 protected function createInfoText(array $a_set): string
135 {
136 $info_params = explode(",", $a_set["info_params"]);
137
138 switch ($this->getObjType()) {
139 case "lm":
140 $info_text = $this->lng->txt("hist_" . str_replace(":", "_", $a_set["obj_type"]) .
141 "_" . $a_set["action"]);
142 break;
143 default:
144 $info_text = $this->lng->txt("hist_" . str_replace(":", "_", $this->getObjType()) .
145 "_" . $a_set["action"]);
146 break;
147 }
148
149 $i = 1;
150 foreach ($info_params as $info_param) {
151 $info_text = str_replace("%" . $i, $info_param, $info_text);
152 $i++;
153 }
154
155 return $info_text;
156 }
157
158 public function setCommentVisibility(bool $a_visible): void
159 {
160 $this->comment_visibility = $a_visible;
161 }
162
163 public function isCommentVisible(): bool
164 {
166 }
167
168 public function setObjId(int $a_obj_id): void
169 {
170 $this->obj_id = $a_obj_id;
171 }
172
173 public function getObjId(): int
174 {
175 return $this->obj_id;
176 }
177
178 public function setObjType(string $a_obj_type): void
179 {
180 $this->obj_type = $a_obj_type;
181 }
182
183 public function getObjType(): string
184 {
185 if (!$this->obj_type) {
186 $this->setObjType(ilObject::_lookupType($this->getObjId()));
187 }
188 return $this->obj_type;
189 }
190}
const IL_CAL_DATETIME
Class ilCtrl provides processing control methods.
getLinkTargetByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
getFormAction(object $a_gui_obj, string $a_fallback_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setObjType(string $a_obj_type)
createInfoText(array $a_set)
format info parameters into info text
setCommentVisibility(bool $a_visible)
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_obj_id, string $a_obj_type=null)
fillRow(array $a_set)
Standard Version of Fill Row.
static _getEntriesForObject(int $a_obj_id, string $a_obj_type="")
get all history entries for an object
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc