From 983384a9be62eb694a8e1cf640685973c2a23ec2 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 18 Oct 2026 12:19:52 +0200 Subject: =?UTF-8?q?nouveau=20File.php,=20suppression=20de=20files.php,=20c?= =?UTF-8?q?ontenu=20d=C3=A9plac=C3=A9=20dans=20Latex.php=20et=20File.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Latex.php | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/Latex.php') diff --git a/src/Latex.php b/src/Latex.php index f49fdea..c638264 100644 --- a/src/Latex.php +++ b/src/Latex.php @@ -57,6 +57,36 @@ abstract class Latex // puis la mémoire est libérée à la fin de la fonction // le PHP inséré fait donc partie de cette "mémoire" } + + public function makeTexAndPdf(): void // document polymorphe + { + if(get_class($this) !== 'EnveloppeVersoLatex') + { + File::makeFolder($this->latex_path); + File::makeFolder($this->pdf_path); + } + File::makeFile($this->latex_path, $this->file_name, $this->latex); // fichier .tex + $this->latexToPdf(); + } + + // commande système pdflatex + private function latexToPdf(): void + { + // paramètre optionnel + $output_dir = ''; + if($this->pdf_path !== '') + { + $output_dir = '-output-directory=' . $this->pdf_path; + } + + // compilation + exec('pdflatex ' . $output_dir . ' ' . $this->latex_path . $this->file_name); + + // nettoyage + $basename = basename($this->file_name, '.tex'); + unlink($this->pdf_path . $basename . '.aux'); + unlink($this->pdf_path . $basename . '.log'); + } // getters public function getFileName(): string @@ -109,8 +139,8 @@ abstract class PrestaLatex extends Latex { $this->file_name = $Object->getCodePresta() . '.tex'; $this->date_array = explode('-', $Object->getdate()); - $this->latex_path = Config::$latex_path . $this->date_array[0] . '/'; - $this->pdf_path = Config::$pdf_path . $this->date_array[0] . '/'; + $this->latex_path = Config::$latex_path . $this->date_array[0] . DIRECTORY_SEPARATOR; + $this->pdf_path = Config::$pdf_path . $this->date_array[0] . DIRECTORY_SEPARATOR; } return $this; // pour chainer les méthodes -- cgit v1.2.3