diff options
Diffstat (limited to 'src/files.php')
| -rw-r--r-- | src/files.php | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/src/files.php b/src/files.php deleted file mode 100644 index 2a68d9d..0000000 --- a/src/files.php +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/files.php | ||
| 3 | // | ||
| 4 | // fonctions pour manipuler les fichiers latex et pdf | ||
| 5 | |||
| 6 | function makeFile($path, $file_name, $data) | ||
| 7 | { | ||
| 8 | //~ if(is_writable('../' . $path)) | ||
| 9 | //~ { | ||
| 10 | file_put_contents($path. $file_name, $data); | ||
| 11 | chmod($path . $file_name, 0644); // droits en octal | ||
| 12 | //~ } | ||
| 13 | |||
| 14 | //~ protected function createFile(string $latex, string $file_name, string $latexPath) | ||
| 15 | //~ { | ||
| 16 | //~ // nom du fichier créé = nom.tex | ||
| 17 | //~ // pour les devis, factures et enveloppes, le nom est le code la prestation | ||
| 18 | //~ // pour les livre de recettes et registres des achats mensuels: | ||
| 19 | //~ // le nom du fichier suit cet exemple: "Recettes-2022-06-Juin.tex" | ||
| 20 | //~ // pour le livre de recette ou le registre des achats annuel, même principe: "Achats-2022.tex" | ||
| 21 | //~ // pour le bilan comptable annuel, ça donne: "Bilan-2022.tex" | ||
| 22 | //~ $fichier = fopen($latexPath . $file_name, "w+"); | ||
| 23 | //~ fputs($fichier, $latex); | ||
| 24 | //~ fclose($fichier); | ||
| 25 | //~ } | ||
| 26 | } | ||
| 27 | |||
| 28 | function makeFolder(string $path) | ||
| 29 | { | ||
| 30 | $rights = 0755; // droits en octal | ||
| 31 | |||
| 32 | if(!file_exists($path)) | ||
| 33 | { | ||
| 34 | //~ if(is_writable('../' . $path)) | ||
| 35 | //~ { | ||
| 36 | mkdir($path); | ||
| 37 | chmod($path, $rights); | ||
| 38 | //~ } | ||
| 39 | //~ else | ||
| 40 | //~ { | ||
| 41 | //~ echo "debug: la création du dossier " . $path . " est impossible\n"; | ||
| 42 | //~ } | ||
| 43 | } | ||
| 44 | else | ||
| 45 | { | ||
| 46 | //~ if(is_writable($path)) | ||
| 47 | //~ { | ||
| 48 | chmod($path, $rights); | ||
| 49 | //~ } | ||
| 50 | //~ else | ||
| 51 | //~ { | ||
| 52 | //~ echo "debug: la modification des droits du dossier " . $path . " est impossible\n"; | ||
| 53 | //~ } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | // commande système pdflatex | ||
| 58 | function latexToPdf(string $latex_path, string $file_name, string $pdf_path) | ||
| 59 | { | ||
| 60 | // paramètre optionnel | ||
| 61 | $output_dir = ''; | ||
| 62 | if($pdf_path !== '') | ||
| 63 | { | ||
| 64 | $output_dir = '-output-directory=' . $pdf_path; | ||
| 65 | } | ||
| 66 | |||
| 67 | // compilation | ||
| 68 | //echo 'pdflatex ' . $output_dir . ' ' . $latex_path . $file_name . "\n"; | ||
| 69 | //die; | ||
| 70 | exec('pdflatex ' . $output_dir . ' ' . $latex_path . $file_name); | ||
| 71 | |||
| 72 | // nettoyage | ||
| 73 | $basename = basename($file_name, '.tex'); | ||
| 74 | unlink($pdf_path . $basename . '.aux'); | ||
| 75 | unlink($pdf_path . $basename . '.log'); | ||
| 76 | } | ||
| 77 | |||
| 78 | // équivalent de la commande mv | ||
| 79 | function renameFiles(Object $Object, string $old_code, string $new_code) | ||
| 80 | { | ||
| 81 | rename($Object->getLatexPath() . $old_code . '.tex', | ||
| 82 | $Object->getLatexPath() . $new_code . '.tex'); | ||
| 83 | rename($Object->getPdfPath() . $old_code . '.pdf', | ||
| 84 | $Object->getPdfPath() . $new_code . '.pdf'); | ||
| 85 | } | ||
| 86 | |||
| 87 | function makeTexAndPdf(Object $Object) // paramètre = enfant de Latex | ||
| 88 | { | ||
| 89 | if(get_class($Object) !== 'EnveloppeVersoLatex') | ||
| 90 | { | ||
| 91 | makeFolder($Object->getLatexPath()); | ||
| 92 | makeFolder($Object->getPdfPath()); | ||
| 93 | } | ||
| 94 | makeFile($Object->getLatexPath(), $Object->getFileName(), $Object->getLatex()); // fichier .tex | ||
| 95 | latexToPdf($Object->getLatexPath(), $Object->getFileName(), $Object->getPdfPath()); // fichier .pdf avec pdflatex | ||
| 96 | } | ||
| 97 | |||
| 98 | //~ function removeFile(Object $Object) | ||
| 99 | //~ {} | ||
