ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\MediaObjects\MediaObjectRepository Class Reference
+ Collaboration diagram for ILIAS\MediaObjects\MediaObjectRepository:

Public Member Functions

 __construct (protected ilDBInterface $db, protected IRSSWrapper $irss)
 
 create (int $id, string $title, \ilMobStakeholder $stakeholder, int $from_mob_id=0)
 
 getById (int $id)
 
 delete (int $id)
 
 getLastChangeTimestamp (int $mob_id)
 
 updateLastChangeTimestamp (int $mob_id, int $timestamp)
 
 addFileFromLegacyUpload (int $mob_id, string $tmp_name, string $target_path="")
 
 addFileFromUpload (int $mob_id, UploadResult $result, string $path="/")
 
 addFileFromLocal (int $mob_id, string $tmp_name, string $path)
 
 addLocalDirectory (int $mob_id, string $dir)
 
 getLocalSrc (int $mob_id, string $location)
 
 hasLocalFile (int $mob_id, string $location)
 
 getLocationStream (int $mob_id, string $location)
 
 getLocationContent (int $mob_id, string $location)
 
 getInfoOfEntry (int $mob_id, string $path)
 
 deliverEntry (int $mob_id, string $path)
 
 getContainerPath (int $mob_id)
 
 addStream (int $mob_id, string $location, FileStream $stream)
 
 addString (int $mob_id, string $location, string $content)
 
 getContainerResource (int $mob_id)
 
 getContainerResourceId (int $mob_id)
 
 removeLocation (int $mob_id, string $location)
 
 getFilesOfPath (int $mob_id, string $dir_path)
 

Protected Member Functions

 getRidForMobId (int $mob_id)
 

Detailed Description

Definition at line 31 of file MediaObjectRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaObjects\MediaObjectRepository::__construct ( protected ilDBInterface  $db,
protected IRSSWrapper  $irss 
)

Definition at line 33 of file MediaObjectRepository.php.

36 {
37 }

Member Function Documentation

◆ addFileFromLegacyUpload()

ILIAS\MediaObjects\MediaObjectRepository::addFileFromLegacyUpload ( int  $mob_id,
string  $tmp_name,
string  $target_path = "" 
)

Definition at line 131 of file MediaObjectRepository.php.

131 : void
132 {
133 if ($rid = $this->getRidForMobId($mob_id)) {
134 if ($target_path === "") {
135 $target_path = "/";
136 }
137 $this->irss->importFileFromLegacyUploadToContainer(
138 $rid,
139 $tmp_name,
140 $target_path
141 );
142 }
143 }

◆ addFileFromLocal()

ILIAS\MediaObjects\MediaObjectRepository::addFileFromLocal ( int  $mob_id,
string  $tmp_name,
string  $path 
)

Definition at line 159 of file MediaObjectRepository.php.

159 : void
160 {
161 if ($rid = $this->getRidForMobId($mob_id)) {
162 $this->irss->addLocalFileToContainer(
163 $rid,
164 $tmp_name,
165 $path
166 );
167 }
168 }
$path
Definition: ltiservices.php:30

References $path.

◆ addFileFromUpload()

ILIAS\MediaObjects\MediaObjectRepository::addFileFromUpload ( int  $mob_id,
UploadResult  $result,
string  $path = "/" 
)

Definition at line 145 of file MediaObjectRepository.php.

149 : void {
150 if ($rid = $this->getRidForMobId($mob_id)) {
151 $this->irss->importFileFromUploadResultToContainer(
152 $rid,
153 $result,
154 $path
155 );
156 }
157 }

References $path.

◆ addLocalDirectory()

ILIAS\MediaObjects\MediaObjectRepository::addLocalDirectory ( int  $mob_id,
string  $dir 
)

Definition at line 170 of file MediaObjectRepository.php.

170 : void
171 {
172 if ($rid = $this->getRidForMobId($mob_id)) {
173 $this->irss->addDirectoryToContainer(
174 $rid,
175 $dir
176 );
177 }
178 }

◆ addStream()

ILIAS\MediaObjects\MediaObjectRepository::addStream ( int  $mob_id,
string  $location,
FileStream  $stream 
)

Definition at line 248 of file MediaObjectRepository.php.

