/** * get versions table */ function getVersionsTable($a_header_params, $a_user_comment = false) { global $ilCtrl; $ref_id = $a_header_params["ref_id"]; require_once "./Services/Table/classes/class.ilTableGUI.php"; $tbl = new ilTableGUI(0, false); // table header $tbl->setTitle($this->lng->txt("versions")); $tbl->setHeaderNames(array($this->lng->txt("date") . "/" . $this->lng->txt("user"), $this->lng->txt("action"))); $tbl->setColumnWidth(array("40%", "60%")); $cols = array("date_user", "action"); if ($a_header_params == "") { $a_header_params = array(); } $header_params = $a_header_params; $tbl->setHeaderVars($cols, $header_params); // table variables $tbl->setOrderColumn($_GET["sort_by"]); $tbl->setOrderDirection($_GET["sort_order"]); $tbl->setLimit($_GET["limit"]); $tbl->setOffset($_GET["offset"]); $tbl->setMaxCount($this->maxcount); // ??? $tbl->disable("header"); // footer $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next")); // get history entries $entries = ilHistory::_getEntriesForObject($this->obj_id, $this->obj_type); $tbl->setMaxCount(count($entries)); $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]); $this->tpl =& $tbl->getTemplateObject(); $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.history_row.html", "Services/History"); if (count($entries) > 0) { $i = 0; foreach ($entries as $entry) { $this->tpl->setCurrentBlock("tbl_content"); $css_row = $css_row != "tblrow1" ? "tblrow1" : "tblrow2"; $this->tpl->setVariable("CSS_ROW", $css_row); $this->tpl->setVariable('TXT_DATE', ilDatePresentation::formatDate(new ilDateTime($entry['date'], IL_CAL_DATETIME))); $name = ilObjUser::_lookupName($entry["user_id"]); $this->tpl->setVariable("TXT_USER", $name["title"] . " " . $name["firstname"] . " " . $name["lastname"] . " [" . $entry["user_id"] . "]"); $info_params = explode(",", $entry["info_params"]); $info_text = $this->lng->txt("hist_" . $this->obj_type . "_" . $entry["action"]); $i = 1; foreach ($info_params as $info_param) { $info_text = str_replace("%" . $i, $info_param, $info_text); $i++; } $this->tpl->setVariable("TXT_ACTION", $info_text); if ($a_user_comment) { $this->tpl->setCurrentBlock("user_comment"); $this->tpl->setVariable("TXT_USER_COMMENT", $entry["user_comment"]); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("tbl_content"); } $this->tpl->setCurrentBlock("dl_link"); $this->tpl->setVariable("TXT_DL", $this->lng->txt("download")); $ilCtrl->setParameterByClass("ilobjfilegui", "hist_id", $entry["hist_entry_id"]); $this->tpl->setVariable("DL_LINK", $ilCtrl->getLinkTargetByClass("ilobjfilegui", "sendfile")); $this->tpl->setCurrentBlock("tbl_content"); $this->tpl->parseCurrentBlock(); } } else { $this->tpl->setCurrentBlock("tbl_content_cell"); $this->tpl->setVariable("TBL_CONTENT_CELL", $this->lng->txt("hist_no_entries")); $this->tpl->setVariable("TBL_COL_SPAN", 4); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("tbl_content_row"); $this->tpl->setVariable("ROWCOLOR", "tblrow1"); $this->tpl->parseCurrentBlock(); } $tbl->render(); //$this->tpl->parseCurrentBlock(); return $this->tpl->get(); }