ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdvancedMDRecordImportFiles.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
26{
27 public const IMPORT_NAME = 'ilias_adv_md_record';
28
29 private string $import_dir = '';
30
31 public function __construct()
32 {
33 $this->import_dir = ilFileUtils::getDataDir() . '/ilAdvancedMetaData/import';
34 $this->init();
35 }
36
37 public function getImportDirectory(): string
38 {
39 return $this->import_dir;
40 }
41
47 public function getImportFileByCreationDate(int $a_unix_time): string
48 {
49 $unix_time = $a_unix_time;
50 return $this->getImportDirectory() . '/' . self::IMPORT_NAME . '_' . $unix_time . '.xml';
51 }
52
57 public function deleteFileByCreationDate(int $a_unix_time): bool
58 {
59 $unix_time = $a_unix_time;
60 return unlink($this->getImportDirectory() . '/' . self::IMPORT_NAME . '_' . $unix_time . '.xml');
61 }
62
69 public function moveUploadedFile(string $a_temp_name): int
70 {
71 $creation_time = time();
72 $file_name = $this->getImportDirectory() . '/' . self::IMPORT_NAME . '_' . $creation_time . '.xml';
73
74 if (!ilFileUtils::moveUploadedFile($a_temp_name, '', $file_name, false)) {
75 return 0;
76 }
77 return $creation_time;
78 }
79
83 private function init(): void
84 {
85 if (!is_dir($this->import_dir)) {
86 ilFileUtils::makeDirParents($this->import_dir);
87 }
88 }
89}
getImportFileByCreationDate(int $a_unix_time)
Get import file by creation date.
init()
init function: create import directory, delete old files
moveUploadedFile(string $a_temp_name)
move uploaded files @access public
deleteFileByCreationDate(int $a_unix_time)
Delete a file.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getDataDir()
get data directory (outside webspace)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file