80 string $clientID = CLIENT_ID
85 $this->logger = $logger;
99 if (
null === $certificateFileUtilsHelper) {
102 $this->fileUtilsHelper = $certificateFileUtilsHelper;
109 $this->clientId = $clientID;
129 if (!$this->fileSystem->hasDir($imagepath)) {
135 $this->uploadFile($imageTempFilename, $backgroundImageTempFilePath);
137 $backgroundImagePath = $this->certificatePath .
'background_' .
$version .
'.jpg';
139 $this->utilHelper->convertImage(
140 $backgroundImageTempFilePath,
141 $this->rootDirectory . $backgroundImagePath,
147 $this->utilHelper->convertImage(
148 $backgroundImageTempFilePath,
149 $backgroundImageThumbnailPath,
156 if (!$this->fileSystem->has($backgroundImagePath)) {
158 if (!ilUtil::moveUploadedFile($backgroundImageTempFilePath, $convert_filename, $this->rootDirectory . $backgroundImagePath)) {
159 throw new ilException(
'Unable to convert the file and the original file');
163 $this->fileSystem->delete($this->certificatePath . self::BACKGROUND_TEMPORARY_FILENAME);
165 if ($this->fileSystem->has($backgroundImagePath)) {
166 return $this->certificatePath .
'background_' .
$version .
'.jpg';
169 throw new ilException(
'The given temporary filename is empty');
179 private function uploadFile(
string $temporaryFilename,
string $targetFileName)
181 $targetFilename = basename($targetFileName);
182 $targetFilename = $this->fileUtilsHelper->getValidFilename($targetFilename);
187 if (
false === $this->fileUpload->hasBeenProcessed()) {
188 $this->fileUpload->process();
191 if (
false === $this->fileUpload->hasUploads()) {
192 throw new ilException($this->language->txt(
'upload_error_file_not_found'));
198 $uploadResults = $this->fileUpload->getResults();
199 $uploadResult = $uploadResults[$temporaryFilename];
201 $processingStatus = $uploadResult->getStatus();
202 if ($processingStatus->getCode() ===
ILIAS\FileUpload\DTO\ProcessingStatus::REJECTED) {
203 throw new ilException($processingStatus->getMessage());
206 $this->fileUpload->moveOneFileTo(
222 case strpos(
$target, $this->rootDirectory .
'/' . $this->clientId) === 0:
223 case strpos(
$target,
'./' . $this->rootDirectory .
'/' . $this->clientId) === 0:
224 case strpos(
$target, $this->rootDirectory) === 0:
227 case strpos(
$target, CLIENT_DATA_DIR .
"/temp") === 0:
230 case strpos(
$target, CLIENT_DATA_DIR) === 0:
233 case strpos(
$target, ILIAS_ABSOLUTE_PATH .
'/Customizing') === 0:
237 throw new InvalidArgumentException(
"Can not move files to \"$target\" because path can not be mapped to web, storage or customizing location.");
240 return $targetFilesystem;
249 $absTargetDir = dirname(
$target);
250 $targetDir = $this->legacyPathHelper->createRelativePath($absTargetDir);
An exception for terminatinating execution or to throw for unit testing.
getTargetDir(string $target)
const BACKGROUND_IMAGE_NAME
const BACKGROUND_TEMPORARY_FILENAME
const BACKGROUND_THUMBNAIL_IMAGE_NAME
getTargetFilesystem(string $target)
__construct(\ILIAS\FileUpload\FileUpload $fileUpload, string $certificatePath, ilLanguage $language, ilLogger $logger, \ILIAS\Filesystem\Filesystem $fileSystem=null, ilCertificateUtilHelper $utilHelper=null, ilCertificateFileUtilsHelper $certificateFileUtilsHelper=null, LegacyPathHelperHelper $legacyPathHelper=null, string $rootDirectory=CLIENT_WEB_DIR, string $clientID=CLIENT_ID)
createBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
createBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
uploadBackgroundImage(string $imageTempFilename, int $version)
Uploads a background image for the certificate.
Just a wrapper class to create Unit Test for other classes.
Base class for ILIAS Exception handling.
Component logger with individual log levels by component id.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
const TEMPORARY
The ILIAS temporary directory.
const CUSTOMIZING
The filesystem within the web root where all the skins and plugins are saved.
const WEB
The filesystem within the ilias web root.
const STORAGE
The filesystem outside of the ilias web root.
Class FlySystemFileAccessTest.