ILIAS  release_8 Revision v8.24
class.ilDclExportTableGUI.php
Go to the documentation of this file.
1<?php
2
20{
21 public function __construct(ilDclExportGUI $a_parent_obj, string $a_parent_cmd, ilObject $a_exp_obj)
22 {
23 parent::__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj);
24
25 $this->addCustomColumn($this->lng->txt('status'), $this, 'parseExportStatus');
26 }
27
28 public function getExportFiles(): array
29 {
30 $types = [];
31 foreach ($this->parent_obj->getFormats() as $f) {
32 $types[] = $f['key'];
33 $this->formats[$f['key']] = $f['txt'];
34 }
35
36 $file = [];
37 foreach ($types as $type) {
38 $dir = ilExport::_getExportDirectory($this->obj->getId(), $type, 'dcl');
39
40 // quit if import dir not available
41 if (!is_dir($dir) || !is_writeable($dir)) {
42 continue;
43 }
44
45 // open directory
46 $h_dir = dir($dir);
47
48 // get files and save the in the array
49 while ($entry = $h_dir->read()) {
50 if ($entry != "." && $entry != "..") {
51 $ts = substr($entry, 0, strpos($entry, "__"));
52
53 $filename = $entry; //($this->isExportInProgress($entry))? substr($entry, 0, - strlen(self::PROGRESS_IDENTIFIER)) : $entry;
54
55 $file[$entry . $type] = [
56 "type" => $type,
57 "file" => $filename,
58 "size" => ($this->isExportInProgress($entry)) ? '0' : filesize($dir . "/" . $entry),
59 "timestamp" => $ts,
60 ];
61 }
62 }
63
64 // close import directory
65 $h_dir->close();
66 }
67
68 // sort files
69 ksort($file);
70
71 return $file;
72 }
73
74 protected function fillRow(array $a_set): void
75 {
76 foreach ($this->getCustomColumns() as $c) {
77 $this->tpl->setCurrentBlock('custom');
78 $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->{$c['func']}($a_set['type'], $a_set['file']) . ' ');
79 $this->tpl->parseCurrentBlock();
80 }
81
82 $file_id = $this->getRowId($a_set);
83 $this->tpl->setVariable('VAL_ID', $file_id);
84
85 $type = ($this->formats[$a_set['type']] != "")
86 ? $this->formats[$a_set['type']]
87 : $a_set['type'];
88 $this->tpl->setVariable('VAL_TYPE', $type);
89
90 $filename = ($this->isExportInProgress($a_set['file'])) ? substr(
91 $a_set['file'],
92 0,
94 ) . ".xlsx" : $a_set['file'];
95 $this->tpl->setVariable('VAL_FILE', $filename);
96
97 $this->tpl->setVariable('VAL_SIZE', ilUtil::formatSize($a_set['size']));
98 $this->tpl->setVariable(
99 'VAL_DATE',
100 ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX))
101 );
102
103 if (!$this->isExportInProgress($a_set['file'])) {
104 $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
105
106 $this->ctrl->setParameter($this->getParentObject(), "file", $file_id);
107 $url = $this->ctrl->getLinkTarget($this->getParentObject(), "download");
108 $this->ctrl->setParameter($this->getParentObject(), "file", "");
109 $this->tpl->setVariable('URL_DOWNLOAD', $url);
110 }
111 }
112
113 public function parseExportStatus(string $type, string $file): string
114 {
115 if ($type == 'xlsx') {
116 if ($this->isExportInProgress($file)) {
117 return $this->lng->txt('dcl_export_started');
118 } else {
119 return $this->lng->txt('dcl_export_finished');
120 }
121 } else {
122 return $this->lng->txt('dcl_export_finished');
123 }
124 }
125
126 protected function isExportInProgress(string $file): string
127 {
128 $ending = substr($file, -strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX));
129
131 }
132}
$filename
Definition: buildRTE.php:78
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseExportStatus(string $type, string $file)
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(ilDclExportGUI $a_parent_obj, string $a_parent_cmd, ilObject $a_exp_obj)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCustomColumn(string $a_txt, object $a_obj, string $a_func)
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatSize(int $size, string $a_mode='short', ?ilLanguage $a_lng=null)
Returns the specified file size value in a human friendly form.
$c
Definition: cli.php:38
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url