ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
53 // properties depending on confirmation
54 if (!$this->confirmDelete) {
55 $this->setTitle($lng->txt("versions"));
56 $this->setSelectAllCheckbox("hist_id[]");
57 }
58
59 // columns
60 if (!$this->confirmDelete) {
61 $this->disable("footer");
62 $this->addColumn("", "", "1", true);
63 }
64
65 $this->addColumn($lng->txt("version"), "", "1");
66 $this->addColumn($lng->txt("date"));
67 $this->addColumn($lng->txt("file_uploaded_by"));
68 $this->addColumn($lng->txt("filename"));
69 $this->addColumn($lng->txt("filesize"), "", "", false, "ilRight");
70
71 if (!$this->confirmDelete) {
72 $this->addColumn($lng->txt("type"));
73 $this->addColumn($lng->txt("action"));
74 $this->addColumn("", "", "1");
75 }
76
77 // commands depending on confirmation
78 if (!$this->confirmDelete) {
79 $this->addMultiCommand("deleteVersions", $lng->txt("delete"));
80 $this->addMultiCommand("rollbackVersion", $lng->txt("file_rollback"));
81 } else {
82 $this->addCommandButton("confirmDeleteVersions", $lng->txt("confirm"));
83 $this->addCommandButton("cancelDeleteVersions", $lng->txt("cancel"));
84 }
85 }
86
87
92 protected function fillRow($a_set)
93 {
94 global $DIC;
95 $lng = $DIC['lng'];
96 $ilCtrl = $DIC['ilCtrl'];
97 $ilAccess = $DIC['ilAccess'];
98
99 $hist_id = $a_set["hist_entry_id"];
100
101 // split params
102 $filename = $a_set["filename"];
103 $version = $a_set["version"];
104 $rollback_version = $a_set["rollback_version"];
105 $rollback_user_id = $a_set["rollback_user_id"];
106
107 // get user name
108 $name = ilObjUser::_lookupName($a_set["user_id"]);
109 $username = trim($name["title"] . " " . $name["firstname"] . " " . $name["lastname"]);
110
111 // get file size
115 $object = $this->parent_obj->object;
116 $directory = LegacyPathHelper::createRelativePath($object->getDirectory($version));
117 $filepath = ilFileUtils::getValidFilename(rtrim($directory, "/") . "/" . $filename); // TODO remove after migration to filesystem
118 $filesize = 0;
119 if ($DIC->filesystem()->storage()->has($filepath)) {
120 $size = $filesize = $DIC->filesystem()->storage()->getSize($filepath, \ILIAS\Data\DataSize::Byte);
121 $filesize = $size->getSize();
122 }
123
124 // get action text
125 $action = $lng->txt("file_version_" . $a_set["action"]); // create, replace, new_version, rollback
126 if ($a_set["action"] == "rollback") {
127 $name = ilObjUser::_lookupName($rollback_user_id);
128 $rollback_username = trim($name["title"] . " " . $name["firstname"] . " " . $name["lastname"]);
129 $action = sprintf($action, $rollback_version, $rollback_username);
130 }
131
132 // get download link
133 $ilCtrl->setParameter($this->parent_obj, "hist_id", $hist_id);
134 $link = $ilCtrl->getLinkTarget($this->parent_obj, "sendfile");
135
136 // build actions
137 include_once("Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
138 $actions = new ilAdvancedSelectionListGUI();
139 $actions->setId($hist_id);
140 $actions->setListTitle($lng->txt("actions"));
141 $actions->addItem($lng->txt("delete"), "", $ilCtrl->getLinkTarget($this->parent_obj, "deleteVersions"));
142 if ($this->current_version != $version) {
143 $actions->addItem($lng->txt("file_rollback"), "", $ilCtrl->getLinkTarget($this->parent_obj, "rollbackVersion"));
144 }
145
146 // reset history parameter
147 $ilCtrl->setParameter($this->parent_obj, "hist_id", "");
148
149 // fill template
150 $this->tpl->setVariable("TXT_VERSION", $version);
151 $this->tpl->setVariable("TXT_DATE", ilDatePresentation::formatDate(new ilDateTime($a_set['date'], IL_CAL_DATETIME)));
152 $this->tpl->setVariable("TXT_UPLOADED_BY", $username);
153 $this->tpl->setVariable("DL_LINK", $link);
154 $this->tpl->setVariable("TXT_FILENAME", $filename);
155 $this->tpl->setVariable("TXT_FILESIZE", ilUtil::formatSize($filesize));
156
157 // columns depending on confirmation
158 if (!$this->confirmDelete) {
159 $this->tpl->setCurrentBlock("version_selection");
160 $this->tpl->setVariable("OBJ_ID", $hist_id);
161 $this->tpl->parseCurrentBlock();
162
163 $this->tpl->setCurrentBlock("version_txt_actions");
164 $this->tpl->setVariable("TXT_ACTION", $action);
165 $this->tpl->parseCurrentBlock();
166
167 $this->tpl->setCurrentBlock("version_actions");
168 $this->tpl->setVariable("ACTIONS", $actions->getHTML());
169 $this->tpl->parseCurrentBlock();
170 } else {
171 $this->tpl->setCurrentBlock("version_id");
172 $this->tpl->setVariable("OBJ_ID", $hist_id);
173 $this->tpl->parseCurrentBlock();
174 }
175 }
176}
$size
Definition: RandomTest.php:84
$filename
Definition: buildRTE.php:89
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.
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
$DIC
Definition: xapitoken.php:46