Description of class class.
More...
|
| __construct () |
| Construct. More...
|
|
| getInputTypes () |
|
| getOutputType () |
|
| isStateless () |
|
| run (array $input, Observer $observer) |
|
| 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
More...
|
|
| getInput () |
| - Returns
- array returns the input array
More...
|
|
| setInput (array $values) |
|
| getOutput () |
|
| getInput () |
|
| getType () |
|
| unfoldTask () |
| Unfold the task. More...
|
|
| getRemoveOption () |
| - Returns
- Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
- See also
- self::getAbortOption();
More...
|
|
| getAbortOption () |
| - Returns
- Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
|
|
|
| getFileDirs ($a_ref_id, string $a_file_name, string $a_temp_dir) |
|
| recurseFolder ($a_ref_id, string $a_folder_name, string $a_temp_dir, int|float $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 238 of file class.ilCollectFilesJob.php.
◆ getFileDirs()
ilCollectFilesJob::getFileDirs |
( |
|
$a_ref_id, |
|
|
string |
$a_file_name, |
|
|
string |
$a_temp_dir |
|
) |
| |
|
private |
- Returns
- bool|array<string, string> 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 143 of file class.ilCollectFilesJob.php.
References $DIC, $filename, and ensureSuffix().
Referenced by recurseFolder(), and run().
147 $user = $DIC->user();
148 $ilAccess = $DIC->access();
149 if ($ilAccess->checkAccessOfUser($user->getId(),
"read",
"", $a_ref_id)) {
151 $source_dir = $file->getFile();
153 if (@!is_file($source_dir)) {
157 $filname_with_suffix = $this->
ensureSuffix($a_file_name, $file->getFileExtension());
159 $target_dir = $a_temp_dir .
'/' . $filname_with_suffix;
164 if (isset(self::$targets[$target_dir])) {
165 $target_info = pathinfo($target_dir);
167 $extension = isset($target_info[
"extension"]) ?
"." . $target_info[
"extension"] :
"";
168 $target_dir = $a_temp_dir .
$filename .
" (" . ++self::$targets[$target_dir] .
")" . $extension;
170 self::$targets[$target_dir] = 0;
174 "source_dir" => $source_dir,
175 "target_dir" => $target_dir,
ensureSuffix(string $title, ?string $suffix=null)
◆ getInputTypes()
ilCollectFilesJob::getInputTypes |
( |
| ) |
|
◆ getOutputType()
ilCollectFilesJob::getOutputType |
( |
| ) |
|
◆ isStateless()
ilCollectFilesJob::isStateless |
( |
| ) |
|
◆ recurseFolder()
ilCollectFilesJob::recurseFolder |
( |
|
$a_ref_id, |
|
|
string |
$a_folder_name, |
|
|
string |
$a_temp_dir, |
|
|
int|float |
$a_num_recursions, |
|
|
|
$a_initiated_by_folder_action |
|
) |
| |
|
private |
- Parameters
-
- Returns
- mixed[]
Definition at line 190 of file class.ilCollectFilesJob.php.
References $DIC, ilObject\_isInTrash(), ilFileUtils\getASCIIFilename(), and getFileDirs().
Referenced by run().
194 $num_recursions = $a_num_recursions + 1;
195 $tree = $DIC->repositoryTree();
196 $ilAccess = $DIC->access();
201 if ($num_recursions <= 1 && $a_initiated_by_folder_action) {
202 $temp_dir = $a_temp_dir;
207 $subtree = $tree->getChildsByTypeFilter($a_ref_id, [
"fold",
"file"]);
209 foreach ($subtree as $child) {
210 if (!$ilAccess->checkAccess(
"read",
"", $child[
"ref_id"])) {
216 if ($child[
"type"] ==
"fold") {
217 $files_from_folder = $this->
recurseFolder($child[
"ref_id"], $child[
'title'], $temp_dir, $num_recursions, $a_initiated_by_folder_action);
218 $files = array_merge($files, $files_from_folder);
219 } elseif (($child[
"type"] ===
"file") && (($dirs = $this->
getFileDirs($child[
"ref_id"], $child[
'title'], $temp_dir)) !==
false)) {
224 if (empty($subtree)) {
227 "target_dir" => $temp_dir .
'/',
recurseFolder($a_ref_id, string $a_folder_name, string $a_temp_dir, int|float $a_num_recursions, $a_initiated_by_folder_action)
static getASCIIFilename(string $a_filename)
static _isInTrash(int $ref_id)
getFileDirs($a_ref_id, string $a_file_name, string $a_temp_dir)
◆ run()
ilCollectFilesJob::run |
( |
array |
$input, |
|
|
Observer |
$observer |
|
) |
| |
- Todo:
- use filsystem service
Implements ILIAS\BackgroundTasks\Task\Job.
Definition at line 89 of file class.ilCollectFilesJob.php.
References getFileDirs(), ilObjectFactory\getInstanceByRefId(), ILIAS\Repository\logger(), and recurseFolder().
91 $this->
logger->debug(
'Start collecting files!');
94 $initiated_by_folder_action =
$input[1]->getValue();
95 $object_ref_ids = $definition->getObjectRefIds();
98 foreach ($object_ref_ids as $object_ref_id) {
100 $object_type = $object->getType();
101 $object_name = $object->getTitle();
102 $object_temp_dir =
"";
104 if ($object_type ===
"fold" || $object_type ===
"crs") {
106 $files_from_folder = $this->
recurseFolder($object_ref_id, $object_name, $object_temp_dir, $num_recursions, $initiated_by_folder_action);
107 $files = array_merge($files, $files_from_folder);
108 } elseif (($object_type ===
"file") && (($file_dirs = $this->
getFileDirs(
113 $files[] = $file_dirs;
116 $this->
logger->debug(
'Collected files:');
117 $this->
logger->dump($files);
120 foreach ($files as $file) {
121 $definition->addCopyDefinition($file[
'source_dir'], $file[
'target_dir']);
122 $this->
logger->debug(
'Added new copy definition: ' . $file[
'source_dir'] .
' -> ' . $file[
'target_dir']);
125 $is_empty_folder = preg_match_all(
"/\/$/", (
string) $file[
'target_dir']);
126 if (!$is_empty_folder) {
130 $definition->setObjectRefIds($object_ref_ids);
131 $definition->setNumFiles($num_files);
recurseFolder($a_ref_id, string $a_folder_name, string $a_temp_dir, int|float $a_num_recursions, $a_initiated_by_folder_action)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
getFileDirs($a_ref_id, string $a_file_name, string $a_temp_dir)
◆ $logger
◆ $targets
array ilCollectFilesJob::$targets = [] |
|
staticprivate |
The documentation for this class was generated from the following file: