ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Repository\IRSS\IRSSWrapper Class Reference
+ Collaboration diagram for ILIAS\Repository\IRSS\IRSSWrapper:

Public Member Functions

 __construct (protected DataService $data)
 
 createEmptyCollection ()
 
 getCollectionForIdString (string $rcid)
 
 deleteCollectionForIdString (string $rcid, ResourceStakeholder $stakeholder)
 
 importFilesFromLegacyUploadToCollection (ResourceCollection $collection, array $file_input, ResourceStakeholder $stakeholder)
 
 importFilesFromDirectoryToCollection (ResourceCollection $collection, string $directory, ResourceStakeholder $stakeholder)
 
 getResourceIdForIdString (string $rid)
 
 importFileFromLegacyUpload (array $file_input, ResourceStakeholder $stakeholder)
 
 importFileFromUploadResult (UploadResult $result, ResourceStakeholder $stakeholder)
 
 importLocalFile (string $file, string $name, ResourceStakeholder $stakeholder)
 
 importStream (Stream $stream, ResourceStakeholder $stakeholder)
 
 renameCurrentRevision (string $rid, string $title)
 
 deliverFile (string $rid)
 
 stream (string $rid)
 
 getResourcePath (string $rid)
 
 getResource (string $rid)
 
 getCollectionResourcesInfo (ResourceCollection $collection)
 
 getResourceInfo (string $rid)
 
 clone (string $from_rc_id)
 
 cloneResource (string $from_rid)
 
 cloneContainer (string $from_rid)
 
 deleteResource (string $rid, ResourceStakeholder $stakeholder)
 
 addEntryOfZipResourceToCollection (string $rid, string $entry, ResourceCollection $target_collection, ResourceStakeholder $target_stakeholder)
 
 getStreamOfContainerEntry (string $rid, string $entry)
 
 getContainerEntryInfo (string $container_id, string $path)
 
 deliverContainerEntry (string $container_id, string $path)
 
 hasContainerEntry (string $rid, string $entry)
 Is there a better way to check this? More...
 
 getContainerStreams (string $container_id, ResourceStakeholder $stakeholder)
 
 getContainerPaths (string $container_id)
 
 getContainerEntries (string $container_id)
 
 getContainerEntriesOfPath (string $container_id, string $dir_path)
 
 addContainerDirToTargetContainer (string $source_container_id, string $target_container_id, string $source_dir_path="", string $target_dir_path="")
 
 createContainer (ResourceStakeholder $stakeholder, string $title="container.zip")
 
 createContainerFromLocalZip (string $local_zip_path, ResourceStakeholder $stakeholder)
 
 createContainerFromLocalDir (string $local_dir_path, ResourceStakeholder $stakeholder, string $container_path="", bool $recursive=true, string $title="container.zip")
 
 addLocalFileToContainer (string $rid, string $fullpath, string $path)
 
 addStringToContainer (string $rid, string $content, string $path)
 
 addDirectoryToContainer (string $rid, string $source_dir, string $target_path="")
 
 addUploadToContainer (string $rid, UploadResult $result)
 
 getContainerUri (string $rid, string $path)
 
 getContainerZip (string $rid)
 
 importFileFromLegacyUploadToContainer (string $rid, string $tmp_name, string $target_path)
 
 importFileFromUploadResultToContainer (string $rid, UploadResult $result, string $target_path)
 
 addStreamToContainer (string $rid, FileStream $stream, string $path)
 
 removePathFromContainer (string $rid, string $path)
 
 renameContainer (string $rid, string $title)
 

Protected Member Functions

 getNewCollectionId ()
 
 getNewCollectionIdAsString ()
 

Protected Attributes

Filesystems $filesystems
 
ILIAS FileDelivery Services $file_delivery
 
ILIAS FileUpload FileUpload $upload
 
ILIAS ResourceStorage Services $irss
 
Archives $archives
 

Detailed Description

Definition at line 41 of file IRSSWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Repository\IRSS\IRSSWrapper::__construct ( protected DataService  $data)

Definition at line 49 of file IRSSWrapper.php.

