ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilExportTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Services/Table/classes/class.ilTable2GUI.php');
5
15{
16 protected $custom_columns = array();
17 protected $formats = array();
18
22 function __construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
23 {
24 global $ilCtrl, $lng, $ilAccess, $lng;
25
26 $this->obj = $a_exp_obj;
27
28 parent::__construct($a_parent_obj, $a_parent_cmd);
29 $this->setData($this->getExportFiles());
30 $this->setTitle($lng->txt('exp_export_files'));
31
32 $this->initColumns();
33
34 $this->setDefaultOrderField('timestamp');
35 $this->setDefaultOrderDirection('desc');
36
37 $this->setEnableHeader(true);
38 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
39 $this->setRowTemplate('tpl.export_table_row.html', 'Services/Export');
40 //$this->disable('footer');
41 //$this->setEnableTitle(true);
42
43 $this->initMultiCommands();
44 }
45
49 protected function initColumns()
50 {
51 $this->addColumn($this->lng->txt(''), '', '1', true);
52 $this->addColumn($this->lng->txt('type'), 'type');
53 $this->addColumn($this->lng->txt('file'), 'file');
54 $this->addColumn($this->lng->txt('size'), 'size');
55 $this->addColumn($this->lng->txt('date'), 'timestamp');
56 }
57
58 protected function prepareOutput()
59 {
60 // append at last position (after custom columns)
61 $this->addColumn($this->lng->txt('actions'));
62 }
63
67 protected function initMultiCommands()
68 {
69 // $this->addMultiCommand('download', $this->lng->txt('download')); #15097
70 $this->addMultiCommand('confirmDeletion', $this->lng->txt('delete'));
71 }
72
79 function addCustomColumn($a_txt, $a_obj, $a_func)
80 {
81 $this->addColumn($a_txt);
82 $this->custom_columns[] = array('txt' => $a_txt,
83 'obj' => $a_obj,
84 'func' => $a_func);
85 }
86
93 function addCustomMultiCommand($a_txt, $a_cmd)
94 {
95 $this->addMultiCommand($a_cmd, $a_txt);
96 }
97
105 {
107 }
108
112 function getExportFiles()
113 {
114 $types = array();
115 foreach ($this->parent_obj->getFormats() as $f)
116 {
117 $types[] = $f['key'];
118 $this->formats[$f['key']] = $f['txt'];
119 }
120 include_once('./Services/Export/classes/class.ilExport.php');
121 $files = ilExport::_getExportFiles($this->obj->getId(),
122 $types, $this->obj->getType());
123 return $files;
124 }
125
129 protected function fillRow($a_set)
130 {
131 global $ilCtrl;
132
133 foreach($this->getCustomColumns() as $c)
134 {
135 $this->tpl->setCurrentBlock('custom');
136 $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->$c['func']($a_set['type'], $a_set['file']).' ');
137 $this->tpl->parseCurrentBlock();
138 }
139
140 $file_id = $this->getRowId($a_set);
141 $this->tpl->setVariable('VAL_ID', $file_id);
142
143 $type = ($this->formats[$a_set['type']] != "")
144 ? $this->formats[$a_set['type']]
145 : $a_set['type'];
146 $this->tpl->setVariable('VAL_TYPE', $type);
147 $this->tpl->setVariable('VAL_FILE', $a_set['file']);
148 include_once("./Services/Utilities/classes/class.ilFormat.php");
149 $this->tpl->setVariable('VAL_SIZE', ilFormat::formatSize($a_set['size']));
150 $this->tpl->setVariable('VAL_DATE', ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX)));
151
152 $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
153
154 $ilCtrl->setParameter($this->getParentObject(), "file", $file_id);
155 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "download");
156 $ilCtrl->setParameter($this->getParentObject(), "file", "");
157 $this->tpl->setVariable('URL_DOWNLOAD', $url);
158 }
159
164 protected function getRowId(array $row)
165 {
166 return $row['type'].':'.$row['file'];
167 }
168}
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
addCustomColumn($a_txt, $a_obj, $a_func)
Add custom column.
__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
Constructor.
addCustomMultiCommand($a_txt, $a_cmd)
Add custom multi command.
getCustomColumns()
Get custom columns.
prepareOutput()
Anything that must be done before HTML is generated.
getExportFiles()
Get export files.
_getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
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.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$url
Definition: shib_logout.php:72