ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_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 
104  function getCustomColumns()
105  {
106  return $this->custom_columns;
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  $f = $c['func'];
137  $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->$f($a_set['type'], $a_set['file']).' ');
138  $this->tpl->parseCurrentBlock();
139  }
140 
141  $file_id = $this->getRowId($a_set);
142  $this->tpl->setVariable('VAL_ID', $file_id);
143 
144  $type = ($this->formats[$a_set['type']] != "")
145  ? $this->formats[$a_set['type']]
146  : $a_set['type'];
147  $this->tpl->setVariable('VAL_TYPE', $type);
148  $this->tpl->setVariable('VAL_FILE', $a_set['file']);
149  $this->tpl->setVariable('VAL_SIZE', ilUtil::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 }
$files
Definition: add-vimline.php:18
__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
Constructor.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addCustomColumn($a_txt, $a_obj, $a_func)
Add custom column.
static _getExportFiles($a_obj_id, $a_export_types="", $a_obj_type="")
Get Export Files for a repository object.
$url
Definition: shib_logout.php:72
const IL_CAL_UNIX
getParentObject()
Get parent object.
addCustomMultiCommand($a_txt, $a_cmd)
Add custom multi command.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
getCustomColumns()
Get custom columns.
addMultiCommand($a_cmd, $a_text)
Add Command button.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
Set cell number formats
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $lng
Definition: privfeed.php:17
setEnableHeader($a_enableheader)
Set Enable Header.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
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.
getExportFiles()
Get export files.