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