Description of class class.
More...
|
static | getFileDirs ($a_ref_id, $a_file_name, $a_temp_dir) |
| Please note that this method must only be called ONCE in order to detect duplicate entries. More...
|
|
static | recurseFolder ($a_ref_id, $a_folder_name, $a_temp_dir, $a_num_recursions, $a_initiated_by_folder_action) |
|
◆ __construct()
ilCollectFilesJob::__construct |
( |
| ) |
|
◆ getExpectedTimeOfTaskInSeconds()
ilCollectFilesJob::getExpectedTimeOfTaskInSeconds |
( |
| ) |
|
- Returns
- int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user
Implements ILIAS\BackgroundTasks\Task\Job.
Definition at line 210 of file class.ilCollectFilesJob.php.
◆ getFileDirs()
static ilCollectFilesJob::getFileDirs |
( |
|
$a_ref_id, |
|
|
|
$a_file_name, |
|
|
|
$a_temp_dir |
|
) |
| |
|
staticprivate |
Please note that this method must only be called ONCE in order to detect duplicate entries.
DO NOT call this method e.g. in an if condition and then again in its body.
Definition at line 119 of file class.ilCollectFilesJob.php.
References $DIC, and ilUtil\getASCIIFilename().
123 $user = $DIC->user();
124 $ilAccess = $DIC->access();
125 if ($ilAccess->checkAccessOfUser($user->getId(),
"read",
"", $a_ref_id)) {
127 $source_dir = $file->getDirectory($file->getVersion()) .
"/" . $file->getFileName();
128 if (@!is_file($source_dir)) {
129 $source_dir = $file->getDirectory() .
"/" . $file->getFileName();
136 if (isset(self::$targets[$target_dir])) {
137 $target_info = pathinfo($target_dir);
138 $target_dir = $a_temp_dir . $target_info[
"filename"] .
" (" . ++self::$targets[$target_dir] .
")." . $target_info[
"extension"];
140 self::$targets[$target_dir] = 0;
144 "source_dir" => $source_dir,
145 "target_dir" => $target_dir,
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
◆ getInputTypes()
ilCollectFilesJob::getInputTypes |
( |
| ) |
|
◆ getOutputType()
ilCollectFilesJob::getOutputType |
( |
| ) |
|
◆ isStateless()
ilCollectFilesJob::isStateless |
( |
| ) |
|
◆ recurseFolder()
static ilCollectFilesJob::recurseFolder |
( |
|
$a_ref_id, |
|
|
|
$a_folder_name, |
|
|
|
$a_temp_dir, |
|
|
|
$a_num_recursions, |
|
|
|
$a_initiated_by_folder_action |
|
) |
| |
|
staticprivate |
- Parameters
-
- Returns
- array
Definition at line 160 of file class.ilCollectFilesJob.php.
References $DIC, ilObject\_isInTrash(), and ilUtil\getASCIIFilename().
164 $num_recursions = $a_num_recursions + 1;
165 $tree = $DIC->repositoryTree();
166 $ilAccess = $DIC->access();
171 if (($num_recursions <= 1) and ($a_initiated_by_folder_action)) {
172 $temp_dir = $a_temp_dir;
177 $subtree = $tree->getChildsByTypeFilter($a_ref_id, array(
"fold",
"file"));
179 foreach ($subtree as $child) {
180 if (!$ilAccess->checkAccess(
"read",
"", $child[
"ref_id"])) {
186 if ($child[
"type"] ==
"fold") {
187 $files_from_folder = self::recurseFolder($child[
"ref_id"], $child[
'title'], $temp_dir, $num_recursions, $a_initiated_by_folder_action);
188 $files = array_merge($files, $files_from_folder);
190 if (($child[
"type"] ==
"file") and (($dirs = self::getFileDirs($child[
"ref_id"], $child[
'title'], $temp_dir)) !=
false)) {
196 if (empty($subtree)) {
199 "target_dir" => $temp_dir .
'/',
static _isInTrash($a_ref_id)
checks wether object is in trash
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
◆ run()
- Todo:
- use filsystem service
Definition at line 69 of file class.ilCollectFilesJob.php.
References ilObjectFactory\getInstanceByRefId().
71 $this->logger->debug(
'Start collecting files!');
72 $this->logger->dump(
$input);
74 $initiated_by_folder_action =
$input[1]->getValue();
75 $object_ref_ids = $definition->getObjectRefIds();
78 foreach ($object_ref_ids as $object_ref_id) {
80 $object_type = $object->getType();
81 $object_name = $object->getTitle();
82 $object_temp_dir =
"";
84 if ($object_type ==
"fold") {
86 $files_from_folder = self::recurseFolder($object_ref_id, $object_name, $object_temp_dir, $num_recursions, $initiated_by_folder_action);
87 $files = array_merge($files, $files_from_folder);
89 if (($object_type ==
"file") and (($file_dirs = self::getFileDirs($object_ref_id, $object_name, $object_temp_dir)) !=
false)) {
90 $files[] = $file_dirs;
94 $this->logger->debug(
'Collected files:');
95 $this->logger->dump($files);
98 foreach ($files as $file) {
99 $definition->addCopyDefinition($file[
'source_dir'], $file[
'target_dir']);
100 $this->logger->debug(
'Added new copy definition: ' . $file[
'source_dir'] .
' -> ' . $file[
'target_dir']);
103 $is_empty_folder = preg_match_all(
"/\/$/", $file[
'target_dir']);
104 if (!$is_empty_folder) {
108 $definition->setObjectRefIds($object_ref_ids);
109 $definition->setNumFiles($num_files);
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
◆ $logger
ilCollectFilesJob::$logger = null |
|
private |
◆ $targets
ilCollectFilesJob::$targets = [] |
|
staticprivate |
The documentation for this class was generated from the following file: