ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 }
setData(array $a_data)
const IL_CAL_DATETIME
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:
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_obj_id, string $a_obj_type=null)
setFormAction(string $a_form_action, bool $a_multipart=false)
static _getEntriesForObject(int $a_obj_id, string $a_obj_type="")
get all history entries for an object
createInfoText(array $a_set)
format info parameters into info text
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
setCommentVisibility(bool $a_visible)
global $DIC
Definition: feed.php:28
static _lookupTitle(int $obj_id)
setObjType(string $a_obj_type)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
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)
$i
Definition: metadata.php:41