]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6721 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 16 Feb 2024 12:44:07 +0000 (13:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 16 Feb 2024 12:44:07 +0000 (13:44 +0100)
app/Fluidbook/Compiler/Compiler.php
app/Models/Traits/PublicationSettings.php

index 84334f2841a772ac4a13b224a32c2f0ec3b2f4b4..d931efe9813d81738a941cf5e6986d41fb0ecad3 100644 (file)
@@ -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)) {
index af787beb349b02d315b0e39850a9b6ca6fc226e7..b20c1cb150cb62882db7e6e935bb207567ad355b 100644 (file)
@@ -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"}}',