26 require_once
'./Services/Object/classes/class.ilObject.php';
73 $this->cert_logger = $DIC->logger()->cert();
74 $this->uuidFactory =
new Factory();
75 $this->certificateSettings =
new ilSetting(
'certificate');
91 if (!empty($imageTempFileName)) {
93 $newImageFileName =
"background_{$this->uuidFactory->uuid4AsString()}.jpg";
94 $newImagePath = $imagePath . $newImageFileName;
96 if (!file_exists($imagePath)) {
105 $this->cert_logger->error(sprintf(
106 "Could not upload certificate background image from '%s' to temporary file '%s' (name: '%s')",
127 if (!is_file($newImagePath) || !file_exists($newImagePath)) {
129 $this->cert_logger->error(sprintf(
130 "Could not convert certificate background image from '%s' as JPEG to '%s', trying fallbacj ...",
138 $this->cert_logger->error(sprintf(
139 "Could not upload certificate background image from '%s' to final file '%s' (name: '%s')",
155 if (file_exists($newImagePath) && (filesize($newImagePath) > 0)) {
160 $this->certificateSettings->set(
'defaultImageFileName', $newImageFileName);
163 $this->certificateRepo->updateDefaultBackgroundImagePaths($oldRelativePath, $newRelativePath);
166 !$this->certificateRepo->isBackgroundImageUsed($oldRelativePath)
167 && !$this->userCertificateRepo->isBackgroundImageUsed($oldRelativePath)
169 if (is_file($oldPath) && file_exists($oldPath)) {
173 if (is_file($oldPathThumb) && file_exists($oldPathThumb)) {
174 unlink($oldPathThumb);
182 $this->cert_logger->error(sprintf(
183 "Final background image '%s' does not exist or is empty",
202 $this->certificateSettings->get(
'defaultImageFileName',
'')
219 $this->certificateSettings->set(
'defaultImageFileName',
'');
226 return ($relativePath ?
'' :
CLIENT_WEB_DIR) .
'/certificates/default/';
237 . $this->certificateSettings->get(
'defaultImageFileName',
'');
266 return is_file($filePath) && filesize($filePath) > 0;
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getDefaultBackgroundImageThumbPath(bool $relativePath=false)
Returns the filesystem path of the background image thumbnail.
getBackgroundImageDefaultFolder(bool $relativePath=false)
getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
const BACKGROUND_THUMBNAIL_FILE_ENDING
__construct($a_id=0, $a_reference=true)
Constructor public.
Class ilObjCertificateSettings.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
uploadBackgroundImage(string $imageTempFileName)
Uploads a background image for the certificate.
getDefaultBackgroundImageTempFilePath()
Returns the filesystem path of the background image temp file during upload.
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static removeTrailingPathSeparators($path)
getDefaultBackgroundImagePathWeb()
Returns the web path of the background image.
deleteBackgroundImage()
Deletes the background image of a certificate.
getDefaultBackgroundImagePath(bool $relativePath=false)
Returns the filesystem path of the background image.
const BACKGROUND_TEMPORARY_UPLOAD_FILE_NAME
__construct(Container $dic, ilPlugin $plugin)