summaryrefslogtreecommitdiff
path: root/src/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/functions.php')
-rw-r--r--src/functions.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/functions.php b/src/functions.php
new file mode 100644
index 0000000..d67a05e
--- /dev/null
+++ b/src/functions.php
@@ -0,0 +1,51 @@
1<?php
2// php/functions.php
3//
4// gros fourre-tout, il faudra le ranger plus tard
5
6
7// commande pour lancer une application graphique en ouvrant un fichier
8function window_app_command(string $app, string $path = ''): string
9{
10 // attention, la syntaxe utilisée est la plus simple: "app fichier"
11 // ça fonctionne avec les logiciels choisis: gimp, scribus
12 // mais ça pourrait ne pas convenir
13
14 $command = 'nohup ' . $app; // détache l'appli du script PHP
15 if($path !== '')
16 {
17 $command .= ' ' . $path;
18 }
19 $command .= ' > /dev/null 2>&1 &';
20 // stdout > /dev/null et & permettent de rendre la main à PHP
21 // stderr > stdout pour cacher un message inutile
22 return $command;
23}
24
25function recherche_client(string $saisie): array
26{
27 $resultats = [];
28
29 // recherche dans la BDD
30
31
32 return($resultats);
33}
34
35// compilation à partir d'un fichier .tex
36function latexToPdf(string $fileName, string $latexPath, string $pdfPath)
37{
38 $outputDir = '';
39 if($pdfPath !== '')
40 {
41 $outputDir = '-output-directory=' . $pdfPath . ' ';
42 }
43
44 // compilation
45 exec('pdflatex ' . $outputDir . $latexPath . $fileName);
46
47 // nettoyage
48 $basename = basename($fileName, '.tex');
49 unlink($pdfPath . $basename . '.aux');
50 unlink($pdfPath . $basename . '.log');
51}