ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCertificateUtilHelper.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  {
107  ilFileUtils::delDir($path);
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 {
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 }
convertImage(string $from, string $to, string $geometry='')
readonly ILIAS FileDelivery Services $delivery
zipAndDeliver(array $streams, string $download_filename)
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")
static prepareFormOutput($a_str, bool $a_strip=false)
getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
moveUploadedFile(string $file, string $name, string $target, bool $raise_errors=true, string $mode='move_uploaded')
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
deliverData(string $data, string $fileName, string $mimeType)
unzip(string $file, string $zip_output_path, bool $overwrite)
getDir(string $copyDirectory)
readonly ILIAS Filesystem Util Convert LegacyImages $image_converter
readonly ILIAS Filesystem Util Archive Archives $archives