51 {
52 global $DIC;
53
54 if (!$DIC->isDependencyAvailable("resourceStorage")) {
55 return;
56 }
57 $this->irss = $DIC->resourceStorage();
58 $this->archives = $DIC->archives();
59 $this->upload = $DIC->upload();
60 $this->archives = $DIC->archives();
61 $this->file_delivery = $DIC->fileDelivery();
62 $this->filesystems = $DIC->filesystem();
63 }
static filesystems()
Returns the loaded filesystems.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Filesystem\filesystems(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

Member Function Documentation

◆ addContainerDirToTargetContainer()

ILIAS\Repository\IRSS\IRSSWrapper::addContainerDirToTargetContainer ( string  $source_container_id,
string  $target_container_id,
string  $source_dir_path = "",
string  $target_dir_path = "" 
)

Definition at line 552 of file IRSSWrapper.php.

557 : void {
558 $reader = new ZipReader(
559 $this->irss->consume()->stream($this->getResourceIdForIdString($source_container_id))->getStream()
560 );
561 $entries = [];
562 foreach ($reader->getStructure() as $path => $entry) {
563 if (str_starts_with($entry['dirname'], $source_dir_path) && !$entry['is_dir']) {
565 $target_container_id,
566 $this->getStreamOfContainerEntry($source_container_id, $path),
567 $target_dir_path . "/" . substr($path, strlen($source_dir_path))
568 );
569 }
570 }
571 }
getStreamOfContainerEntry(string $rid, string $entry)
addStreamToContainer(string $rid, FileStream $stream, string $path)
$path
Definition: ltiservices.php:30

References $path.

◆ addDirectoryToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::addDirectoryToContainer ( string  $rid,
string  $source_dir,
string  $target_path = "" 
)

Definition at line 686 of file IRSSWrapper.php.

690 : void {
691 $source_dir = realpath($source_dir);
692 $directoryIterator = new \RecursiveDirectoryIterator(
693 $source_dir,
694 \FilesystemIterator::SKIP_DOTS
695 );
696
697 $recursiveIterator = new \RecursiveIteratorIterator(
698 $directoryIterator,
699 \RecursiveIteratorIterator::LEAVES_ONLY
700 );
701
702 foreach ($recursiveIterator as $fileInfo) {
703 if ($fileInfo->isFile()) {
704 $fullPath = $fileInfo->getPathname();
705 $relativePath = substr($fullPath, strlen($source_dir) + 1);
706 $files[] = $relativePath;
708 $rid,
709 $fullPath,
710 $target_path . "/" . $relativePath
711 );
712 }
713 }
714 }
addLocalFileToContainer(string $rid, string $fullpath, string $path)

◆ addEntryOfZipResourceToCollection()

ILIAS\Repository\IRSS\IRSSWrapper::addEntryOfZipResourceToCollection ( string  $rid,
string  $entry,
ResourceCollection  $target_collection,
ResourceStakeholder  $target_stakeholder 
)

Definition at line 388 of file IRSSWrapper.php.

393 : void {
394 $entry_parts = explode("/", $entry);
395 $stream = $this->getStreamOfContainerEntry($rid, $entry);
396 $feedback_rid = $this->irss->manage()->stream(
397 $stream,
398 $target_stakeholder,
399 $entry_parts[2]
400 );
401 $target_collection->add($feedback_rid);
402 $this->irss->collection()->store($target_collection);
403 }
add(ResourceIdentification $identification)

◆ addLocalFileToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::addLocalFileToContainer ( string  $rid,
string  $fullpath,
string  $path 
)

Definition at line 650 of file IRSSWrapper.php.

