ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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", "components/ILIAS/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(
101 "SRC_ICON",
102 ilUtil::getImagePath("standard/icon_" . $img_type . ".svg")
103 );
104 $this->tpl->parseCurrentBlock();
105
106 if ($class != "") {
107 $this->tpl->setCurrentBlock("item_link");
108 $this->ilCtrl->setParameterByClass($class, "obj_id", $a_set["obj_id"]);
109 $this->tpl->setVariable(
110 "HREF_LINK",
111 $this->ilCtrl->getLinkTargetByClass($class, $cmd)
112 );
113 $this->tpl->setVariable("TXT_LINK", $a_set["title"]);
114 } else {
115 $this->tpl->setCurrentBlock("item_title");
116 $this->tpl->setVariable(
117 "TXT_TITLE",
118 ilObject::_lookupTitle($a_set["obj_id"])
119 );
120 }
121 $this->tpl->parseCurrentBlock();
122 }
123
124 if ($this->isCommentVisible() && $a_set["user_comment"] != "") {
125 $this->tpl->setCurrentBlock("user_comment");
126 $this->tpl->setVariable("TXT_COMMENT", $this->lng->txt("comment"));
127 $this->tpl->setVariable("TXT_USER_COMMENT", $a_set["user_comment"]);
128 $this->tpl->parseCurrentBlock();
129 }
130 }
131
135 protected function createInfoText(array $a_set): string
136 {
137 $info_params = explode(",", $a_set["info_params"]);
138
139 switch ($this->getObjType()) {
140 case "lm":
141 $info_text = $this->lng->txt("hist_" . str_replace(":", "_", $a_set["obj_type"]) .
142 "_" . $a_set["action"]);
143 break;
144 default:
145 $info_text = $this->lng->txt("hist_" . str_replace(":", "_", $this->getObjType()) .
146 "_" . $a_set["action"]);
147 break;
148 }
149
150 $i = 1;
151 foreach ($info_params as $info_param) {
152 $info_text = str_replace("%" . $i, $info_param, $info_text);
153 $i++;
154 }
155
156 return $info_text;
157 }
158
159 public function setCommentVisibility(bool $a_visible): void
160 {
161 $this->comment_visibility = $a_visible;
162 }
163
164 public function isCommentVisible(): bool
165 {
167 }
168
169 public function setObjId(int $a_obj_id): void
170 {
171 $this->obj_id = $a_obj_id;
172 }
173
174 public function getObjId(): int
175 {
176 return $this->obj_id;
177 }
178
179 public function setObjType(string $a_obj_type): void
180 {
181 $this->obj_type = $a_obj_type;
182 }
183
184 public function getObjType(): string
185 {
186 if (!$this->obj_type) {
187 $this->setObjType(ilObject::_lookupType($this->getObjId()));
188 }
189 return $this->obj_type;
190 }
191}
const IL_CAL_DATETIME
Class ilCtrl provides processing control methods.
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
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@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)
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_obj_id, ?string $a_obj_type=null)
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=null)
Default behaviour is:
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26