ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilFileVersionTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("Services/Table/classes/class.ilTable2GUI.php");
5 include_once("Services/Utilities/classes/class.ilFileUtils.php");
6 
19 {
20  var $confirmDelete = false;
22 
29  function __construct($a_parent_obj, $a_parent_cmd, $confirmDelete = false)
30  {
31  global $ilCtrl, $lng;
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  $this->current_version = $a_parent_obj->object->getVersion();
36  $this->confirmDelete = $confirmDelete;
37 
38  $lng->loadLanguageModule("file");
39 
40  // general properties
41  $this->setRowTemplate("tpl.file_version_row.html", "Modules/File");
42  $this->setLimit(9999);
43  $this->setPrefix("versions");
44  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
45  $this->setEnableHeader(true);
46  $this->disable("footer");
47 
48  // properties depending on confirmation
49  if (!$this->confirmDelete)
50  {
51  $this->setTitle($lng->txt("versions"));
52  $this->setSelectAllCheckbox("hist_id[]");
53  }
54 
55  // columns
56  if (!$this->confirmDelete)
57  $this->addColumn("", "", "1", true);
58 
59  $this->addColumn($lng->txt("version"), "", "1");
60  $this->addColumn($lng->txt("date"));
61  $this->addColumn($lng->txt("file_uploaded_by"));
62  $this->addColumn($lng->txt("filename"));
63  $this->addColumn($lng->txt("filesize"), "", "", false, "ilRight");
64 
65  if (!$this->confirmDelete)
66  {
67  $this->addColumn($lng->txt("action"));
68  $this->addColumn("", "", "1");
69  }
70 
71  // commands depending on confirmation
72  if (!$this->confirmDelete)
73  {
74  $this->addMultiCommand("deleteVersions", $lng->txt("delete"));
75  $this->addMultiCommand("rollbackVersion", $lng->txt("file_rollback"));
76  }
77  else
78  {
79  $this->addCommandButton("confirmDeleteVersions", $lng->txt("confirm"));
80  $this->addCommandButton("cancelDeleteVersions", $lng->txt("cancel"));
81  }
82  }
83 
88  protected function fillRow($a_set)
89  {
90  global $lng, $ilCtrl, $ilAccess;
91 
92  $hist_id = $a_set["hist_entry_id"];
93 
94  // split params
95  $filename = $a_set["filename"];
96  $version = $a_set["version"];
97  $rollback_version = $a_set["rollback_version"];
98  $rollback_user_id = $a_set["rollback_user_id"];
99 
100  // get user name
101  $name = ilObjUser::_lookupName($a_set["user_id"]);
102  $username = trim($name["title"] . " " . $name["firstname"] . " " . $name["lastname"]);
103 
104  // get file size
105  // bugfix mantis 0022054
106  $directory = $this->parent_obj->object->getDirectory($version);
107  $filepath = ilFileUtils::getValidFilename(rtrim($directory, "/") . "/" . $filename);
108  $filesize = filesize($filepath);
109 
110  // get action text
111  $action = $lng->txt("file_version_" . $a_set["action"]); // create, replace, new_version, rollback
112  if ($a_set["action"] == "rollback")
113  {
114  $name = ilObjUser::_lookupName($rollback_user_id);
115  $rollback_username = trim($name["title"] . " " . $name["firstname"] . " " . $name["lastname"]);
116  $action = sprintf($action, $rollback_version, $rollback_username);
117  }
118 
119  // get download link
120  $ilCtrl->setParameter($this->parent_obj, "hist_id", $hist_id);
121  $link = $ilCtrl->getLinkTarget($this->parent_obj, "sendfile");
122 
123  // build actions
124  include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
125  $actions = new ilAdvancedSelectionListGUI();
126  $actions->setId($hist_id);
127  $actions->setListTitle($lng->txt("actions"));
128  $actions->addItem($lng->txt("delete"), "", $ilCtrl->getLinkTarget($this->parent_obj, "deleteVersions"));
129  if ($this->current_version != $version)
130  $actions->addItem($lng->txt("file_rollback"), "", $ilCtrl->getLinkTarget($this->parent_obj, "rollbackVersion"));
131 
132  // reset history parameter
133  $ilCtrl->setParameter($this->parent_obj, "hist_id", "");
134 
135  // fill template
136  $this->tpl->setVariable("TXT_VERSION", $version);
137  $this->tpl->setVariable("TXT_DATE", ilDatePresentation::formatDate(new ilDateTime($a_set['date'],IL_CAL_DATETIME)));
138  $this->tpl->setVariable("TXT_UPLOADED_BY", $username);
139  $this->tpl->setVariable("DL_LINK", $link);
140  $this->tpl->setVariable("TXT_FILENAME", $filename);
141  $this->tpl->setVariable("TXT_FILESIZE", ilUtil::formatSize($filesize));
142 
143  // columns depending on confirmation
144  if (!$this->confirmDelete)
145  {
146  $this->tpl->setCurrentBlock("version_selection");
147  $this->tpl->setVariable("OBJ_ID", $hist_id);
148  $this->tpl->parseCurrentBlock();
149 
150  $this->tpl->setCurrentBlock("version_txt_actions");
151  $this->tpl->setVariable("TXT_ACTION", $action);
152  $this->tpl->parseCurrentBlock();
153 
154  $this->tpl->setCurrentBlock("version_actions");
155  $this->tpl->setVariable("ACTIONS", $actions->getHTML());
156  $this->tpl->parseCurrentBlock();
157  }
158  else
159  {
160  $this->tpl->setCurrentBlock("version_id");
161  $this->tpl->setVariable("OBJ_ID", $hist_id);
162  $this->tpl->parseCurrentBlock();
163  }
164  }
165 }
166 ?>
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static _lookupName($a_user_id)
lookup user name
fillRow($a_set)
Standard Version of Fill Row.
const IL_CAL_DATETIME
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
__construct($a_parent_obj, $a_parent_cmd, $confirmDelete=false)
Creates a new ilFileVersionTableGUI instance.
Class ilTable2GUI.
addMultiCommand($a_cmd, $a_text)
Add Command button.
static formatDate(ilDateTime $date)
Format a date public.
setPrefix($a_prefix)
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
global $lng
Definition: privfeed.php:17
setEnableHeader($a_enableheader)
Set Enable Header.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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.
Class ilFileVersionTableGUI.
static getValidFilename($a_filename)
Get valid filename.
setLimit($a_limit=0, $a_default_limit=0)