ILIAS  release_7 Revision v7.30-3-g800a261c036
ilExportImportDirectory Class Reference

Import directory interface. 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 ()
 
 getAbsolutePath ()
 
 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
 $storage
 
 $logger
 

Detailed Description

Import directory interface.

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

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

Member Function Documentation

◆ getAbsolutePathForHash()

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

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

96 : string
97 {
98 foreach ($this->getFilesFor($user_id, $type) as $hash => $file) {
99 if (strcmp($hash, $post_hash) === 0) {
100 $file_path = base64_decode($hash);
101 return ilUtil::getDataDir() . '/' . base64_decode($hash);
102 }
103 }
104 return '';
105 }
getFilesFor(int $user_id, string $type)
static getDataDir()
get data directory (outside webspace)
$type

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

+ Here is the call graph for this function:

◆ getFilesFor()

ilExportImportDirectory::getFilesFor ( int  $user_id,
string  $type 
)
Parameters
int$user_id
string$type
Returns
array

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

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

Reimplemented from ilImportDirectory.

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

20 : string
21 {
22 return self::PATH_PREFIX;
23 }

References PATH_PREFIX.

◆ hasFilesFor()

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

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

29 : bool
30 {
31 return (bool) count($this->getFilesFor($user_id, $type));
32 }

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.

Parameters
string$type
Returns
bool

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

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

References $filename, $result, 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 15 of file class.ilExportImportDirectory.php.

Referenced by getPathPrefix().


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