84        if (
null === $database) {
 
   86            $database = 
$DIC->database();
 
  122    public function import(
 
  125        string $rootDir = CLIENT_WEB_DIR,
 
  134            $this->filesystem->deleteDir($importPath);
 
  138        $this->utilHelper->unzip(
 
  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);
 
  267        $type = $this->objectHelper->lookupType($this->objectId);
 
  270        $dir = $this->certificatePath . time() . 
'__' . 
$installationID . 
'__' . 
$type . 
'__' . $certificateId . 
'__certificate/';
 
  271        $this->filesystem->createDir($dir);
 
  284            array($rootDir, 
'//'),
 
  285            array(
'[CLIENT_WEB_DIR]', 
'/'),
 
  295        return $this->certificatePath . 
'background.jpg.thumb.jpg';
 
An exception for terminatinating execution or to throw for unit testing.
getBackgroundImageDirectory(string $rootDir)
__construct(int $objectId, string $certificatePath, ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilLogger $logger, Filesystem $filesystem, ilCertificateTemplateRepository $templateRepository=null, ilCertificateObjectHelper $objectHelper=null, ilCertificateUtilHelper $utilHelper=null, ilDBInterface $database=null)
getBackgroundImageThumbnailPath()
createArchiveDirectory(string $installationID)
Creates a directory for a zip archive containing multiple certificates.
$placeholderDescriptionObject
Just a wrapper class to create Unit Test for other classes.
Component logger with individual log levels by component id.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
const ILIAS_VERSION_NUMERIC
Class FlySystemFileAccessTest.
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.