19 declare(strict_types=1);
44 string $certificatePath,
58 if (null === $database) {
60 $database = $DIC->database();
67 if (null === $templateRepository) {
72 if (null === $objectHelper) {
77 if (null === $utilHelper) {
82 if (null === $fileService) {
104 public function import(
113 $result = $this->utilHelper->moveUploadedFile($zipFile, $filename, $rootDir . $importPath . $filename);
120 $this->utilHelper->unzip(
121 $rootDir . $importPath . $filename,
125 $subDirectoryName = str_replace(
'.zip',
'', strtolower($filename)) .
'/';
126 $subDirectoryAbsolutePath = $rootDir . $importPath . $subDirectoryName;
128 $copyDirectory = $importPath;
129 if (is_dir($subDirectoryAbsolutePath)) {
130 $copyDirectory = $subDirectoryAbsolutePath;
133 $directoryInformation = $this->utilHelper->getDir($copyDirectory);
136 foreach ($directoryInformation as $file) {
137 if (strcmp($file[
'type'],
'file') === 0 && strpos($file[
'entry'],
'.xml') !==
false) {
142 if (0 === $xmlFiles) {
147 $certificate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
149 $currentVersion = $certificate->getVersion();
150 $newVersion = $currentVersion + 1;
151 $backgroundImagePath = $certificate->getBackgroundImagePath();
152 $cardThumbnailImagePath = $certificate->getThumbnailImagePath();
154 $xsl = $certificate->getCertificateContent();
156 foreach ($directoryInformation as $file) {
157 if (strcmp($file[
'type'],
'file') === 0) {
158 $filePath = $importPath . $subDirectoryName . $file[
'entry'];
159 if (strpos($file[
'entry'],
'.xml') !==
false) {
163 $xsl = preg_replace_callback(
164 "/url\([']{0,1}(.*?)[']{0,1}\)/",
165 function (array $matches) use ($rootDir):
string {
166 $basePath = rtrim(dirname($this->fileService->getBackgroundImageDirectory($rootDir)),
'/');
167 $fileName = basename($matches[1]);
169 if (
'[BACKGROUND_IMAGE]' === $fileName) {
171 } elseif ($basePath !==
'') {
175 return 'url(' . $basePath . $fileName .
')';
179 } elseif (strpos($file[
'entry'],
'.jpg') !==
false) {
180 $newBackgroundImageName =
'background_' . $newVersion .
'.jpg';
181 $newPath = $this->certificatePath . $newBackgroundImageName;
184 $backgroundImagePath = $this->certificatePath . $newBackgroundImageName;
189 $thumbnailImagePath = $rootDir . $backgroundImageThumbPath;
191 $originalImagePath = $rootDir . $newPath;
192 $this->utilHelper->convertImage(
198 } elseif (strpos($file[
'entry'],
'.svg') !==
false) {
199 $newCardThumbnailName =
'thumbnail_' . $newVersion .
'.svg';
200 $newPath = $this->certificatePath . $newCardThumbnailName;
204 $cardThumbnailImagePath = $this->certificatePath . $newCardThumbnailName;
209 $jsonEncodedTemplateValues = json_encode(
210 $this->placeholderDescriptionObject->getPlaceholderDescriptions(),
214 $newHashValue =
hash(
218 $backgroundImagePath,
219 $jsonEncodedTemplateValues,
220 $cardThumbnailImagePath
226 $this->objectHelper->lookupType($this->objectId),
229 $jsonEncodedTemplateValues,
234 $backgroundImagePath,
235 $cardThumbnailImagePath
238 $this->templateRepository->save($template);
253 $type = $this->objectHelper->lookupType($this->objectId);
256 $dir = $this->certificatePath . time() .
'__' . $installationID .
'__' .
$type .
'__' . $certificateId .
'__certificate/';
264 return $this->certificatePath .
'background.jpg.thumb.jpg';
const ILIAS_VERSION_NUMERIC
ilCertificateUtilHelper $utilHelper
ilCertificateObjectHelper $objectHelper
ilCertificateTemplateRepository $templateRepository
getBackgroundImageThumbnailPath()
ilCertificateBackgroundImageFileService $fileService
Just a wrapper class to create Unit Test for other classes.
__construct(int $objectId, string $certificatePath, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilLogger $logger, Filesystem $filesystem, ?ilCertificateTemplateRepository $templateRepository=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilDBInterface $database=null, ?ilCertificateBackgroundImageFileService $fileService=null)
ilCertificatePlaceholderDescription $placeholderDescriptionObject
Class FlySystemFileAccessTest disabled disabled disabled.
createArchiveDirectory(string $installationID)
Creates a directory for a zip archive containing multiple certificates.