45 public function __construct(
int $ref_id, ?
int $table_id, array $filter = [])
48 $this->main_tpl = $DIC->ui()->mainTemplate();
56 $this->tables = (
$table_id) ? [$this->dcl->getTableById($table_id)] : $this->dcl->getTables();
68 $dangerous_filename_characters = [
" ",
'"',
"'",
"&",
"/",
"\\",
"?",
"#",
"`"];
70 return str_replace($dangerous_filename_characters,
"_", iconv(
"utf-8",
"ascii//TRANSLIT", $filename));
92 if ($field->getExportable()) {
105 foreach ($table->
getFields() as $field) {
106 if ($field->getExportable()) {
107 $field->fillHeaderExcel($worksheet, $row, $col);
124 public function export(
string $format = self::EXPORT_EXCEL,
string $filepath = null,
bool $send =
false)
126 if (count($this->tables) == 0) {
130 if (empty($filepath)) {
134 $basename = (isset($this->table_id)) ? $this->tables[0]->getTitle() :
'complete';
135 $filename = time() .
'__' . $basename .
"_" . date(
"Y-m-d_H-i");
139 $filename = pathinfo($filepath, PATHINFO_FILENAME);
142 $in_progress_file = $filepath . self::IN_PROGRESS_POSTFIX;
143 file_put_contents($in_progress_file,
"");
145 $data_available =
false;
146 $fields_available =
false;
147 if (
$format == self::EXPORT_EXCEL) {
149 foreach ($this->tables as $table) {
152 $list = $table->getPartialRecords($this->dcl->getRefId(),
'id',
'asc', null, 0,
$this->filter);
153 $data_available = $data_available || ($list[
'total'] > 0);
154 $fields_available = $fields_available || (count($table->getExportableFields()) > 0);
155 if ($list[
'total'] > 0 && count($table->getExportableFields()) > 0) {
157 $title = substr($table->getTitle(), 0, 31);
158 $adapter->addSheet($title);
170 foreach ($list[
'records'] as $set) {
175 $data_available =
true;
180 if (file_exists($in_progress_file)) {
181 unlink($in_progress_file);
184 if (!$data_available) {
185 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'dcl_no_export_content_available'));
190 if (!$fields_available) {
192 $this->main_tpl->setOnScreenMessage(
'info', sprintf(
193 $this->
lng->txt(
'dcl_no_export_fields_available'),
194 $ilCtrl->getLinkTargetByClass(
195 [
'ilDclTableListGUI',
'ilDclFieldListGUI'],
205 $adapter->writeToFile($filepath);
218 $ilLog = $DIC[
'ilLog'];
220 $method = self::SOAP_FUNCTION_NAME;
222 $soap_params = [$this->dcl->getRefId()];
223 array_push($soap_params, $this->table_id,
$format, $filepath);
230 $soap_client->setResponseTimeout(5);
231 $soap_client->enableWSDL(
true);
233 $ilLog->write(__METHOD__ .
': Trying to call Soap client...');
235 array_unshift($soap_params, $new_session_id .
'::' .
$client_id);
237 if ($soap_client->init()) {
238 $ilLog->info(
'Calling soap ' . $method .
' method with params ' . print_r($soap_params,
true));
239 $res = $soap_client->call($method, $soap_params);
241 $ilLog->warning(
'SOAP clone call failed. Calling clone method manually');
242 if (method_exists(
'ilSoapFunctions', $method)) {
243 $res = ilSoapFunctions::$method(
244 $new_session_id .
'::' . $client_id,
245 $this->dcl->getRefId(),
251 throw new ilDclException(
"SOAP call " . $method .
" does not exists!");
static _duplicate(string $a_session_id)
Duplicate session.
getExportContentPath(string $format)
Return export path.
ilGlobalTemplateInterface $main_tpl
getFields()
Returns all fields of this table including the standard fields.
loadLanguageModule(string $a_module)
Load language module.
array $filter
Array with filters.
export(string $format=self::EXPORT_EXCEL, string $filepath=null, bool $send=false)
Creates an export of a specific data collection table.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object.
fillMetaExcel(ilDclTable $table, ilExcel $worksheet, int $row)
Fill Excel meta-data.
__construct(int $ref_id, ?int $table_id, array $filter=[])
static resetCache()
Resets all the cache fields.
int $table_id
Table-Id for export.
fillRowExcel(ilDclTable $table, ilExcel $worksheet, ilDclBaseRecordModel $record, int $row)
Fill a excel row.
fillHeaderExcel(ilDclTable $table, ilExcel $worksheet, int $row)
Fill Excel header.
sanitizeFilename(string $filename)
Sanitize the given filename The ilUtil::_sanitizeFilename() does not clean enough.
fillRecordFieldExcelExport(ilExcel $worksheet, int &$row, int &$col, $field_id)
int $ref_id
Ref-ID of DataCollection.
exportAsync(string $format=self::EXPORT_EXCEL, string $filepath=null)
Start Export async.
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...
const IN_PROGRESS_POSTFIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...