ILIAS  release_7 Revision v7.30-3-g800a261c036
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(
47 "type" => $type,
48 "file" => $filename,
49 "size" => ($this->isExportInProgress($entry)) ? '0' : filesize($dir . "/" . $entry),
50 "timestamp" => $ts,
51 );
52 }
53 }
54
55 // close import directory
56 $h_dir->close();
57 }
58
59 // sort files
60 ksort($file);
61 reset($file);
62
63 return $file;
64
65 return $files;
66 }
67
68
69 protected function fillRow($a_set)
70 {
71 global $DIC;
72 $ilCtrl = $DIC['ilCtrl'];
73
74 foreach ($this->getCustomColumns() as $c) {
75 $this->tpl->setCurrentBlock('custom');
76 $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->{$c['func']}($a_set['type'], $a_set['file']) . ' ');
77 $this->tpl->parseCurrentBlock();
78 }
79
80 $file_id = $this->getRowId($a_set);
81 $this->tpl->setVariable('VAL_ID', $file_id);
82
83 $type = ($this->formats[$a_set['type']] != "")
84 ? $this->formats[$a_set['type']]
85 : $a_set['type'];
86 $this->tpl->setVariable('VAL_TYPE', $type);
87
88 $filename = ($this->isExportInProgress($a_set['file'])) ? substr($a_set['file'], 0, -strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX)) . ".xlsx" : $a_set['file'];
89 $this->tpl->setVariable('VAL_FILE', $filename);
90
91 $this->tpl->setVariable('VAL_SIZE', ilUtil::formatSize($a_set['size']));
92 $this->tpl->setVariable('VAL_DATE', ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX)));
93
94 if (!$this->isExportInProgress($a_set['file'])) {
95 $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
96
97 $ilCtrl->setParameter($this->getParentObject(), "file", $file_id);
98 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "download");
99 $ilCtrl->setParameter($this->getParentObject(), "file", "");
100 $this->tpl->setVariable('URL_DOWNLOAD', $url);
101 }
102 }
103
104
105 public function parseExportStatus($type, $file)
106 {
107 if ($type == 'xlsx') {
108 if ($this->isExportInProgress($file)) {
109 return $this->lng->txt('dcl_export_started');
110 } else {
111 return $this->lng->txt('dcl_export_finished');
112 }
113
114 return $file;
115 } else {
116 return $this->lng->txt('dcl_export_finished');
117 }
118 }
119
120
121 protected function isExportInProgress($file)
122 {
123 $ending = substr($file, -strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX));
124
126 }
127}
$filename
Definition: buildRTE.php:89
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, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Export User Interface Class.
getExportFiles()
Get export files.
__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj)
Constructor.
addCustomColumn($a_txt, $a_obj, $a_func)
Add custom column.
getCustomColumns()
Get custom columns.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
getParentObject()
Get parent object.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
$c
Definition: cli.php:37
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url