654 : void {
655 $id = $this->getResourceIdForIdString($rid);
656 $stream = fopen($fullpath, 'r');
657 $fs = new Stream($stream);
658 $this->irss->manageContainer()->removePathInsideContainer($id, $path);
659 $this->irss->manageContainer()->addStreamToContainer(
660 $id,
661 $fs,
662 $path
663 );
664 fclose($stream);
665 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ addStreamToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::addStreamToContainer ( string  $rid,
FileStream  $stream,
string  $path 
)

Definition at line 819 of file IRSSWrapper.php.

823 : void {
824 $id = $this->getResourceIdForIdString($rid);
825
826 if (!is_null($id)) {
827 $this->irss->manageContainer()->addStreamToContainer(
828 $id,
829 $stream,
830 $path
831 );
832 }
833 }

References $id, and $path.

◆ addStringToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::addStringToContainer ( string  $rid,
string  $content,
string  $path 
)

Definition at line 667 of file IRSSWrapper.php.

671 : void {
672 $id = $this->getResourceIdForIdString($rid);
673 $stream = fopen('php://memory', 'r+');
674 fwrite($stream, $content);
675 rewind($stream);
676 $fs = new Stream($stream);
677 $this->irss->manageContainer()->removePathInsideContainer($id, $path);
678 $this->irss->manageContainer()->addStreamToContainer(
679 $id,
680 $fs,
681 $path
682 );
683 fclose($stream);
684 }

◆ addUploadToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::addUploadToContainer ( string  $rid,
UploadResult  $result 
)

Definition at line 716 of file IRSSWrapper.php.

719 : void {
720 $id = $this->getResourceIdForIdString($rid);
721 $this->irss->manageContainer()->addUploadToContainer(
722 $id,
723 $result,
724 "images"
725 );
726 }

◆ clone()

ILIAS\Repository\IRSS\IRSSWrapper::clone ( string  $from_rc_id)

Definition at line 348 of file IRSSWrapper.php.

350 : string {
351 if ($from_rc_id !== "") {
352 $cloned_rcid = $this->irss->collection()->clone($this->irss->collection()->id($from_rc_id));
353 return $cloned_rcid->serialize();
354 }
355 return "";
356 }

◆ cloneContainer()

ILIAS\Repository\IRSS\IRSSWrapper::cloneContainer ( string  $from_rid)

Definition at line 368 of file IRSSWrapper.php.

370 : string {
371 if ($from_rid !== "") {
372 $cloned_rid = $this->irss->manageContainer()->clone($this->getResourceIdForIdString($from_rid));
373 return $cloned_rid->serialize();
374 }
375 return "";
376 }

◆ cloneResource()

ILIAS\Repository\IRSS\IRSSWrapper::cloneResource ( string  $from_rid)

Definition at line 358 of file IRSSWrapper.php.

360 : string {
361 if ($from_rid !== "") {
362 $cloned_rid = $this->irss->manage()->clone($this->getResourceIdForIdString($from_rid));
363 return $cloned_rid->serialize();
364 }
365 return "";
366 }

◆ createContainer()

ILIAS\Repository\IRSS\IRSSWrapper::createContainer ( ResourceStakeholder  $stakeholder,
string  $title = "container.zip" 
)

Definition at line 573 of file IRSSWrapper.php.

576 : string {
577 if ($title === "") {
578 throw new \ilException("Container title missing.");
579 }
580 // create empty container resource. empty zips are not allowed, we need at least one file which is hidden
581 $tmp_dir_info = new \SplFileInfo(\ilFileUtils::ilTempnam());
582 $this->filesystems->temp()->createDir($tmp_dir_info->getFilename());
583 $tmp_dir = $tmp_dir_info->getRealPath();
584 $options = (new ZipOptions())
585 ->withZipOutputName($title)
586 ->withZipOutputPath($tmp_dir);
587 $empty_zip = $this->archives->zip(
588 [],
590 );
591 $rid = $this->irss->manageContainer()->containerFromStream(
592 $empty_zip->get(),
593 $stakeholder,
594 $title
595 );
596 \ilFileUtils::delDir($tmp_dir);
597 return $rid->serialize();
598 }
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

◆ createContainerFromLocalDir()

ILIAS\Repository\IRSS\IRSSWrapper::createContainerFromLocalDir ( string  $local_dir_path,
ResourceStakeholder  $stakeholder,
string  $container_path = "",
bool  $recursive = true,
string  $title = "container.zip" 
)

Definition at line 614 of file IRSSWrapper.php.

620 : string {
621 $real_dir_path = realpath($local_dir_path);
622 $rid = $this->createContainer($stakeholder, $title);
623 if ($recursive) {
624 $iterator = new \RecursiveIteratorIterator(
625 new \RecursiveDirectoryIterator(
626 $local_dir_path,
627 \RecursiveDirectoryIterator::SKIP_DOTS | \RecursiveDirectoryIterator::CURRENT_AS_SELF
628 ),
629 \RecursiveIteratorIterator::SELF_FIRST
630 );
631 } else {
632 $iterator = new \DirectoryIterator($local_dir_path);
633 }
634 if ($container_path !== "") {
635 $container_path = $container_path . "/";
636 }
637 foreach ($iterator as $file) {
638 if (!$file->isDir() && !$file->isDot()) {
639 $file->getRealPath();
641 $rid,
642 $file->getRealPath(),
643 $container_path . substr($file->getRealPath(), strlen($real_dir_path) + 1)
644 );
645 }
646 }
647 return $rid;
648 }
createContainer(ResourceStakeholder $stakeholder, string $title="container.zip")

