ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once('./Services/Export/classes/class.ilExportGUI.php');
5require_once('./Services/Export/classes/class.ilExport.php');
6require_once('./Services/Export/classes/class.ilExportTableGUI.php');
7
14{
15
16 public function __construct($a_parent_obj, $a_parent_cmd, $a_exp_obj) {
17 parent::__construct($a_parent_obj, $a_parent_cmd, $a_exp_obj);
18
19 $this->addCustomColumn($this->lng->txt('status'), $this, 'parseExportStatus');
20 }
21
22
23 public function getExportFiles()
24 {
25 $types = array();
26 foreach ($this->parent_obj->getFormats() as $f)
27 {
28 $types[] = $f['key'];
29 $this->formats[$f['key']] = $f['txt'];
30 }
31
32 $file = array();
33 foreach($types as $type)
34 {
35 $dir = ilExport::_getExportDirectory($this->obj->getId(), $type, 'dcl');
36
37 // quit if import dir not available
38 if (!is_dir($dir) || !is_writeable($dir)) {
39 continue;
40 }
41
42 // open directory
43 $h_dir = dir($dir);
44
45 // get files and save the in the array
46 while ($entry = $h_dir->read())
47 {
48 if ($entry != "." && $entry != "..")
49 {
50 $ts = substr($entry, 0, strpos($entry, "__"));
51
52 $filename = $entry; //($this->isExportInProgress($entry))? substr($entry, 0, - strlen(self::PROGRESS_IDENTIFIER)) : $entry;
53
54 $file[$entry.$type] = array("type" => $type, "file" => $filename,
55 "size" => ($this->isExportInProgress($entry))? '0' : filesize($dir."/".$entry),
56 "timestamp" => $ts);
57 }
58 }
59
60 // close import directory
61 $h_dir->close();
62 }
63
64 // sort files
65 ksort ($file);
66 reset ($file);
67 return $file;
68
69 return $files;
70 }
71
72 protected function fillRow($a_set)
73 {
74 global $DIC;
75 $ilCtrl = $DIC['ilCtrl'];
76
77 foreach($this->getCustomColumns() as $c)
78 {
79 $this->tpl->setCurrentBlock('custom');
80 $this->tpl->setVariable('VAL_CUSTOM', $c['obj']->{$c['func']}($a_set['type'], $a_set['file']) . ' ');
81 $this->tpl->parseCurrentBlock();
82 }
83
84 $file_id = $this->getRowId($a_set);
85 $this->tpl->setVariable('VAL_ID', $file_id);
86
87 $type = ($this->formats[$a_set['type']] != "")
88 ? $this->formats[$a_set['type']]
89 : $a_set['type'];
90 $this->tpl->setVariable('VAL_TYPE', $type);
91
92 $filename = ($this->isExportInProgress($a_set['file']))? substr($a_set['file'], 0, - strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX)).".xlsx" : $a_set['file'];
93 $this->tpl->setVariable('VAL_FILE', $filename);
94
95 $this->tpl->setVariable('VAL_SIZE', ilUtil::formatSize($a_set['size']));
96 $this->tpl->setVariable('VAL_DATE', ilDatePresentation::formatDate(new ilDateTime($a_set['timestamp'], IL_CAL_UNIX)));
97
98 if(!$this->isExportInProgress($a_set['file'])) {
99 $this->tpl->setVariable('TXT_DOWNLOAD', $this->lng->txt('download'));
100
101 $ilCtrl->setParameter($this->getParentObject(), "file", $file_id);
102 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "download");
103 $ilCtrl->setParameter($this->getParentObject(), "file", "");
104 $this->tpl->setVariable('URL_DOWNLOAD', $url);
105 }
106 }
107
108 public function parseExportStatus($type, $file) {
109 if($type == 'xlsx') {
110 if($this->isExportInProgress($file)) {
111 return $this->lng->txt('dcl_export_started');
112 } else {
113 return $this->lng->txt('dcl_export_finished');
114 }
115 return $file;
116 } else {
117 return $this->lng->txt('dcl_export_finished');
118 }
119 }
120
121 protected function isExportInProgress($file) {
122 $ending = substr($file, - strlen(ilDclContentExporter::IN_PROGRESS_POSTFIX));
124 }
125}
$files
Definition: add-vimline.php:18
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
static formatDate(ilDateTime $date)
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.
global $ilCtrl
Definition: ilias.php:18
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$url
Definition: shib_logout.php:72
global $DIC