19 declare(strict_types=1);
36 protected const DIR_PATH =
"sty/sty_%id%/images";
54 protected function dir(
int $style_id): string
56 return str_replace(
"%id%", (
string) $style_id, self::DIR_PATH);
70 $unzip = $this->irss->getContainerZip($rid);
71 $uri = $this->irss->stream($rid)->getMetadata(
"uri");
72 $zip_archive = new \ZipArchive();
73 $zip_archive->open($uri, \ZipArchive::RDONLY);
75 foreach ($unzip->getPaths() as
$path) {
76 if (str_starts_with(
$path,
".")) {
79 if (!str_starts_with(
$path,
"images")) {
82 if (!in_array(strtolower(pathinfo(
$path, PATHINFO_EXTENSION)), [
"jpg",
"png",
"gif",
"svg"])) {
85 $att = $zip_archive->statName(
$path);
86 $full_path = $this->irss->getContainerUri($rid,
$path);
88 $image_size = getimagesize($full_path);
91 $width = $image_size[0] ?? 0;
92 $height = $image_size[1] ?? 0;
94 $this->irss->getContainerUri($rid,
$path),
103 $dir = $this->
dir($style_id);
104 if ($this->web_files->hasDir($dir)) {
105 foreach ($this->web_files->listContents($dir) as $meta) {
106 if ($meta->isFile()) {
107 $size = $this->web_files->getSize(
111 $image_size = getimagesize($this->
getWebPath($meta->getPath()));
112 $width = $image_size[0] ?? 0;
113 $height = $image_size[1] ?? 0;
129 return $this->irss->getStreamOfContainerEntry(
140 $this->irss->addStreamToContainer(
150 if (str_starts_with($path,
"http")) {
157 public function getByFilename(
int $style_id,
string $rid,
string $filename): ?
Image 160 foreach ($this->
getImages($style_id, $rid) as $i) {
171 $dir = $this->
dir($style_id);
172 $this->web_files->delete($dir .
"/" . $filename);
179 $this->irss->addUploadToContainer(
Filesystem Filesystem $web_files
This class provides the data size with additional information to remove the work to calculate the siz...
The filesystem interface provides the public interface for the Filesystem service API consumer...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addStream(string $rid, string $image, FileStream $stream)
InternalDataService $factory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(InternalDataService $factory, Filesystem\Filesystem $web_files, FileUpload $upload, protected IRSSWrapper $irss)
getImageStream(string $rid, string $image)
deleteImageByFilename(int $style_id, string $filename)
importFromUploadResult(string $rid, UploadResult $result,)
The base interface for all filesystem streams.
getImages(int $style_id, string $rid)
Get images of style.