◆ createContainerFromLocalZip()

ILIAS\Repository\IRSS\IRSSWrapper::createContainerFromLocalZip ( string  $local_zip_path,
ResourceStakeholder  $stakeholder 
)

Definition at line 600 of file IRSSWrapper.php.

603 : string {
604 $stream = fopen($local_zip_path, 'r');
605 $fs = new Stream($stream);
606
607 $rid = $this->irss->manageContainer()->containerFromStream(
608 $fs,
609 $stakeholder
610 );
611 return $rid->serialize();
612 }

◆ createEmptyCollection()

ILIAS\Repository\IRSS\IRSSWrapper::createEmptyCollection ( )

Definition at line 75 of file IRSSWrapper.php.

75 : string
76 {
77 $new_id = $this->getNewCollectionId();
78 $new_collection = $this->irss->collection()->get($new_id);
79 $this->irss->collection()->store($new_collection);
80 return $new_id->serialize();
81 }

References ILIAS\Repository\IRSS\IRSSWrapper\getNewCollectionId().

+ Here is the call graph for this function:

◆ deleteCollectionForIdString()

ILIAS\Repository\IRSS\IRSSWrapper::deleteCollectionForIdString ( string  $rcid,
ResourceStakeholder  $stakeholder 
)

Definition at line 88 of file IRSSWrapper.php.

91 : void {
92 $id = $this->irss->collection()->id($rcid);
93 $this->irss->collection()->remove($id, $stakeholder, true);
94 }

◆ deleteResource()

ILIAS\Repository\IRSS\IRSSWrapper::deleteResource ( string  $rid,
ResourceStakeholder  $stakeholder 
)

Definition at line 378 of file IRSSWrapper.php.

378 : void
379 {
380 if ($rid !== "") {
381 $res = $this->getResourceIdForIdString($rid);
382 if ($res) {
383 $this->irss->manage()->remove($this->getResourceIdForIdString($rid), $stakeholder);
384 }
385 }
386 }
$res
Definition: ltiservices.php:69

References $res.

◆ deliverContainerEntry()

ILIAS\Repository\IRSS\IRSSWrapper::deliverContainerEntry ( string  $container_id,
string  $path 
)

Definition at line 430 of file IRSSWrapper.php.

433 : void {
434 $reader = new ZipReader(
435 $this->irss->consume()->stream($this->getResourceIdForIdString($container_id))->getStream()
436 );
437 [$stream, $info] = $reader->getItem($path);
438
439 $this->file_delivery->delivery()->deliver(
440 $stream,
441 $info['basename'],
442 $info['mime_type'],
443 Disposition::ATTACHMENT
444 );
445 }
$info
Definition: entry_point.php:21

◆ deliverFile()

ILIAS\Repository\IRSS\IRSSWrapper::deliverFile ( string  $rid)

Definition at line 275 of file IRSSWrapper.php.

275 : void
276 {
277 $id = $this->getResourceIdForIdString($rid);
278 if ($id) {
279 $revision = $this->irss->manage()->getCurrentRevision($id);
280 $this->irss->consume()->download($id)->overrideFileName($revision->getTitle())->run();
281 }
282 }

References $id.

◆ getCollectionForIdString()

ILIAS\Repository\IRSS\IRSSWrapper::getCollectionForIdString ( string  $rcid)

Definition at line 83 of file IRSSWrapper.php.

84 {
85 return $this->irss->collection()->get($this->irss->collection()->id($rcid));
86 }

◆ getCollectionResourcesInfo()

ILIAS\Repository\IRSS\IRSSWrapper::getCollectionResourcesInfo ( ResourceCollection  $collection)

Definition at line 311 of file IRSSWrapper.php.

