summaryrefslogtreecommitdiff
path: root/src/functions.php
blob: d67a05e2b4d89447964957148107a9b930b3fb1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
// php/functions.php
//
// gros fourre-tout, il faudra le ranger plus tard


// commande pour lancer une application graphique en ouvrant un fichier
function window_app_command(string $app, string $path = ''): string
{
	// attention, la syntaxe utilisée est la plus simple: "app fichier"
	// ça fonctionne avec les logiciels choisis: gimp, scribus
	// mais ça pourrait ne pas convenir
	
	$command = 'nohup ' . $app; // détache l'appli du script PHP
	if($path !== '')
	{
		$command .= ' ' . $path;
	}
	$command .= ' > /dev/null 2>&1 &';
	// stdout > /dev/null et & permettent de rendre la main à PHP
	// stderr > stdout pour cacher un message inutile
	return $command;
}

function recherche_client(string $saisie): array
{
	$resultats = [];
	
	// recherche dans la BDD
	
	
	return($resultats);
}

// compilation à partir d'un fichier .tex
function latexToPdf(string $fileName, string $latexPath, string $pdfPath)
{
    $outputDir = '';
    if($pdfPath !== '')
    {
        $outputDir = '-output-directory=' . $pdfPath . ' ';
    }
    
    // compilation
    exec('pdflatex ' . $outputDir . $latexPath . $fileName);

    // nettoyage
    $basename = basename($fileName, '.tex');
    unlink($pdfPath . $basename . '.aux');
    unlink($pdfPath . $basename . '.log');
}