ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclExportTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 {
11  public function __construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
12  {
13  parent::__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj);
14 
15  $this->addCustomColumn($this->lng->txt('status'), $this, 'parseExportStatus');
16  }
17 
18 
19  public function getExportFiles()
20  {
21  $types = array();
22  foreach ($this->parent_obj->getFormats() as $f) {
23  $types[] = $f['key'];
24  $this->formats[$f['key']] = $f['txt'];
25  }
26 
27  $file = array();
28  foreach ($types as $type) {
29  $dir = ilExport::_getExportDirectory($this->obj->getId(), $type, 'dcl');
30 
31  // quit if import dir not available
32  if (!is_dir($dir) || !is_writeable($dir)) {
33  continue;
34  }
35 
36  // open directory
37  $h_dir = dir($dir);
38 
39  // get files and save the in the array
40  while ($entry = $h_dir->read()) {
41  if ($entry != "." && $entry != "..") {
42  $ts = substr($entry, 0, strpos($entry, "__"));
43 
44  $filename = $entry; //($this->isExportInProgress($entry))? substr($entry, 0, - strlen(self::PROGRESS_IDENTIFIER)) : $entry;
45 
46  $file[$entry . $type] = array("type" => $type, "file" => $filename,
47  "size" => ($this->isExportInProgress($entry)) ? '0' : filesize($dir . "/" . $entry),
48  "timestamp" => $ts);
49  }
50  }
51 
52  // close import directory
53  $h_dir->close();
54  }
55 
56  // sort files
57  ksort($file);
58  reset($file);
59 
60  return $file;
61 
62  return $files;
63  }
64 
65 
66  protected function fillRow($a_set)
67  {
68  global $DIC;
69  $ilCtrl = $DIC['ilCtrl'];
70 
71  foreach ($this->getCustomColumns() as $c) {
72  $this->tpl->setCurrentBlock('custom');
73  $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->{$c['func']}($a_set['type'], $a_set['file']) . ' ');
74  $this->tpl->parseCurrentBlock();
75  }
76 
77  $file_id = $this->getRowId($a_set);
78  $this->tpl->setVariable('VAL_ID', $file_id);
79 
80  $type = ($this->formats[$a_set['type']] != "")
81  ? $this->formats[$a_set['type']]
82  : $a_set['type'];
83  $this->tpl->setVariable('VAL_TYPE', $type);
84 
85  $filename = ($this->isExportInProgress($a_set['file'])) ? substr($a_set['file'], 0, -strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX)) . ".xlsx" : $a_set['file'];
86  $this->tpl->setVariable('VAL_FILE', $filename);
87 
88  $this->tpl->setVariable('VAL_SIZE', ilUtil::formatSize($a_set['size']));
89  $this->tpl->setVariable('VAL_DATE', ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX)));
90 
91  if (!$this->isExportInProgress($a_set['file'])) {
92  $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
93 
94  $ilCtrl->setParameter($this->getParentObject(), "file", $file_id);
95  $url = $ilCtrl->getLinkTarget($this->getParentObject(), "download");
96  $ilCtrl->setParameter($this->getParentObject(), "file", "");
97  $this->tpl->setVariable('URL_DOWNLOAD', $url);
98  }
99  }
100 
101 
102  public function parseExportStatus($type, $file)
103  {
104  if ($type == 'xlsx') {
105  if ($this->isExportInProgress($file)) {
106  return $this->lng->txt('dcl_export_started');
107  } else {
108  return $this->lng->txt('dcl_export_finished');
109  }
110 
111  return $file;
112  } else {
113  return $this->lng->txt('dcl_export_finished');
114  }
115  }
116 
117 
118  protected function isExportInProgress($file)
119  {
120  $ending = substr($file, -strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX));
121 
122  return ($ending == ilDclContentExporter::IN_PROGRESS_POSTFIX);
123  }
124 }
$files
Definition: metarefresh.php:49
$type
global $DIC
Definition: saml.php:7
addCustomColumn($a_txt, $a_obj, $a_func)
Add custom column.
__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
global $ilCtrl
Definition: ilias.php:18
getCustomColumns()
Get custom columns.
Date and time handling
Export User Interface Class.
$filename
Definition: buildRTE.php:89
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
$url
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.