313 : \Generator {
314 foreach ($collection->getResourceIdentifications() as $rid) {
315 $info = $this->irss->manage()->getResource($rid)
316 ->getCurrentRevision()
317 ->getInformation();
318 $src = $this->irss->consume()->src($rid)->getSrc();
319 yield $this->data->resourceInformation(
320 $rid->serialize(),
321 $info->getTitle(),
322 $info->getSize(),
323 $info->getCreationDate()->getTimestamp(),
324 $info->getMimeType(),
325 $src
326 );
327 }
328 }

References $info.

◆ getContainerEntries()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerEntries ( string  $container_id)

Definition at line 517 of file IRSSWrapper.php.

519 : array {
520 $rid = $this->getResourceIdForIdString($container_id);
521 if (is_null($rid)) {
522 return [];
523 }
524 $reader = new ZipReader(
525 $this->irss->consume()->stream($rid)->getStream()
526 );
527 return $reader->getStructure();
528 }

◆ getContainerEntriesOfPath()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerEntriesOfPath ( string  $container_id,
string  $dir_path 
)

Definition at line 530 of file IRSSWrapper.php.

533 : array {
534 $rid = $this->getResourceIdForIdString($container_id);
535 if (is_null($rid)) {
536 return [];
537 }
538 $reader = new ZipReader(
539 $this->irss->consume()->stream($rid)->getStream()
540 );
541 $entries = [];
542 foreach ($reader->getStructure() as $path => $entry) {
543 $dirname = $entry['dirname'] ?? '';
544 if ($dirname !== $dir_path) {
545 continue;
546 }
547 $entries[$path] = $entry;
548 }
549 return $entries;
550 }

◆ getContainerEntryInfo()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerEntryInfo ( string  $container_id,
string  $path 
)

Definition at line 420 of file IRSSWrapper.php.

423 : array {
424 $reader = new ZipReader(
425 $this->irss->consume()->stream($this->getResourceIdForIdString($container_id))->getStream()
426 );
427 return $reader->getItem($path)[1];
428 }

◆ getContainerPaths()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerPaths ( string  $container_id)

Definition at line 507 of file IRSSWrapper.php.

509 : \Generator {
510 foreach ($this->irss->consume()->containerZIP(
511 $this->getResourceIdForIdString($container_id)
512 )->getZIP()->getPaths() as $path) {
513 yield $path;
514 }
515 }

References $path.

◆ getContainerStreams()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerStreams ( string  $container_id,
ResourceStakeholder  $stakeholder 
)
Returns
\Generator<Stream>

Definition at line 496 of file IRSSWrapper.php.

499 : \Generator {
500 foreach ($this->irss->consume()->containerZIP(
501 $this->getResourceIdForIdString($container_id)
502 )->getZIP()->getFileStreams() as $stream) {
503 yield $stream;
504 }
505 }

◆ getContainerUri()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerUri ( string  $rid,
string  $path 
)

Definition at line 728 of file IRSSWrapper.php.

731 : string {
732 $id = $this->getResourceIdForIdString($rid);
733 $uri = $this->irss->consume()->containerURI(
734 $id,
735 $path,
736 8 * 60
737 )->getURI();
738 // temp fixes wrong slash escaping, maybe due to 24805bcaabb33b1c5c82609dbe6791c55577c6a4
739 $uri = str_replace("%2F", "/", (string) $uri);
740 return (string) $uri;
741 }

◆ getContainerZip()

ILIAS\Repository\IRSS\IRSSWrapper::getContainerZip ( string  $rid)

Definition at line 743 of file IRSSWrapper.php.

745 : Unzip {
746 $id = $this->getResourceIdForIdString($rid);
747 return $this->irss->consume()->containerZIP(
748 $id
749 )->getZIP();
750 }

◆ getNewCollectionId()

ILIAS\Repository\IRSS\IRSSWrapper::getNewCollectionId ( )
protected

Definition at line 65 of file IRSSWrapper.php.

65 : ResourceCollectionIdentification
66 {
67 return $this->irss->collection()->id();
68 }

Referenced by ILIAS\Repository\IRSS\IRSSWrapper\createEmptyCollection(), and ILIAS\Repository\IRSS\IRSSWrapper\getNewCollectionIdAsString().

+ Here is the caller graph for this function:

◆ getNewCollectionIdAsString()

ILIAS\Repository\IRSS\IRSSWrapper::getNewCollectionIdAsString ( )
protected

