ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCertificateUtilHelper.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
32{
33 private readonly \ILIAS\Filesystem\Util\Convert\LegacyImages $image_converter;
34 private readonly \ILIAS\Filesystem\Util\Archive\Archives $archives;
35 private readonly \ILIAS\FileDelivery\Services $delivery;
36
37 public function __construct()
38 {
39 global $DIC;
40 $this->image_converter = $DIC->fileConverters()->legacyImages();
41 $this->archives = $DIC->archives();
42 $this->delivery = $DIC->fileDelivery();
43 }
44
45 public function deliverData(string $data, string $fileName, string $mimeType): void
46 {
48 $data,
49 $fileName,
50 $mimeType
51 );
52 }
53
54 public function prepareFormOutput(string $string): string
55 {
57 }
58
59 public function convertImage(
60 string $from,
61 string $to,
62 string $geometry = ''
63 ): void {
64 $this->image_converter->convertToFormat(
65 $from,
66 $to,
67 ImageOutputOptions::FORMAT_JPG,
68 $geometry === '' ? null : (int) $geometry,
69 $geometry === '' ? null : (int) $geometry,
70 );
71 }
72
73 public function stripSlashes(string $string): string
74 {
75 return ilUtil::stripSlashes($string);
76 }
77
81 public function zipAndDeliver(array $streams, string $download_filename): void
82 {
83 $this->delivery->delivery()->attached(
84 $this->archives->zip($streams)->get(),
85 $download_filename
86 );
87 }
88
89 public function getDir(string $copyDirectory): array
90 {
91 return ilFileUtils::getDir($copyDirectory);
92 }
93
94 public function unzip(string $file, string $zip_output_path, bool $overwrite): Unzip
95 {
96 return $this->archives->unzip(
97 Streams::ofResource(fopen($file, 'rb')),
98 $this->archives->unzipOptions()
99 ->withOverwrite($overwrite)
100 ->withZipOutputPath($zip_output_path)
101 ->withDirectoryHandling(ZipDirectoryHandling::KEEP_STRUCTURE)
102 );
103 }
104
105 public function delDir(string $path): void
106 {
108 }
109
113 public function moveUploadedFile(
114 string $file,
115 string $name,
116 string $target,
117 bool $raise_errors = true,
118 string $mode = 'move_uploaded'
119 ): bool {
120 return ilFileUtils::moveUploadedFile(
121 $file,
122 $name,
123 $target,
124 $raise_errors,
125 $mode
126 );
127 }
128
129 public function getImagePath(
130 string $img,
131 string $module_path = "",
132 string $mode = "output",
133 bool $offline = false
134 ): string {
135 return ilUtil::getImagePath(
136 $img,
137 $module_path,
138 $mode,
139 $offline
140 );
141 }
142}
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
Just a wrapper class to create Unit Test for other classes.
getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
zipAndDeliver(array $streams, string $download_filename)
readonly ILIAS Filesystem Util Convert LegacyImages $image_converter
deliverData(string $data, string $fileName, string $mimeType)
convertImage(string $from, string $to, string $geometry='')
getDir(string $copyDirectory)
unzip(string $file, string $zip_output_path, bool $overwrite)
moveUploadedFile(string $file, string $name, string $target, bool $raise_errors=true, string $mode='move_uploaded')
readonly ILIAS FileDelivery Services $delivery
readonly ILIAS Filesystem Util Archive Archives $archives
Class ilFileUtils.
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static prepareFormOutput($a_str, bool $a_strip=false)
Util class various functions, usage as namespace.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:30
global $DIC
Definition: shib_login.php:26