ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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 public 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 public function addCustomMultiCommand($a_txt, $a_cmd)
94 {
95 $this->addMultiCommand($a_cmd, $a_txt);
96 }
97
104 public function getCustomColumns()
105 {
107 }
108
112 public function getExportFiles()
113 {
114 $types = array();
115 foreach ($this->parent_obj->getFormats() as $f) {
116 $types[] = $f['key'];
117 $this->formats[$f['key']] = $f['txt'];
118 }
119 include_once('./Services/Export/classes/class.ilExport.php');
121 $this->obj->getId(),
122 $types,
123 $this->obj->getType()
124 );
125 return $files;
126 }
127
131 protected function fillRow($a_set)
132 {
133 global $ilCtrl;
134
135 foreach ($this->getCustomColumns() as $c) {
136 $this->tpl->setCurrentBlock('custom');
137 $f = $c['func'];
138 $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->$f($a_set['type'], $a_set['file']) . ' ');
139 $this->tpl->parseCurrentBlock();
140 }
141
142 $file_id = $this->getRowId($a_set);
143 $this->tpl->setVariable('VAL_ID', $file_id);
144
145 $type = ($this->formats[$a_set['type']] != "")
146 ? $this->formats[$a_set['type']]
147 : $a_set['type'];
148 $this->tpl->setVariable('VAL_TYPE', $type);
149 $this->tpl->setVariable('VAL_FILE', $a_set['file']);
150 $this->tpl->setVariable('VAL_SIZE', ilUtil::formatSize($a_set['size']));
151 $this->tpl->setVariable('VAL_DATE', ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX)));
152
153 $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
154
155 $ilCtrl->setParameter($this->getParentObject(), "file", $file_id);
156 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "download");
157 $ilCtrl->setParameter($this->getParentObject(), "file", "");
158 $this->tpl->setVariable('URL_DOWNLOAD', $url);
159 }
160
165 protected function getRowId(array $row)
166 {
167 return $row['type'] . ':' . $row['file'];
168 }
169}
$files
Definition: add-vimline.php:18
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)
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
$type
$url