Definition at line 70 of file IRSSWrapper.php.

70 : string
71 {
72 return $this->getNewCollectionId()->serialize();
73 }

References ILIAS\Repository\IRSS\IRSSWrapper\getNewCollectionId().

+ Here is the call graph for this function:

◆ getResource()

ILIAS\Repository\IRSS\IRSSWrapper::getResource ( string  $rid)

Definition at line 302 of file IRSSWrapper.php.

302 : ?StorableResource
303 {
304 $id = $this->getResourceIdForIdString($rid);
305 if ($id) {
306 return $this->irss->manage()->getResource($id);
307 }
308 return null;
309 }

References $id.

◆ getResourceIdForIdString()

ILIAS\Repository\IRSS\IRSSWrapper::getResourceIdForIdString ( string  $rid)

Definition at line 178 of file IRSSWrapper.php.

178 : ?ResourceIdentification
179 {
180 return $this->irss->manage()->find($rid);
181 }

◆ getResourceInfo()

ILIAS\Repository\IRSS\IRSSWrapper::getResourceInfo ( string  $rid)

Definition at line 330 of file IRSSWrapper.php.

332 : ResourceInformation {
333 $rid = $this->getResourceIdForIdString($rid);
334 $info = $this->irss->manage()->getResource($rid)
335 ->getCurrentRevision()
336 ->getInformation();
337 $src = $this->irss->consume()->src($rid)->getSrc();
338 return $this->data->resourceInformation(
339 $rid->serialize(),
340 $info->getTitle(),
341 $info->getSize(),
342 $info->getCreationDate()->getTimestamp(),
343 $info->getMimeType(),
344 $src
345 );
346 }

◆ getResourcePath()

ILIAS\Repository\IRSS\IRSSWrapper::getResourcePath ( string  $rid)

Definition at line 293 of file IRSSWrapper.php.

293 : string
294 {
295 $stream = $this->stream($rid);
296 if ($stream) {
297 return $stream->getMetadata('uri') ?? '';
298 }
299 return "";
300 }

References ILIAS\Filesystem\Stream\Stream\getMetadata().

+ Here is the call graph for this function:

◆ getStreamOfContainerEntry()

ILIAS\Repository\IRSS\IRSSWrapper::getStreamOfContainerEntry ( string  $rid,
string  $entry 
)

Definition at line 409 of file IRSSWrapper.php.

412 : ZIPStream {
413 $zip_path = $this->stream($rid)->getMetadata("uri");
415 $zip_path,
416 $entry
417 );
418 }
static ofFileInsideZIP(string $path_to_zip, string $path_inside_zip)
Definition: Streams.php:84

◆ hasContainerEntry()

ILIAS\Repository\IRSS\IRSSWrapper::hasContainerEntry ( string  $rid,
string  $entry 
)

Is there a better way to check this?

Definition at line 450 of file IRSSWrapper.php.

453 : bool {
454 if ($rid === "") {
455 return false;
456 }
457 $zip_path = $this->stream($rid)?->getMetadata("uri");
458 if (is_null($zip_path)) {
459 return false;
460 }
461 try {
462 $stream = Streams::ofFileInsideZIP(
463 $zip_path,
464 $entry
465 );
466 $stream->close();
467 return true;
468 } catch (\Exception $e) {
469 return false;
470 }
471 }

◆ importFileFromLegacyUpload()

ILIAS\Repository\IRSS\IRSSWrapper::importFileFromLegacyUpload ( array  $file_input,
ResourceStakeholder  $stakeholder 
)

Definition at line 183 of file IRSSWrapper.php.

186 : string {
188
189 if (is_array($file_input)) {
190 if (!$upload->hasBeenProcessed()) {
191 $upload->process();
192 }
193 foreach ($upload->getResults() as $name => $result) {
194 // we must check if these are files from this input
195 if ($name !== ($file_input["tmp_name"] ?? "")) {
196 continue;
197 }
198 // if the result is not OK, we skip it
199 if (!$result->isOK()) {
200 continue;
201 }
202
203 // we store the file in the IRSS
204 $rid = $this->irss->manage()->upload(
205 $result,
206 $stakeholder
207 );
208 return $rid->serialize();
209 }
210 }
211 return "";
212 }
ILIAS FileUpload FileUpload $upload
Definition: IRSSWrapper.php:45

◆ importFileFromLegacyUploadToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::importFileFromLegacyUploadToContainer ( string  $rid,
string  $tmp_name,
string  $target_path 
)

Definition at line 754 of file IRSSWrapper.php.

758 : void {
760
761 if (!$upload->hasBeenProcessed()) {
762 $upload->process();
763 }
764 foreach ($upload->getResults() as $name => $result) {
765 // we must check if these are files from this input
766 if ($name !== $tmp_name) {
767 continue;
768 }
769 // if the result is not OK, we skip it
770 if (!$result->isOK()) {
771 continue;
772 }
773
774 $id = $this->getResourceIdForIdString($rid);
775
776 if (!is_null($id)) {
777 // if target path is a directory, addUploadToContainer
778 // can be used, the original filename will be appended
779 if ($target_path === "" || str_ends_with($target_path, "/")) {
780 $this->irss->manageContainer()->addUploadToContainer(
781 $id,
782 $result,
783 "/"
784 );
785 } else {
786 // we have a full path given (renaming the
787 // original name)
789 $rid,
790 $result->getPath(),
791 $target_path
792 );
793 }
794 }
795 }
796 }

◆ importFileFromUploadResult()

ILIAS\Repository\IRSS\IRSSWrapper::importFileFromUploadResult ( UploadResult  $result,
ResourceStakeholder  $stakeholder 
)

Definition at line 214 of file IRSSWrapper.php.

217 : string {
218 // if the result is not OK, we skip it
219 if (!$result->isOK()) {
220 return "";
221 }
222
223 // we store the file in the IRSS
224 $rid = $this->irss->manage()->upload(
225 $result,
226 $stakeholder
227 );
228 return $rid->serialize();
229 }

◆ importFileFromUploadResultToContainer()

ILIAS\Repository\IRSS\IRSSWrapper::importFileFromUploadResultToContainer ( string  $rid,
UploadResult  $result,
string  $target_path 
)

Definition at line 798 of file IRSSWrapper.php.

802 : void {
803 // if the result is not OK, we skip it
804 if (!$result->isOK()) {
805 return;
806 }
807
808 $id = $this->getResourceIdForIdString($rid);
809
810 if (!is_null($id)) {
811 $this->irss->manageContainer()->addUploadToContainer(
812 $id,
813 $result,
814 $target_path
815 );
816 }
817 }

◆ importFilesFromDirectoryToCollection()

ILIAS\Repository\IRSS\IRSSWrapper::importFilesFromDirectoryToCollection ( ResourceCollection  $collection,
string  $directory,
ResourceStakeholder  $stakeholder 
)

Definition at line 146 of file IRSSWrapper.php.

150 : void {
151 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($directory);
152 $sourceDir = LegacyPathHelper::createRelativePath($directory);
153
154 // check if arguments are directories
155 if (!$sourceFS->hasDir($sourceDir)) {
156 return;
157 }
158
159 $sourceList = $sourceFS->listContents($sourceDir, false);
160
161 foreach ($sourceList as $item) {
162 if ($item->isDir()) {
163 continue;
164 }
165 try {
166 $stream = $sourceFS->readStream($item->getPath());
167 $rid = $this->irss->manage()->stream(
168 $stream,
169 $stakeholder
170 );
171 $collection->add($rid);
172 } catch (\ILIAS\Filesystem\Exception\FileAlreadyExistsException $e) {
173 }
174 }
175 $this->irss->collection()->store($collection);
176 }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ importFilesFromLegacyUploadToCollection()

ILIAS\Repository\IRSS\IRSSWrapper::importFilesFromLegacyUploadToCollection ( ResourceCollection  $collection,
array  $file_input,
ResourceStakeholder  $stakeholder 
)

Definition at line 112 of file IRSSWrapper.php.

116 : void {
118
119 if (is_array($file_input)) {
120 if (!$upload->hasBeenProcessed()) {
121 $upload->process();
122 }
123 foreach ($upload->getResults() as $name => $result) {
124 // we must check if these are files from this input
125 if (!in_array($name, $file_input["tmp_name"] ?? [], true)) {
126 continue;
127 }
128 // if the result is not OK, we skip it
129 if (!$result->isOK()) {
130 continue;
131 }
132
133 // we store the file in the IRSS
134 $rid = $this->irss->manage()->upload(
135 $result,
136 $stakeholder
137 );
138 // and add its identification to the collection
139 $collection->add($rid);
140 }
141 // we store the collection after all files have been added
142 $this->irss->collection()->store($collection);
143 }
144 }

