90 if (null === $database) {
92 $database = $DIC->database();
136 public function import(
139 string $rootDir = CLIENT_WEB_DIR,
145 $result = $this->utilHelper->moveUploadedFile($zipFile, $filename, $rootDir . $importPath . $filename);
148 $this->filesystem->deleteDir($importPath);
152 $this->utilHelper->unzip(
153 $rootDir . $importPath . $filename,
157 $subDirectoryName = str_replace(
'.zip',
'', strtolower($filename)) .
'/';
158 $subDirectoryAbsolutePath = $rootDir . $importPath . $subDirectoryName;
160 $copyDirectory = $importPath;
161 if (is_dir($subDirectoryAbsolutePath)) {
162 $copyDirectory = $subDirectoryAbsolutePath;
165 $directoryInformation = $this->utilHelper->getDir($copyDirectory);
168 foreach ($directoryInformation as $file) {
169 if (strcmp($file[
'type'],
'file') == 0) {
170 if (strpos($file[
'entry'],
'.xml') !==
false) {
176 if (0 === $xmlFiles) {
177 $this->filesystem->deleteDir($importPath);
181 $certificate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
183 $currentVersion = (int) $certificate->getVersion();
184 $newVersion = $currentVersion + 1;
185 $backgroundImagePath = $certificate->getBackgroundImagePath();
186 $cardThumbnailImagePath = $certificate->getThumbnailImagePath();
188 $xsl = $certificate->getCertificateContent();
190 foreach ($directoryInformation as $file) {
191 if (strcmp($file[
'type'],
'file') == 0) {
192 $filePath = $importPath . $subDirectoryName . $file[
'entry'];
193 if (strpos($file[
'entry'],
'.xml') !==
false) {
194 $xsl = $this->filesystem->read($filePath);
197 $xsl = preg_replace_callback(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
function (array $matches) use ($rootDir) {
198 $basePath = rtrim(dirname($this->fileService->getBackgroundImageDirectory($rootDir)),
'/');
199 $fileName = basename($matches[1]);
201 if (
'[BACKGROUND_IMAGE]' === $fileName) {
203 } elseif (strlen($basePath) > 0) {
207 return 'url(' . $basePath . $fileName .
')';
209 } elseif (strpos($file[
'entry'],
'.jpg') !==
false) {
210 $newBackgroundImageName =
'background_' . $newVersion .
'.jpg';
211 $newPath = $this->certificatePath . $newBackgroundImageName;
212 $this->filesystem->copy($filePath, $newPath);
214 $backgroundImagePath = $this->certificatePath . $newBackgroundImageName;
219 $thumbnailImagePath = $rootDir . $backgroundImageThumbPath;
221 $originalImagePath = $rootDir . $newPath;
222 $this->utilHelper->convertImage(
228 } elseif (strpos($file[
'entry'],
'.svg') !==
false) {
229 $newCardThumbnailName =
'thumbnail_' . $newVersion .
'.svg';
230 $newPath = $this->certificatePath . $newCardThumbnailName;
232 $this->filesystem->copy($filePath, $newPath);
234 $cardThumbnailImagePath = $this->certificatePath . $newCardThumbnailName;
239 $jsonEncodedTemplateValues = json_encode($this->placeholderDescriptionObject->getPlaceholderDescriptions());
241 $newHashValue =
hash(
245 $backgroundImagePath,
246 $jsonEncodedTemplateValues,
247 $cardThumbnailImagePath
253 $this->objectHelper->lookupType($this->objectId),
256 $jsonEncodedTemplateValues,
261 $backgroundImagePath,
262 $cardThumbnailImagePath
265 $this->templateRepository->save($template);
267 $this->utilHelper->delDir($importPath);
281 $type = $this->objectHelper->lookupType($this->objectId);
284 $dir = $this->certificatePath . time() .
'__' . $installationID .
'__' .
$type .
'__' . $certificateId .
'__certificate/';
285 $this->filesystem->createDir($dir);
296 return $this->certificatePath .
'background.jpg.thumb.jpg';
__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)
const ILIAS_VERSION_NUMERIC
$placeholderDescriptionObject
getBackgroundImageThumbnailPath()
Just a wrapper class to create Unit Test for other classes.
Component logger with individual log levels by component id.
Class FlySystemFileAccessTest.
createArchiveDirectory(string $installationID)
Creates a directory for a zip archive containing multiple certificates.