ILIAS
release_7 Revision v7.30-3-g800a261c036
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
l
m
p
r
s
t
w
+
Functions
_
a
b
c
f
g
h
i
r
s
t
w
+
Variables
$
c
d
e
f
g
h
j
l
m
p
s
t
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Files
File List
+
Globals
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Modules
Pages
class.ilFileObjectToStorageDirectory.php
Go to the documentation of this file.
1
<?php
2
7
class
ilFileObjectToStorageDirectory
8
{
12
protected
$object_id
;
16
protected
$path
;
20
protected
$versions
= [];
21
27
public
function
__construct
(
int
$object_id
,
string
$path
)
28
{
29
$this->object_id =
$object_id
;
30
$this->path =
$path
;
31
$this->
initVersions
();
32
}
33
34
private
function
initVersions
() : void
35
{
36
$history_data = $this->
getHistoryData
();
37
try
{
38
$g =
new
RegexIterator(
39
new
RecursiveIteratorIterator
(
40
new
RecursiveDirectoryIterator(
41
$this->path,
42
FilesystemIterator::KEY_AS_PATHNAME
43
|FilesystemIterator::CURRENT_AS_FILEINFO
44
|FilesystemIterator::SKIP_DOTS
45
),
46
RecursiveIteratorIterator::LEAVES_ONLY
47
),
48
'/.*\/file_[\d]*\/([\d]*)\/(.*)/'
,
49
RegexIterator::GET_MATCH
50
);
51
}
catch
(
Throwable
$t) {
52
// there was an error reading the directory, there will be no versions
53
$g = [];
54
}
55
56
57
$this->versions = [];
58
59
foreach
($g as $item) {
60
$version = (int) $item[1];
61
$title = $history_data[$version][
'filename'
] ?? $item[2];
62
$action = $history_data[$version][
'action'
] ??
'create'
;
63
$owner = $history_data[$version][
'owner_id'
] ?? 13;
64
$creation_date_timestamp = strtotime($history_data[$version][
'date'
] ??
'0'
);
65
if
($creation_date_timestamp ===
false
) {
66
$creation_date_timestamp = 0;
67
}
68
$this->versions[$version] =
new
ilFileObjectToStorageVersion
(
69
$version,
70
$item[0],
71
$title,
72
$title,
73
$action,
74
$creation_date_timestamp,
75
$owner
76
);
77
}
78
ksort($this->versions);
79
}
80
84
private
function
getHistoryData
() : array
85
{
86
$info =
ilHistory::_getEntriesForObject
($this->object_id,
'file'
);
87
$history_data = [];
88
foreach
($info as
$i
) {
89
$parsed_info =
ilObjFileImplementationLegacy::parseInfoParams
($i);
90
$version = (int) $parsed_info[
'version'
];
91
$history_data[$version] = $parsed_info;
92
$history_data[$version][
'owner_id'
] = (int) $i[
'user_id'
];
93
$history_data[$version][
'date'
] = (string) $i[
'date'
];
94
$history_data[$version][
'action'
] = (string) $i[
'action'
];
95
}
96
97
uasort($history_data,
static
function
($v1, $v2) {
98
return
(
int
) $v2[
"version"
] - (
int
) $v1[
"version"
];
99
});
100
return
$history_data;
101
}
102
106
public
function
getVersions
() :
Generator
107
{
108
yield from
$this->versions
;
109
}
110
114
public
function
getObjectId
() : int
115
{
116
return
$this->object_id
;
117
}
118
119
public
function
tearDown
() : void
120
{
121
if
(is_writable($this->path)) {
122
touch(rtrim($this->path,
"/"
) .
"/"
.
ilFileObjectToStorageMigrationHelper::MIGRATED
);
123
}
124
}
125
}
ilFileObjectToStorageDirectory\$path
$path
Definition:
class.ilFileObjectToStorageDirectory.php:16
ilFileObjectToStorageDirectory
Class ilFileObjectToStorageDirectory.
Definition:
class.ilFileObjectToStorageDirectory.php:7
ilHistory\_getEntriesForObject
static _getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
Definition:
class.ilHistory.php:128
ilFileObjectToStorageDirectory\$object_id
$object_id
Definition:
class.ilFileObjectToStorageDirectory.php:12
ilFileObjectToStorageDirectory\initVersions
initVersions()
Definition:
class.ilFileObjectToStorageDirectory.php:34
ilFileObjectToStorageDirectory\$versions
$versions
Definition:
class.ilFileObjectToStorageDirectory.php:20
RecursiveIteratorIterator
ilFileObjectToStorageDirectory\__construct
__construct(int $object_id, string $path)
ilFileObjectToStorageDirectory constructor.
Definition:
class.ilFileObjectToStorageDirectory.php:27
Generator
ilFileObjectToStorageDirectory\getObjectId
getObjectId()
Definition:
class.ilFileObjectToStorageDirectory.php:114
ilFileObjectToStorageDirectory\getHistoryData
getHistoryData()
Definition:
class.ilFileObjectToStorageDirectory.php:84
ilFileObjectToStorageMigrationHelper\MIGRATED
const MIGRATED
Definition:
class.ilFileObjectToStorageMigrationHelper.php:6
ilObjFileImplementationLegacy\parseInfoParams
static parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
Definition:
class.ilObjFileImplementationLegacy.php:275
ilFileObjectToStorageDirectory\getVersions
getVersions()
Definition:
class.ilFileObjectToStorageDirectory.php:106
ilFileObjectToStorageVersion
Class ilFileObjectToStorageVersion.
Definition:
class.ilFileObjectToStorageVersion.php:7
ilFileObjectToStorageDirectory\tearDown
tearDown()
Definition:
class.ilFileObjectToStorageDirectory.php:119
$i
$i
Definition:
metadata.php:24
Throwable
Modules
File
classes
Setup
class.ilFileObjectToStorageDirectory.php
Generated on Sun Apr 13 2025 21:01:06 for ILIAS by
1.8.13 (using
Doxyfile
)