References ILIAS\ResourceStorage\Collection\ResourceCollection\add().

+ Here is the call graph for this function:

◆ importLocalFile()

ILIAS\Repository\IRSS\IRSSWrapper::importLocalFile ( string  $file,
string  $name,
ResourceStakeholder  $stakeholder 
)

Definition at line 231 of file IRSSWrapper.php.

235 : string {
237 $sourceFile = LegacyPathHelper::createRelativePath($file);
238
239 //try {
240 $stream = $sourceFS->readStream($sourceFile);
241 $rid = $this->irss->manage()->stream(
242 $stream,
243 $stakeholder,
244 $name
245 );
246 //} catch (\Exception $e) {
247 // return "";
248 //}
249 return $rid->serialize();
250 }

◆ importStream()

ILIAS\Repository\IRSS\IRSSWrapper::importStream ( Stream  $stream,
ResourceStakeholder  $stakeholder 
)

Definition at line 252 of file IRSSWrapper.php.

255 : string {
256 $rid = $this->irss->manage()->stream(
257 $stream,
258 $stakeholder
259 );
260 return $rid->serialize();
261 }

◆ removePathFromContainer()

ILIAS\Repository\IRSS\IRSSWrapper::removePathFromContainer ( string  $rid,
string  $path 
)

Definition at line 835 of file IRSSWrapper.php.

838 : void {
839 $id = $this->getResourceIdForIdString($rid);
840 if (!is_null($id)) {
841 $this->irss->manageContainer()->removePathInsideContainer($id, $path);
842 }
843 }

References $id, and $path.

◆ renameContainer()

ILIAS\Repository\IRSS\IRSSWrapper::renameContainer ( string  $rid,
string  $title 
)

Definition at line 846 of file IRSSWrapper.php.

849 : void {
850 $id = $this->getResourceIdForIdString($rid);
851 $rev = $this->irss->manageContainer()->getCurrentRevision($id);
852 $info = $rev->getInformation();
853 $info->setTitle($title);
854 $rev->setInformation($info);
855 $this->irss->manageContainer()->updateRevision($rev);
856 }

◆ renameCurrentRevision()

ILIAS\Repository\IRSS\IRSSWrapper::renameCurrentRevision ( string  $rid,
string  $title 
)

Definition at line 263 of file IRSSWrapper.php.

266 : void {
267 $id = $this->getResourceIdForIdString($rid);
268 $rev = $this->irss->manage()->getCurrentRevision($id);
269 $info = $rev->getInformation();
270 $info->setTitle($title);
271 $rev->setInformation($info);
272 $this->irss->manage()->updateRevision($rev);
273 }

◆ stream()

ILIAS\Repository\IRSS\IRSSWrapper::stream ( string  $rid)

Definition at line 284 of file IRSSWrapper.php.

284 : ?FileStream
285 {
286 $id = $this->getResourceIdForIdString($rid);
287 if ($id) {
288 return $this->irss->consume()->stream($id)->getStream();
289 }
290 return null;
291 }
The base interface for all filesystem streams.
Definition: FileStream.php:32

References $id.

Field Documentation

◆ $archives

Archives ILIAS\Repository\IRSS\IRSSWrapper::$archives
protected

Definition at line 47 of file IRSSWrapper.php.

◆ $file_delivery

ILIAS FileDelivery Services ILIAS\Repository\IRSS\IRSSWrapper::$file_delivery
protected

Definition at line 44 of file IRSSWrapper.php.

◆ $filesystems

Filesystems ILIAS\Repository\IRSS\IRSSWrapper::$filesystems
protected

Definition at line 43 of file IRSSWrapper.php.

◆ $irss

ILIAS ResourceStorage Services ILIAS\Repository\IRSS\IRSSWrapper::$irss
protected

Definition at line 46 of file IRSSWrapper.php.

◆ $upload

ILIAS FileUpload FileUpload ILIAS\Repository\IRSS\IRSSWrapper::$upload
protected

Definition at line 45 of file IRSSWrapper.php.


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