ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
5
6include_once("Services/Table/classes/class.ilTable2GUI.php");
7
20{
21 public $confirmDelete = false;
22 public $current_version = 0;
23
24
32 public function __construct(ilFileVersionsGUI $a_parent_obj, $a_parent_cmd, $confirmDelete = false)
33 {
34 global $DIC;
35 $ilCtrl = $DIC['ilCtrl'];
36 $lng = $DIC['lng'];
37
38 parent::__construct($a_parent_obj, $a_parent_cmd);
39
40 $this->current_version = $a_parent_obj->object->getVersion();
41 $this->confirmDelete = $confirmDelete;
42
43 $lng->loadLanguageModule("file");
44
45 // general properties
46 $this->setRowTemplate("tpl.file_version_row.html", "Modules/File");
47 $this->setLimit(9999);
48 $this->setPrefix("versions");
49 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
50 $this->setEnableHeader(true);
51
52 // properties depending on confirmation
53 if (!$this->confirmDelete) {
54 $this->setTitle($lng->txt("versions"));
55 $this->setSelectAllCheckbox("hist_id[]");
56 }
57
58 // columns
59 if (!$this->confirmDelete) {
60 $this->disable("footer");
61 $this->addColumn("", "", "1", true);
62 }
63
64 $this->addColumn($lng->txt("version"), "", "1");
65 $this->addColumn($lng->txt("date"));
66 $this->addColumn($lng->txt("file_uploaded_by"));
67 $this->addColumn($lng->txt("filename"));
68 $this->addColumn($lng->txt("filesize"), "", "", false, "ilRight");
69
70 if (!$this->confirmDelete) {
71 $this->addColumn($lng->txt("type"));
72 $this->addColumn($lng->txt("action"));
73 $this->addColumn("", "", "1");
74 }
75
76 // commands depending on confirmation
77 if (!$this->confirmDelete) {
78 $this->addMultiCommand("deleteVersions", $lng->txt("delete"));
79 $this->addMultiCommand("rollbackVersion", $lng->txt("file_rollback"));
80 } else {
81 $this->addCommandButton("confirmDeleteVersions", $lng->txt("confirm"));
82 $this->addCommandButton("cancelDeleteVersions", $lng->txt("cancel"));
83 }
84 }
85
86
91 protected function fillRow($a_set)
92 {
93 global $DIC;
94 $lng = $DIC['lng'];
95 $ilCtrl = $DIC['ilCtrl'];
96 $ilAccess = $DIC['ilAccess'];
97
98 $hist_id = $a_set["hist_entry_id"];
99
100 // split params
101 $filename = $a_set["filename"];
102 $version = $a_set["version"];
103 $rollback_version = $a_set["rollback_version"];
104 $rollback_user_id = $a_set["rollback_user_id"];
105
106 // get user name
107 $name = ilObjUser::_lookupName($a_set["user_id"]);
108 $username = trim($name["title"] . " " . $name["firstname"] . " " . $name["lastname"]);
109
110 // get file size
114 $object = $this->parent_obj->object;
115 $directory = LegacyPathHelper::createRelativePath($object->getDirectory($version));
116 $filepath = ilFileUtils::getValidFilename(rtrim($directory, "/") . "/" . $filename); // TODO remove after migration to filesystem
117 $filesize = 0;
118 if ($DIC->filesystem()->storage()->has($filepath)) {
119 $size = $filesize = $DIC->filesystem()->storage()->getSize($filepath, \ILIAS\Data\DataSize::Byte);
120 $filesize = $size->getSize();
121 }
122
123 // get action text
124 $action = $lng->txt("file_version_" . $a_set["action"]); // create, replace, new_version, rollback
125 if ($a_set["action"] == "rollback") {
126 $name = ilObjUser::_lookupName($rollback_user_id);
127 $rollback_username = trim($name["title"] . " " . $name["firstname"] . " " . $name["lastname"]);
128 $action = sprintf($action, $rollback_version, $rollback_username);
129 }
130
131 // get download link
132 $ilCtrl->setParameter($this->parent_obj, "hist_id", $hist_id);
133 $link = $ilCtrl->getLinkTarget($this->parent_obj, "sendfile");
134
135 // build actions
136 include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
137 $actions = new ilAdvancedSelectionListGUI();
138 $actions->setId($hist_id);
139 $actions->setListTitle($lng->txt("actions"));
140 $actions->addItem($lng->txt("delete"), "", $ilCtrl->getLinkTarget($this->parent_obj, "deleteVersions"));
141 if ($this->current_version != $version) {
142 $actions->addItem($lng->txt("file_rollback"), "", $ilCtrl->getLinkTarget($this->parent_obj, "rollbackVersion"));
143 }
144
145 // reset history parameter
146 $ilCtrl->setParameter($this->parent_obj, "hist_id", "");
147
148 // fill template
149 $this->tpl->setVariable("TXT_VERSION", $version);
150 $this->tpl->setVariable("TXT_DATE", ilDatePresentation::formatDate(new ilDateTime($a_set['date'], IL_CAL_DATETIME)));
151 $this->tpl->setVariable("TXT_UPLOADED_BY", $username);
152 $this->tpl->setVariable("DL_LINK", $link);
153 $this->tpl->setVariable("TXT_FILENAME", $filename);
154 $this->tpl->setVariable("TXT_FILESIZE", ilUtil::formatSize($filesize));
155
156 // columns depending on confirmation
157 if (!$this->confirmDelete) {
158 $this->tpl->setCurrentBlock("version_selection");
159 $this->tpl->setVariable("OBJ_ID", $hist_id);
160 $this->tpl->parseCurrentBlock();
161
162 $this->tpl->setCurrentBlock("version_txt_actions");
163 $this->tpl->setVariable("TXT_ACTION", $action);
164 $this->tpl->parseCurrentBlock();
165
166 $this->tpl->setCurrentBlock("version_actions");
167 $this->tpl->setVariable("ACTIONS", $actions->getHTML());
168 $this->tpl->parseCurrentBlock();
169 } else {
170 $this->tpl->setCurrentBlock("version_id");
171 $this->tpl->setVariable("OBJ_ID", $hist_id);
172 $this->tpl->parseCurrentBlock();
173 }
174 }
175}
$size
Definition: RandomTest.php:84
$filename
Definition: buildRTE.php:89
$version
Definition: build.php:27
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static getValidFilename($a_filename)
Get valid filename.
Class ilFileVersionTableGUI.
__construct(ilFileVersionsGUI $a_parent_obj, $a_parent_cmd, $confirmDelete=false)
ilFileVersionTableGUI constructor.
Class ilFileVersionsGUI.
static _lookupName($a_user_id)
lookup user name
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
fillRow($a_set)
Standard Version of Fill Row.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command 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.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
$action
global $ilCtrl
Definition: ilias.php:18
Class BaseForm.
global $DIC
Definition: saml.php:7