From 39d4558eaf5fa5fd6060a0f202b22bcec5a982dc Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 9 Oct 2026 15:09:38 +0200 Subject: =?UTF-8?q?variables=20d=C3=A9plac=C3=A9es=20dans=20Config,=20supp?= =?UTF-8?q?ressions=20constructeurs=20Latex.php,=20=C3=A9bauche=20de=20sec?= =?UTF-8?q?tion=206=5Fadvertising,=20un=20peu=20de=20typage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 57 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'src/Config.php') diff --git a/src/Config.php b/src/Config.php index 5de966f..eea90bd 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,7 +3,7 @@ class Config { - // valeurs par défaut au cas où + // valeurs par défaut au cas où static public string $business_name = 'ORDIPOLO'; static public string $business_guy = 'Paul Jusot'; static public string $business_address = "2A rue de l'île de Man"; @@ -21,24 +21,25 @@ class Config static public string $sgbd = 'sqlite'; static public string $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite static public string $date_format = 'euro'; + static public string $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance //~ static public $sqliteBin = 'lib/sqlite_linux'; //~ static public $sqliteBin = 'lib/sqlite_win.exe'; - static private $raw_data; + static private array|false $raw_data; - static public function readFile($file_path) - { - self::$raw_data = parse_ini_file($file_path); + static public function readFile(string $file_path): void + { + self::$raw_data = parse_ini_file($file_path); } - static public function hydrate() + static public function hydrate(): void { foreach(self::$raw_data as $field => $value) { if($value != '') // valeur par défaut - { + { if(isset(self::$$field)) // vérification du nom du champ { // problème du slash à la fin du nom d'un dossier @@ -55,37 +56,37 @@ class Config else { echo "debug: le fichier config.ini comporte une erreur, le champ: " . $field . " est incorrect,\nl'information contenue sur cette ligne ne sera pas utilisée\n"; - } + } } else - { - echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; + { + echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; } } } - static private function fieldIsPath($field): bool - { + static private function fieldIsPath(string $field): bool + { if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') - { - return true; + { + return true; } else - { - return false; - } + { + return false; + } } - static public function slashAtEndOfPath($path): string + static public function slashAtEndOfPath(string $path): string { if(!str_ends_with($path, '/')) { return($path . '/'); } else - { - return $path; - } + { + return $path; + } } @@ -94,21 +95,21 @@ class Config static private function adjustRelativePath($input) { // chemin windows? - + // chemin relatif ou absolu (par le 1er caractère) // obtenir l'emplacement du dossier de l'utilisateur '~' $userHomePlace = exec(''); // obtenir l'emplacement du dossier 'src' - $appExecPlace = getcwd(); + $appExecPlace = getcwd(); } //~ static public function makeDsn() - //~ { + //~ { //~ if($this->sgbd === 'sqlite') - //~ { - //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; - //~ } - //~ } + //~ { + //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; + //~ } + //~ } } -- cgit v1.2.3