ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilHistoryTableGUI.php
Go to the documentation of this file.
1<?php
2include_once('./Services/Table/classes/class.ilTable2GUI.php');
3include_once('./Services/History/classes/class.ilHistory.php');
4include_once('./Services/User/classes/class.ilUserUtil.php');
19{
20 protected $obj_id;
21 protected $obj_type;
22 protected $ref_id;
23 protected $ilCtrl;
24
25 protected $comment_visibility = false;
26
27
28 function __construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_obj_type = null)
29 {
30 global $ilCtrl;
31 parent::__construct($a_parent_obj, $a_parent_cmd);
32
33 $this->setObjId($a_obj_id);
34 $this->setObjType($a_obj_type);
35 $this->ilCtrl = $ilCtrl;
36 }
37
41 public function getDataFromDb()
42 {
43 $entries = ilHistory::_getEntriesForObject($this->getObjId(), $this->getObjType());
44 $this->setData($entries);
45 }
46
50 public function initTable()
51 {
52 $this->setRowTemplate("tpl.history_row.html", "Services/History");
53 $this->setFormAction($this->ilCtrl->getFormAction($this->getParentObject()));
54
55 $this->setTitle($this->lng->txt("history"));
56 $this->addColumn($this->lng->txt("user"), "", "25%");
57 $this->addColumn($this->lng->txt("date"), "", "25%");
58 $this->addColumn($this->lng->txt("action"), "", "50%");
59
60 $this->getDataFromDb();
61 }
62
66 protected function fillRow($a_set)
67 {
68 $this->tpl->setVariable("TXT_USER",ilUserUtil::getNamePresentation($a_set["user_id"], false,false));
69 $this->tpl->setVariable('TXT_DATE',
71 $this->tpl->setVariable("TXT_ACTION", $this->createInfoText($a_set));
72
73 if ($this->getObjType() == "lm" || $this->getObjType() == "dbk")
74 {
75 $obj_arr = explode(":", $a_set["obj_type"]);
76 switch ($obj_arr[1])
77 {
78 case "st":
79 $img_type = "st";
80 $class = "ilstructureobjectgui";
81 $cmd = "view";
82 break;
83
84 case "pg":
85 $img_type = "pg";
86 $class = "illmpageobjectgui";
87 $cmd = "edit";
88 break;
89
90 default:
91 $img_type = $obj_arr[0];
92 $class = "";
93 $cmd = "view";
94 break;
95 }
96
97 $this->tpl->setCurrentBlock("item_icon");
98 $this->tpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_".$img_type.".svg"));
99 $this->tpl->parseCurrentBlock();
100
101 if ($class != "")
102 {
103 $this->tpl->setCurrentBlock("item_link");
104 $this->ilCtrl->setParameterByClass($class, "obj_id", $a_set["obj_id"]);
105 $this->tpl->setVariable("HREF_LINK",
106 $this->ilCtrl->getLinkTargetByClass($class, $cmd));
107 $this->tpl->setVariable("TXT_LINK", $a_set["title"]);
108 $this->tpl->parseCurrentBlock();
109 }
110 else
111 {
112 $this->tpl->setCurrentBlock("item_title");
113 $this->tpl->setVariable("TXT_TITLE",
114 ilObject::_lookupTitle($a_set["obj_id"]));
115 $this->tpl->parseCurrentBlock();
116 }
117 }
118
119 if ($this->isCommentVisible() && $a_set["user_comment"] != "")
120 {
121 $this->tpl->setCurrentBlock("user_comment");
122 $this->tpl->setVariable("TXT_COMMENT", $this->lng->txt("comment"));
123 $this->tpl->setVariable("TXT_USER_COMMENT", $a_set["user_comment"]);
124 $this->tpl->parseCurrentBlock();
125 }
126 }
127
133 protected function createInfoText($a_set)
134 {
135 $info_params = explode(",", $a_set["info_params"]);
136
137 switch($this->getObjType())
138 {
139 case "lm":
140 case "dbk":
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 {
153 $info_text = str_replace("%".$i, $info_param, $info_text);
154 $i++;
155 }
156
157 return $info_text;
158 }
159
165 public function setCommentVisibility($a_visible)
166 {
167 $this->comment_visibility = (bool)$a_visible;
168 }
169
174 public function isCommentVisible()
175 {
177 }
178
183 public function setObjId($a_obj_id)
184 {
185 $this->obj_id = $a_obj_id;
186 }
187
192 public function getObjId()
193 {
194 return $this->obj_id;
195 }
196
201 public function setObjType($a_obj_type)
202 {
203 $this->obj_type = $a_obj_type;
204 }
205
210 public function getObjType()
211 {
212 if(!$this->obj_type)
213 {
214 $this->setObjType(ilObject::_lookupType($this->getObjId()));
215 }
216 return $this->obj_type;
217 }
218}
const IL_CAL_DATETIME
This class provides processing control methods.
getFormAction(&$a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class object.
getLinkTargetByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE Date: 24....
getDataFromDb()
Get data and put it into an array.
isCommentVisible()
comments visible?
fillRow($a_set)
Fill a single data row.
createInfoText($a_set)
format info parameters into info text
__construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_obj_type=null)
setObjType($a_obj_type)
set object type (not required)
getObjType()
get object type (if not set, it will be set via object id)
setCommentVisibility($a_visible)
set comments visible
setObjId($a_obj_id)
set object id
_getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$cmd
Definition: sahs_server.php:35