252 : void {
253 $this->irss->addStreamToContainer(
254 $this->getRidForMobId($mob_id),
255 $stream,
257 );
258 }
$location
Definition: buildRTE.php:22

◆ addString()

ILIAS\MediaObjects\MediaObjectRepository::addString ( int  $mob_id,
string  $location,
string  $content 
)

Definition at line 260 of file MediaObjectRepository.php.

264 : void {
265 $this->irss->addStringToContainer(
266 $this->getRidForMobId($mob_id),
267 $content,
269 );
270 }

◆ create()

ILIAS\MediaObjects\MediaObjectRepository::create ( int  $id,
string  $title,
\ilMobStakeholder  $stakeholder,
int  $from_mob_id = 0 
)

Definition at line 39 of file MediaObjectRepository.php.

44 : void {
45 $rid = "";
46 if ($from_mob_id > 0) {
47 $from_rid = $this->getRidForMobId($from_mob_id);
48 if ($from_rid !== "") {
49 $rid = $this->irss->cloneContainer($from_rid);
50 }
51 }
52 if ($rid === "") {
53 $rid = $this->irss->createContainer(
54 $stakeholder,
55 "mob.zip"
56 );
57 }
58 $this->db->insert('mob_data', [
59 'id' => ['integer', $id],
60 'rid' => ['text', $rid],
61 'last_change' => ['integer', time()]
62 ]);
63 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References ILIAS\MediaObjects\MediaObjectRepository\getRidForMobId().

+ Here is the call graph for this function:

◆ delete()

ILIAS\MediaObjects\MediaObjectRepository::delete ( int  $id)

Definition at line 85 of file MediaObjectRepository.php.

85 : void
86 {
87 $this->db->manipulateF(
88 'DELETE FROM mob_data WHERE id = %s',
89 ['integer'],
90 [$id]
91 );
92 }

References $id.

◆ deliverEntry()

ILIAS\MediaObjects\MediaObjectRepository::deliverEntry ( int  $mob_id,
string  $path 
)

Definition at line 232 of file MediaObjectRepository.php.

235 : void {
236 $this->irss->deliverContainerEntry(
237 $this->getRidForMobId($mob_id),
238 $path
239 );
240 }

◆ getById()

ILIAS\MediaObjects\MediaObjectRepository::getById ( int  $id)

Definition at line 65 of file MediaObjectRepository.php.

65 : ?array
66 {
67 $set = $this->db->queryF(
68 'SELECT * FROM mob_data WHERE id = %s',
69 ['integer'],
70 [$id]
71 );
72
73 $record = $this->db->fetchAssoc($set);
74 if ($record) {
75 return [
76 'id' => (int) $record['id'],
77 'rid' => (string) $record['rid'],
78 'last_change' => (int) $record['last_change']
79 ];
80 }
81
82 return null;
83 }

References $id, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getContainerPath()

ILIAS\MediaObjects\MediaObjectRepository::getContainerPath ( int  $mob_id)

Definition at line 242 of file MediaObjectRepository.php.

244 : string {
245 return $this->irss->getResourcePath($this->getRidForMobId($mob_id));
246 }

◆ getContainerResource()

ILIAS\MediaObjects\MediaObjectRepository::getContainerResource ( int  $mob_id)

Definition at line 272 of file MediaObjectRepository.php.

274 : ?StorableResource {
275 return $this->irss->getResource($this->getRidForMobId($mob_id));
276 }

◆ getContainerResourceId()

ILIAS\MediaObjects\MediaObjectRepository::getContainerResourceId ( int  $mob_id)

Definition at line 278 of file MediaObjectRepository.php.

280 : ?ResourceIdentification {
281 return $this->irss->getResourceIdForIdString($this->getRidForMobId($mob_id));
282 }

◆ getFilesOfPath()

ILIAS\MediaObjects\MediaObjectRepository::getFilesOfPath ( int  $mob_id,
string  $dir_path 
)

Definition at line 291 of file MediaObjectRepository.php.

294 : array {
295 return $this->irss->getContainerEntriesOfPath(
296 $this->getRidForMobId($mob_id),
297 $dir_path
298 );
299 }

◆ getInfoOfEntry()

ILIAS\MediaObjects\MediaObjectRepository::getInfoOfEntry ( int  $mob_id,
string  $path 
)

Definition at line 222 of file MediaObjectRepository.php.

225 : array {
226 return $this->irss->getContainerEntryInfo(
227 $this->getRidForMobId($mob_id),
228 $path
229 );
230 }

◆ getLastChangeTimestamp()

ILIAS\MediaObjects\MediaObjectRepository::getLastChangeTimestamp ( int  $mob_id)

Definition at line 108 of file MediaObjectRepository.php.

108 : int
109 {
110 $set = $this->db->queryF(
111 "SELECT last_change FROM mob_data " .
112 " WHERE id = %s ",
113 ["integer"],
114 [$mob_id]
115 );
116 if ($rec = $this->db->fetchAssoc($set)) {
117 return (int) ($rec["last_change"] ?? 0);
118 }
119 return 0;
120 }

◆ getLocalSrc()

ILIAS\MediaObjects\MediaObjectRepository::getLocalSrc ( int  $mob_id,
string  $location 
)

Definition at line 180 of file MediaObjectRepository.php.

180 : string
181 {
182 $rid = $this->getRidForMobId($mob_id);
183 if ($rid === "") {
184 return "";
185 }
186 return $this->irss->getContainerUri($rid, $location);
187 }

References $location.

◆ getLocationContent()

ILIAS\MediaObjects\MediaObjectRepository::getLocationContent ( int  $mob_id,
string  $location 
)

Definition at line 208 of file MediaObjectRepository.php.

211 : string {
212 $content = "";
213 if (str_starts_with($location, "/")) {
214 $location = substr($location, 1);
215 }
216 if ($this->irss->hasContainerEntry($this->getRidForMobId($mob_id), $location)) {
217 $content = stream_get_contents($this->getLocationStream($mob_id, $location)->detach());
218 }
219 return $content;
220 }
getLocationStream(int $mob_id, string $location)

References $location.

◆ getLocationStream()

ILIAS\MediaObjects\MediaObjectRepository::getLocationStream ( int  $mob_id,
string  $location 
)

Definition at line 198 of file MediaObjectRepository.php.

201 : ZIPStream {
202 return $this->irss->getStreamOfContainerEntry(
203 $this->getRidForMobId($mob_id),
205 );
206 }

◆ getRidForMobId()

ILIAS\MediaObjects\MediaObjectRepository::getRidForMobId ( int  $mob_id)
protected

Definition at line 94 of file MediaObjectRepository.php.

94 : string
95 {
96 $set = $this->db->queryF(
97 "SELECT * FROM mob_data " .
98 " WHERE id = %s ",
99 ["integer"],
100 [$mob_id]
101 );
102 if ($rec = $this->db->fetchAssoc($set)) {
103 return $rec["rid"] ?? "";
104 }
105 return "";
106 }

Referenced by ILIAS\MediaObjects\MediaObjectRepository\create().

+ Here is the caller graph for this function:

◆ hasLocalFile()

ILIAS\MediaObjects\MediaObjectRepository::hasLocalFile ( int  $mob_id,
string  $location 
)

Definition at line 189 of file MediaObjectRepository.php.

189 : bool
190 {
191 $rid = $this->getRidForMobId($mob_id);
192 if ($rid === "") {
193 return false;
194 }
195 return $this->irss->hasContainerEntry($rid, $location);
196 }

References $location.

◆ removeLocation()

ILIAS\MediaObjects\MediaObjectRepository::removeLocation ( int  $mob_id,
string  $location 
)

Definition at line 284 of file MediaObjectRepository.php.

287 : void {
288 $this->irss->removePathFromContainer($this->getRidForMobId($mob_id), $location);
289 }

◆ updateLastChangeTimestamp()

ILIAS\MediaObjects\MediaObjectRepository::updateLastChangeTimestamp ( int  $mob_id,
int  $timestamp 
)

Definition at line 122 of file MediaObjectRepository.php.

122 : void
123 {
124 $this->db->update(
125 'mob_data',
126 ['last_change' => ['integer', $timestamp]],
127 ['id' => ['integer', $mob_id]]
128 );
129 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70

References $timestamp.


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