00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once("classes/class.ilHistory.php");
00025
00033 class ilHistoryGUI
00034 {
00035 var $obj_id;
00036 var $lng;
00037 var $tpl;
00038
00039 function ilHistoryGUI($a_obj_id, $a_obj_type = "")
00040 {
00041 global $lng, $ilCtrl;
00042
00043 $this->obj_id = $a_obj_id;
00044
00045 if ($a_obj_type == "")
00046 {
00047 $this->obj_type = ilObject::_lookupType($a_obj_id);
00048 }
00049 else
00050 {
00051 $this->obj_type = $a_obj_type;
00052 }
00053
00054 $this->lng =& $lng;
00055 $this->ctrl =& $ilCtrl;
00056 }
00057
00058
00062 function getHistoryTable($a_header_params, $a_user_comment = false)
00063 {
00064 $ref_id = $a_header_params["ref_id"];
00065
00066 require_once("classes/class.ilTableGUI.php");
00067 $tbl = new ilTableGUI(0, false);
00068
00069
00070 $tbl->setTitle($this->lng->txt("history"));
00071
00072 $tbl->setHeaderNames(array($this->lng->txt("date")."/".
00073 $this->lng->txt("user"), $this->lng->txt("action")));
00074 $tbl->setColumnWidth(array("40%", "60%"));
00075 $cols = array("date_user", "action");
00076
00077 if ($a_header_params == "")
00078 {
00079 $a_header_params = array();
00080 }
00081 $header_params = $a_header_params;
00082 $tbl->setHeaderVars($cols, $header_params);
00083
00084
00085 $tbl->setOrderColumn($_GET["sort_by"]);
00086 $tbl->setOrderDirection($_GET["sort_order"]);
00087 $tbl->setLimit($_GET["limit"]);
00088 $tbl->setOffset($_GET["offset"]);
00089 $tbl->setMaxCount($this->maxcount);
00090 $tbl->disable("header");
00091
00092
00093 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00094
00095
00096 $entries = ilHistory::_getEntriesForObject($this->obj_id, $this->obj_type);
00097
00098 $tbl->setMaxCount(count($entries));
00099 $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
00100
00101 $this->tpl =& $tbl->getTemplateObject();
00102 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.history_row.html", false);
00103
00104 if(count($entries) > 0)
00105 {
00106 $i=0;
00107 foreach($entries as $entry)
00108 {
00109 $this->tpl->setCurrentBlock("tbl_content");
00110 $css_row = ($css_row != "tblrow1") ? "tblrow1" : "tblrow2";
00111 $this->tpl->setVariable("CSS_ROW", $css_row);
00112 $this->tpl->setVariable("TXT_DATE", $entry["date"]);
00113 $name = ilObjUser::_lookupName($entry["user_id"]);
00114 $login = ilObjUser::_lookupLogin($entry["user_id"]);
00115 $this->tpl->setVariable("TXT_USER",
00116 $name["title"]." ".$name["firstname"]." ".$name["lastname"]." [".$login."]");
00117 $info_params = explode(",", $entry["info_params"]);
00118
00119
00120 if ($this->obj_type != "lm" && $this->obj_type != "dbk")
00121 {
00122 $info_text = $this->lng->txt("hist_".str_replace(":", "_", $this->obj_type).
00123 "_".$entry["action"]);
00124 }
00125 else
00126 {
00127 $info_text = $this->lng->txt("hist_".str_replace(":", "_", $entry["obj_type"]).
00128 "_".$entry["action"]);
00129 }
00130 $i=1;
00131 foreach($info_params as $info_param)
00132 {
00133 $info_text = str_replace("%".$i, $info_param, $info_text);
00134 $i++;
00135 }
00136 $this->tpl->setVariable("TXT_ACTION", $info_text);
00137 if ($this->obj_type == "lm" || $this->obj_type == "dbk")
00138 {
00139 $obj_arr = explode(":", $entry["obj_type"]);
00140 switch ($obj_arr[1])
00141 {
00142 case "st":
00143 $img_type = "st";
00144 $class = "ilstructureobjectgui";
00145 break;
00146
00147 case "pg":
00148 $img_type = "pg";
00149 $class = "illmpageobjectgui";
00150 break;
00151
00152 default:
00153 $img_type = $obj_arr[0];
00154 $class = "";
00155 break;
00156 }
00157
00158 $this->tpl->setCurrentBlock("item_icon");
00159 $this->tpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_".$img_type.".gif"));
00160 $this->tpl->parseCurrentBlock();
00161
00162 if ($class != "")
00163 {
00164 $this->tpl->setCurrentBlock("item_link");
00165 $this->ctrl->setParameterByClass($class, "obj_id", $entry["obj_id"]);
00166 $this->tpl->setVariable("HREF_LINK",
00167 $this->ctrl->getLinkTargetByClass($class, "view"));
00168 $this->tpl->setVariable("TXT_LINK", $entry["title"]);
00169 $this->tpl->parseCurrentBlock();
00170 }
00171 else
00172 {
00173 $this->tpl->setCurrentBlock("item_title");
00174 $this->tpl->setVariable("TXT_TITLE",
00175 ilObject::_lookupTitle($entry["obj_id"]));
00176 $this->tpl->parseCurrentBlock();
00177 }
00178 }
00179 if ($a_user_comment && $entry["user_comment"] != "")
00180 {
00181 $this->tpl->setCurrentBlock("user_comment");
00182 $this->tpl->setVariable("TXT_COMMENT", $this->lng->txt("comment"));
00183 $this->tpl->setVariable("TXT_USER_COMMENT", $entry["user_comment"]);
00184 $this->tpl->parseCurrentBlock();
00185 }
00186 $this->tpl->setCurrentBlock("tbl_content");
00187
00188 $this->tpl->setCurrentBlock("tbl_content");
00189 $this->tpl->parseCurrentBlock();
00190 }
00191 }
00192 else
00193 {
00194 $this->tpl->setCurrentBlock("tbl_content_cell");
00195 $this->tpl->setVariable("TBL_CONTENT_CELL", $this->lng->txt("hist_no_entries"));
00196 $this->tpl->setVariable("TBL_COL_SPAN", 4);
00197 $this->tpl->parseCurrentBlock();
00198 $this->tpl->setCurrentBlock("tbl_content_row");
00199 $this->tpl->setVariable("ROWCOLOR", "tblrow1");
00200 $this->tpl->parseCurrentBlock();
00201 }
00202 $tbl->render();
00203
00204
00205 return $this->tpl->get();
00206 }
00207
00211 function getVersionsTable($a_header_params, $a_user_comment = false)
00212 {
00213 $ref_id = $a_header_params["ref_id"];
00214
00215 require_once("classes/class.ilTableGUI.php");
00216 $tbl = new ilTableGUI(0, false);
00217
00218
00219 $tbl->setTitle($this->lng->txt("versions"));
00220
00221 $tbl->setHeaderNames(array($this->lng->txt("date")."/".
00222 $this->lng->txt("user"), $this->lng->txt("action")));
00223 $tbl->setColumnWidth(array("40%", "60%"));
00224 $cols = array("date_user", "action");
00225
00226 if ($a_header_params == "")
00227 {
00228 $a_header_params = array();
00229 }
00230 $header_params = $a_header_params;
00231 $tbl->setHeaderVars($cols, $header_params);
00232
00233
00234 $tbl->setOrderColumn($_GET["sort_by"]);
00235 $tbl->setOrderDirection($_GET["sort_order"]);
00236 $tbl->setLimit($_GET["limit"]);
00237 $tbl->setOffset($_GET["offset"]);
00238 $tbl->setMaxCount($this->maxcount);
00239 $tbl->disable("header");
00240
00241
00242 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00243
00244
00245 $entries = ilHistory::_getEntriesForObject($this->obj_id, $this->obj_type);
00246
00247 $tbl->setMaxCount(count($entries));
00248 $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
00249
00250 $this->tpl =& $tbl->getTemplateObject();
00251 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.history_row.html", false);
00252
00253 if(count($entries) > 0)
00254 {
00255 $i=0;
00256 foreach($entries as $entry)
00257 {
00258 $this->tpl->setCurrentBlock("tbl_content");
00259 $css_row = ($css_row != "tblrow1") ? "tblrow1" : "tblrow2";
00260 $this->tpl->setVariable("CSS_ROW", $css_row);
00261 $this->tpl->setVariable("TXT_DATE", $entry["date"]);
00262 $name = ilObjUser::_lookupName($entry["user_id"]);
00263 $this->tpl->setVariable("TXT_USER",
00264 $name["title"]." ".$name["firstname"]." ".$name["lastname"]." [".$entry["user_id"]."]");
00265 $info_params = explode(",", $entry["info_params"]);
00266 $info_text = $this->lng->txt("hist_".$this->obj_type.
00267 "_".$entry["action"]);
00268 $i=1;
00269 foreach($info_params as $info_param)
00270 {
00271 $info_text = str_replace("%".$i, $info_param, $info_text);
00272 $i++;
00273 }
00274 $this->tpl->setVariable("TXT_ACTION", $info_text);
00275 if ($a_user_comment)
00276 {
00277 $this->tpl->setCurrentBlock("user_comment");
00278 $this->tpl->setVariable("TXT_USER_COMMENT", $entry["user_comment"]);
00279 $this->tpl->parseCurrentBlock();
00280 $this->tpl->setCurrentBlock("tbl_content");
00281 }
00282
00283 $this->tpl->setCurrentBlock("dl_link");
00284 $this->tpl->setVariable("TXT_DL", $this->lng->txt("download"));
00285 $this->tpl->setVariable("DL_LINK", "repository.php?cmd=sendfile&hist_id=".$entry["hist_entry_id"]."&ref_id=".$ref_id);
00286 $this->tpl->setCurrentBlock("tbl_content");
00287 $this->tpl->parseCurrentBlock();
00288
00289 }
00290 }
00291 else
00292 {
00293 $this->tpl->setCurrentBlock("tbl_content_cell");
00294 $this->tpl->setVariable("TBL_CONTENT_CELL", $this->lng->txt("hist_no_entries"));
00295 $this->tpl->setVariable("TBL_COL_SPAN", 4);
00296 $this->tpl->parseCurrentBlock();
00297 $this->tpl->setCurrentBlock("tbl_content_row");
00298 $this->tpl->setVariable("ROWCOLOR", "tblrow1");
00299 $this->tpl->parseCurrentBlock();
00300 }
00301
00302 $tbl->render();
00303
00304
00305 return $this->tpl->get();
00306 }
00307
00308 }
00309 ?>