ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 public function __construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
23 {
24 global $DIC;
25
26 $ilCtrl = $DIC['ilCtrl'];
27 $lng = $DIC['lng'];
28 $ilAccess = $DIC['ilAccess'];
29 $lng = $DIC['lng'];
30
31 $this->obj = $a_exp_obj;
32
33 parent::__construct($a_parent_obj, $a_parent_cmd);
34 $this->setData($this->getExportFiles());
35 $this->setTitle($lng->txt('exp_export_files'));
36
37 $this->initColumns();
38
39 $this->setDefaultOrderField('timestamp');
40 $this->setDefaultOrderDirection('desc');
41
42 $this->setEnableHeader(true);
43 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
44 $this->setRowTemplate('tpl.export_table_row.html', 'Services/Export');
45 //$this->disable('footer');
46 //$this->setEnableTitle(true);
47
48 $this->initMultiCommands();
49 }
50
54 protected function initColumns()
55 {
56 $this->addColumn($this->lng->txt(''), '', '1', true);
57 $this->addColumn($this->lng->txt('type'), 'type');
58 $this->addColumn($this->lng->txt('file'), 'file');
59 $this->addColumn($this->lng->txt('size'), 'size');
60 $this->addColumn($this->lng->txt('date'), 'timestamp');
61 }
62
63 protected function prepareOutput()
64 {
65 // append at last position (after custom columns)
66 $this->addColumn($this->lng->txt('actions'));
67 }
68
72 protected function initMultiCommands()
73 {
74 // $this->addMultiCommand('download', $this->lng->txt('download')); #15097
75 $this->addMultiCommand('confirmDeletion', $this->lng->txt('delete'));
76 }
77
84 public function addCustomColumn($a_txt, $a_obj, $a_func)
85 {
86 $this->addColumn($a_txt);
87 $this->custom_columns[] = array('txt' => $a_txt,
88 'obj' => $a_obj,
89 'func' => $a_func);
90 }
91
98 public function addCustomMultiCommand($a_txt, $a_cmd)
99 {
100 $this->addMultiCommand($a_cmd, $a_txt);
101 }
102
109 public function getCustomColumns()
110 {
112 }
113
117 public function getExportFiles()
118 {
119 $types = array();
120 foreach ($this->parent_obj->getFormats() as $f) {
121 $types[] = $f['key'];
122 $this->formats[$f['key']] = $f['txt'];
123 }
124 include_once('./Services/Export/classes/class.ilExport.php');
126 $this->obj->getId(),
127 $types,
128 $this->obj->getType()
129 );
130 return $files;
131 }
132
136 protected function fillRow($a_set)
137 {
138 global $DIC;
139
140 $ilCtrl = $DIC['ilCtrl'];
141
142 foreach ($this->getCustomColumns() as $c) {
143 $this->tpl->setCurrentBlock('custom');
144 $f = $c['func'];
145 $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->$f($a_set['type'], $a_set['file']) . ' ');
146 $this->tpl->parseCurrentBlock();
147 }
148
149 $file_id = $this->getRowId($a_set);
150 $this->tpl->setVariable('VAL_ID', $file_id);
151
152 $type = ($this->formats[$a_set['type']] != "")
153 ? $this->formats[$a_set['type']]
154 : $a_set['type'];
155 $this->tpl->setVariable('VAL_TYPE', $type);
156 $this->tpl->setVariable('VAL_FILE', $a_set['file']);
157 $this->tpl->setVariable('VAL_SIZE', ilUtil::formatSize($a_set['size']));
158 $this->tpl->setVariable('VAL_DATE', ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX)));
159
160 $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
161
162 $ilCtrl->setParameter($this->getParentObject(), "file", $file_id);
163 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "download");
164 $ilCtrl->setParameter($this->getParentObject(), "file", "");
165 $this->tpl->setVariable('URL_DOWNLOAD', $url);
166 }
167
172 protected function getRowId(array $row)
173 {
174 return $row['type'] . ':' . $row['file'];
175 }
176}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
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
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.
static _getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable 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.
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.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url
$DIC
Definition: xapitoken.php:46