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