From: Vincent Vanwaelscappel Date: Fri, 16 Feb 2024 12:44:07 +0000 (+0100) Subject: wait #6721 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f82c15448251450e84770d669c31cdeb29d4d9dd;p=fluidbook-toolbox.git wait #6721 @0.5 --- diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 84334f284..d931efe98 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -1258,10 +1258,15 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError } $res = PDF::compilePDF($this->getFluidbook()); + $this->config->pdfName = str_replace('.pdf', '', $this->config->pdfName); if (!$this->config->pdfName) { - $this->config->pdfName = 'document.pdf'; + $this->config->pdfName = '%title%'; } - $this->config->pdfName = Text::removeAccents($this->config->pdfName); + $this->config->pdfName = Text::str2URL(static::replaceVariables($this->config->pdfName), false, true); + if (!$this->config->pdfName) { + $this->config->pdfName = 'document'; + } + if (mb_strtolower(substr($this->config->pdfName, -4)) !== '.pdf') { $this->config->pdfName .= '.pdf'; } @@ -1273,6 +1278,12 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError return ''; } + protected function replaceVariables($str) + { + $replace = ['%title%' => $this->config->title]; + return strtr($str, $replace); + } + protected function addFilesInfos($key, $file) { if (!file_exists($file)) { diff --git a/app/Models/Traits/PublicationSettings.php b/app/Models/Traits/PublicationSettings.php index af787beb3..b20c1cb15 100644 --- a/app/Models/Traits/PublicationSettings.php +++ b/app/Models/Traits/PublicationSettings.php @@ -957,7 +957,7 @@ trait PublicationSettings ]); $this->addSettingField('pdfName', LongText::class, $this->__('Nom du fichier PDF'), [ 'v2' => '{"type":"text","default":"document.pdf","editable":true,"label":"\\u00a7!\\u00a7Nom du fichier PDF!\\u00a7!"}', - 'default' => 'document.pdf', + 'default' => '%title%', ]); $this->addSettingField('pdfReplace', FilesOrURL::class, $this->__('PDF de remplacement'), [ 'v2' => '{"type":"freefile","default":"","editable":true,"label":"\\u00a7!\\u00a7PDF de remplacement!\\u00a7!","grade":3,"fileFilter":{"name":"\\u00a7!\\u00a7Document PDF!\\u00a7! (*.pdf)","extensions":"*.pdf"}}',