134 $this->filesystem->deleteDir($importPath);
138 $this->utilHelper->unzip(
139 $rootDir . $importPath . $filename,
143 $subDirectoryName = str_replace(
'.zip',
'', strtolower($filename)) .
'/';
144 $subDirectoryAbsolutePath = $rootDir . $importPath . $subDirectoryName;
146 $copyDirectory = $importPath;
147 if (is_dir($subDirectoryAbsolutePath)) {
148 $copyDirectory = $subDirectoryAbsolutePath;
151 $directoryInformation = $this->utilHelper->getDir($copyDirectory);
154 foreach ($directoryInformation as $file) {
155 if (strcmp($file[
'type'],
'file') == 0) {
156 if (strpos($file[
'entry'],
'.xml') !==
false) {
162 if (0 === $xmlFiles) {
163 $this->filesystem->deleteDir($importPath);
167 $certificate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
170 $newVersion = $currentVersion + 1;
171 $backgroundImagePath =
$certificate->getBackgroundImagePath();
172 $cardThumbnailImagePath =
$certificate->getThumbnailImagePath();
176 foreach ($directoryInformation as $file) {
177 if (strcmp($file[
'type'],
'file') == 0) {
178 $filePath = $importPath . $subDirectoryName . $file[
'entry'];
179 if (strpos($file[
'entry'],
'.xml') !==
false) {
180 $xsl = $this->filesystem->read($filePath);
183 $xsl = preg_replace_callback(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
function (array $matches) use ($rootDir) {
185 $fileName = basename($matches[1]);
187 if (
'[BACKGROUND_IMAGE]' === $fileName) {
189 } elseif (strlen($basePath) > 0) {
193 return 'url(' . $basePath . $fileName .
')';
195 } elseif (strpos($file[
'entry'],
'.jpg') !==
false) {
196 $newBackgroundImageName =
'background_' . $newVersion .
'.jpg';
197 $newPath = $this->certificatePath . $newBackgroundImageName;
198 $this->filesystem->copy($filePath, $newPath);
200 $backgroundImagePath = $this->certificatePath . $newBackgroundImageName;
205 $thumbnailImagePath = $rootDir . $backgroundImageThumbPath;
207 $originalImagePath = $rootDir . $newPath;
208 $this->utilHelper->convertImage(
214 } elseif (strpos($file[
'entry'],
'.svg') !==
false) {
215 $newCardThumbnailName =
'thumbnail_' . $newVersion .
'.svg';
216 $newPath = $this->certificatePath . $newCardThumbnailName;
218 $this->filesystem->copy($filePath, $newPath);
220 $cardThumbnailImagePath = $this->certificatePath . $newCardThumbnailName;
225 $jsonEncodedTemplateValues = json_encode($this->placeholderDescriptionObject->getPlaceholderDescriptions());
227 $newHashValue =
hash(
231 $backgroundImagePath,
232 $jsonEncodedTemplateValues,
233 $cardThumbnailImagePath
239 $this->objectHelper->lookupType($this->objectId),
242 $jsonEncodedTemplateValues,
247 $backgroundImagePath,
248 $cardThumbnailImagePath
251 $this->templateRepository->save(
$template);
253 $this->utilHelper->delDir($importPath);
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
getBackgroundImageThumbnailPath()
getBackgroundImageDirectory(string $rootDir)
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
createArchiveDirectory(string $installationID)
Creates a directory for a zip archive containing multiple certificates.