ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCertificateUtilHelper Class Reference

Just a wrapper class to create Unit Test for other classes. More...

+ Collaboration diagram for ilCertificateUtilHelper:

Public Member Functions

 __construct ()
 
 deliverData (string $data, string $fileName, string $mimeType)
 
 prepareFormOutput (string $string)
 
 convertImage (string $from, string $to, string $geometry='')
 
 stripSlashes (string $string)
 
 zipAndDeliver (array $streams, string $download_filename)
 
 getDir (string $copyDirectory)
 
 unzip (string $file, string $zip_output_path, bool $overwrite)
 
 delDir (string $path)
 
 moveUploadedFile (string $file, string $name, string $target, bool $raise_errors=true, string $mode='move_uploaded')
 
 getImagePath (string $img, string $module_path="", string $mode="output", bool $offline=false)
 

Private Attributes

ILIAS Filesystem Util Convert Images $image_converter
 
ILIAS Filesystem Util Archive Archives $archives
 
ILIAS FileDelivery Services $delivery
 

Detailed Description

Just a wrapper class to create Unit Test for other classes.

Can be remove when the static method calls have been removed

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

Definition at line 31 of file ilCertificateUtilHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilCertificateUtilHelper::__construct ( )

Definition at line 37 of file ilCertificateUtilHelper.php.

References $DIC.

38  {
39  global $DIC;
40  $this->image_converter = $DIC->fileConverters()->images();
41  $this->archives = $DIC->archives();
42  $this->delivery = $DIC->fileDelivery();
43  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ convertImage()

ilCertificateUtilHelper::convertImage ( string  $from,
string  $to,
string  $geometry = '' 
)

Definition at line 59 of file ilCertificateUtilHelper.php.

63  : void {
64  $converter = $this->image_converter->convertToFormat(
65  Streams::ofResource(fopen($from, 'rb')),
66  ImageOutputOptions::FORMAT_JPG,
67  $geometry === '' ? null : (int) $geometry,
68  $geometry === '' ? null : (int) $geometry,
69  (new ImageOutputOptions())->withQuality(100)
70  );
71 
72  if (!$converter->isOK()) {
73  throw new ilException(
74  sprintf(
75  'Could not convert image %s to %s',
76  $from,
77  $to
78  ),
79  0,
80  $converter->getThrowableIfAny()
81  );
82  }
83 
84  $stream = $converter->getStream();
85 
86  try {
87  $stream->rewind();
88  if (file_put_contents($to, $stream->getContents()) === false) {
89  throw new ilException(
90  sprintf(
91  'Could not store converted image %s to %s',
92  $from,
93  $to
94  )
95  );
96  }
97  } finally {
98  $stream->close();
99  }
100  }

◆ delDir()

ilCertificateUtilHelper::delDir ( string  $path)

Definition at line 134 of file ilCertificateUtilHelper.php.

References ilFileUtils\delDir().

134  : void
135  {
137  }
$path
Definition: ltiservices.php:32
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ deliverData()

ilCertificateUtilHelper::deliverData ( string  $data,
string  $fileName,
string  $mimeType 
)

Definition at line 45 of file ilCertificateUtilHelper.php.

References ilUtil\deliverData().

45  : void
46  {
48  $data,
49  $fileName,
50  $mimeType
51  );
52  }
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
+ Here is the call graph for this function:

◆ getDir()

ilCertificateUtilHelper::getDir ( string  $copyDirectory)

Definition at line 118 of file ilCertificateUtilHelper.php.

References ilFileUtils\getDir().

118  : array
119  {
120  return ilFileUtils::getDir($copyDirectory);
121  }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory
+ Here is the call graph for this function:

◆ getImagePath()

ilCertificateUtilHelper::getImagePath ( string  $img,
string  $module_path = "",
string  $mode = "output",
bool  $offline = false 
)

Definition at line 158 of file ilCertificateUtilHelper.php.

References ilUtil\getImagePath().

163  : string {
164  return ilUtil::getImagePath(
165  $img,
166  $module_path,
167  $mode,
168  $offline
169  );
170  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:

◆ moveUploadedFile()

ilCertificateUtilHelper::moveUploadedFile ( string  $file,
string  $name,
string  $target,
bool  $raise_errors = true,
string  $mode = 'move_uploaded' 
)
Exceptions
ilException

Definition at line 142 of file ilCertificateUtilHelper.php.

References ilFileUtils\moveUploadedFile().

148  : bool {
150  $file,
151  $name,
152  $target,
153  $raise_errors,
154  $mode
155  );
156  }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

◆ prepareFormOutput()

ilCertificateUtilHelper::prepareFormOutput ( string  $string)

Definition at line 54 of file ilCertificateUtilHelper.php.

References ilLegacyFormElementsUtil\prepareFormOutput().

54  : string
55  {
57  }
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:

◆ stripSlashes()

ilCertificateUtilHelper::stripSlashes ( string  $string)

Definition at line 102 of file ilCertificateUtilHelper.php.

References ilUtil\stripSlashes().

102  : string
103  {
104  return ilUtil::stripSlashes($string);
105  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:

◆ unzip()

ilCertificateUtilHelper::unzip ( string  $file,
string  $zip_output_path,
bool  $overwrite 
)

Definition at line 123 of file ilCertificateUtilHelper.php.

123  : Unzip
124  {
125  return $this->archives->unzip(
126  Streams::ofResource(fopen($file, 'rb')),
127  $this->archives->unzipOptions()
128  ->withOverwrite($overwrite)
129  ->withZipOutputPath($zip_output_path)
130  ->withDirectoryHandling(ZipDirectoryHandling::KEEP_STRUCTURE)
131  );
132  }

◆ zipAndDeliver()

ilCertificateUtilHelper::zipAndDeliver ( array  $streams,
string  $download_filename 
)
Parameters
list<Streams>$streams

Definition at line 110 of file ilCertificateUtilHelper.php.

110  : void
111  {
112  $this->delivery->delivery()->attached(
113  $this->archives->zip($streams)->get(),
114  $download_filename
115  );
116  }

Field Documentation

◆ $archives

ILIAS Filesystem Util Archive Archives ilCertificateUtilHelper::$archives
private

Definition at line 34 of file ilCertificateUtilHelper.php.

◆ $delivery

ILIAS FileDelivery Services ilCertificateUtilHelper::$delivery
private

Definition at line 35 of file ilCertificateUtilHelper.php.

◆ $image_converter

ILIAS Filesystem Util Convert Images ilCertificateUtilHelper::$image_converter
private

Definition at line 33 of file ilCertificateUtilHelper.php.


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