ILIAS  release_8 Revision v8.24
ilExportImportDirectory Class Reference

Import directory. More...

+ Inheritance diagram for ilExportImportDirectory:
+ Collaboration diagram for ilExportImportDirectory:

Public Member Functions

 hasFilesFor (int $user_id, string $type)
 
 getFilesFor (int $user_id, string $type)
 
 getAbsolutePathForHash (int $user_id, string $type, string $post_hash)
 
- Public Member Functions inherited from ilImportDirectory
 __construct (Filesystem $storage, ilLogger $logger)
 
 getRelativePath ()
 
 exists ()
 @inheritDoc More...
 
 getAbsolutePath ()
 @inheritDoc More...
 
 exists ()
 
 getAbsolutePath ()
 

Protected Member Functions

 getPathPrefix ()
 
 matchesType (string $type, string $filename)
 Check if filename matches a given type. More...
 
 getPathPrefix ()
 

Private Attributes

const PATH_PREFIX = 'export'
 

Additional Inherited Members

- Protected Attributes inherited from ilImportDirectory
Filesystem $storage
 
ilLogger $logger
 

Detailed Description

Import directory.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 28 of file class.ilExportImportDirectory.php.

Member Function Documentation

◆ getAbsolutePathForHash()

ilExportImportDirectory::getAbsolutePathForHash ( int  $user_id,
string  $type,
string  $post_hash 
)

Definition at line 91 of file class.ilExportImportDirectory.php.

91 : string
92 {
93 foreach ($this->getFilesFor($user_id, $type) as $hash => $file) {
94 if (strcmp($hash, $post_hash) === 0) {
95 $file_path = base64_decode($hash);
96 return ilFileUtils::getDataDir() . '/' . base64_decode($hash);
97 }
98 }
99 return '';
100 }
getFilesFor(int $user_id, string $type)
static getDataDir()
get data directory (outside webspace)
$type

References $type, ilFileUtils\getDataDir(), and getFilesFor().

+ Here is the call graph for this function:

◆ getFilesFor()

ilExportImportDirectory::getFilesFor ( int  $user_id,
string  $type 
)

Definition at line 42 of file class.ilExportImportDirectory.php.

42 : array
43 {
44 if (!$this->exists()) {
45 return [];
46 }
47 $finder = $this->storage->finder()
48 ->in([$this->getRelativePath()])
49 ->files()
50 ->depth('< 1')
51 ->sortByName();
52 $files = [];
53 foreach ($finder as $file) {
54 $basename = basename($file->getPath());
55 if ($this->matchesType($type, $basename)) {
56 $files[base64_encode($file->getPath())] = $basename;
57 }
58 }
59 if ($this->storage->hasDir($this->getRelativePath() . '/' . $user_id)) {
60 $finder = $this->storage->finder()->in([$this->getRelativePath() . '/' . $user_id])
61 ->depth('< 1')
62 ->files()
63 ->sortByName();
64 foreach ($finder as $file) {
65 $basename = basename($file->getPath());
66 if ($this->matchesType($type, $basename)) {
67 $files[base64_encode($file->getPath())] = $basename;
68 }
69 }
70 }
71 asort($files);
72 return $files;
73 }
matchesType(string $type, string $filename)
Check if filename matches a given type.

References ilImportDirectory\exists(), ilImportDirectory\getRelativePath(), and matchesType().

Referenced by getAbsolutePathForHash(), and hasFilesFor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPathPrefix()

ilExportImportDirectory::getPathPrefix ( )
protected

Reimplemented from ilImportDirectory.

Definition at line 32 of file class.ilExportImportDirectory.php.

32 : string
33 {
34 return self::PATH_PREFIX;
35 }

References PATH_PREFIX.

◆ hasFilesFor()

ilExportImportDirectory::hasFilesFor ( int  $user_id,
string  $type 
)

Definition at line 37 of file class.ilExportImportDirectory.php.

37 : bool
38 {
39 return (bool) count($this->getFilesFor($user_id, $type));
40 }

References $type, and getFilesFor().

+ Here is the call graph for this function:

◆ matchesType()

ilExportImportDirectory::matchesType ( string  $type,
string  $filename 
)
protected

Check if filename matches a given type.

Definition at line 78 of file class.ilExportImportDirectory.php.

78 : bool
79 {
80 $matches = [];
81 $result = preg_match('/[0-9]{10}__[0-9]{1,6}__([a-z]{1,4})_[0-9]{2,9}.zip/', $filename, $matches);
82 if (!$result) {
83 return false;
84 }
85 if (isset($matches[1]) && $matches[1] == $type) {
86 return true;
87 }
88 return false;
89 }
$filename
Definition: buildRTE.php:78

References $filename, and $type.

Referenced by getFilesFor().

+ Here is the caller graph for this function:

Field Documentation

◆ PATH_PREFIX

const ilExportImportDirectory::PATH_PREFIX = 'export'
private

Definition at line 30 of file class.ilExportImportDirectory.php.

Referenced by getPathPrefix().


The documentation for this class was generated from the following file: