summaryrefslogtreecommitdiff
path: root/src/File.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-12 21:42:42 +0200
committerpolo <ordipolo@gmx.fr>2026-10-12 21:42:42 +0200
commit63365247e23c206bc9eea63a224447543f1ec9b5 (patch)
treea6f8ab1098b4336ee08d199c821563fcfb15c09d /src/File.php
parent084264d336fa9156e1b26196d3936eb3cf2c9782 (diff)
downloadAppliGestionPHP-63365247e23c206bc9eea63a224447543f1ec9b5.tar.gz
AppliGestionPHP-63365247e23c206bc9eea63a224447543f1ec9b5.tar.bz2
AppliGestionPHP-63365247e23c206bc9eea63a224447543f1ec9b5.zip
préparation date bulletin de paie des CESU, relecture
Diffstat (limited to 'src/File.php')
-rw-r--r--src/File.php101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/File.php b/src/File.php
new file mode 100644
index 0000000..660a2e1
--- /dev/null
+++ b/src/File.php
@@ -0,0 +1,101 @@
1<?php
2// src/File.php
3//
4// manipulations des fichiers
5
6class File
7{
8 private $file_name = '';
9 private $path = '';
10 private $data = ''; // écriture de binaire (blob) non prévue
11 private $file_rights = 0644;
12 private $folder_rights = 0755; // droits en octal
13 private $write_mod = 0; // 0 = écraser, 1 = ajouter à la suite, 2 = nouveau fichier
14
15
16 public function __construct(string $file_name, string $path)
17 {
18 $this->file_name = $file_name;
19 $this->path = $path;
20 }
21
22 // getters
23 public function getData(): string
24 {
25 return $this->data;
26 }
27
28 // setters
29 public function setFileName($file_name)
30 {
31 $this->file_name = $file_name;
32 }
33
34 public function setPath($path)
35 {
36 $this->path = $path;
37 }
38
39 public function setData($data)
40 {
41 $this->data = $data;
42 }
43
44 public function setFileRights(int $octal)
45 {
46 $this->file_rights($octal);
47 }
48 public function setFolderRights(int $octal)
49 {
50 $this->folder_rights($octal);
51 }
52
53 public function setWriteMod(int $mod)
54 {
55 $this->write_mod = $mod;
56 }
57
58
59 // fichiers
60 public function readFile(): string
61 {}
62
63 public function writeFile()
64 {
65 file_put_contents($this->path. $this->file_name, $data);
66 chmod($this->path, $this->file_rights);
67 }
68
69
70 // dossiers
71 public function makeFolder()
72 {
73 if(!file_exists($this->path))
74 {
75 mkdir($this->path);
76 chmod($this->path, $this->folder_rights);
77 }
78 }
79}
80
81// compilation à partir d'un fichier .tex
82class latexToPdf extends File
83{
84 public function __construct(string $latex_path, string $file_name, string $pdf_path)
85 {}
86
87 $output_dir = '';
88 if($pdf_path !== '')
89 {
90 $output_dir = '-output-directory=' . $pdf_path . ' ';
91 }
92
93 // compilation
94 //echo 'pdflatex ' . $output_dir . $latex_path . $file_name . "\n";
95 exec('pdflatex ' . $output_dir . $latex_path . $file_name);
96
97 // nettoyage
98 $basename = basename($file_name, '.tex');
99 unlink($pdf_path . $basename . '.aux');
100 unlink($pdf_path . $basename . '.log');
101}