diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-09 15:09:38 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-09 15:09:38 +0200 |
| commit | 39d4558eaf5fa5fd6060a0f202b22bcec5a982dc (patch) | |
| tree | aa3d078c4d9a12fe05602510581f7360e2afa504 /src/Config.php | |
| parent | 32f22413786763d4d128ee286cc13700e6b0446f (diff) | |
| download | AppliGestionPHP-39d4558eaf5fa5fd6060a0f202b22bcec5a982dc.tar.gz AppliGestionPHP-39d4558eaf5fa5fd6060a0f202b22bcec5a982dc.tar.bz2 AppliGestionPHP-39d4558eaf5fa5fd6060a0f202b22bcec5a982dc.zip | |
variables déplacées dans Config, suppressions constructeurs Latex.php, ébauche de section 6_advertising, un peu de typage
Diffstat (limited to 'src/Config.php')
| -rw-r--r-- | src/Config.php | 57 |
1 files changed, 29 insertions, 28 deletions
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 @@ | |||
| 3 | 3 | ||
| 4 | class Config | 4 | class Config |
| 5 | { | 5 | { |
| 6 | // valeurs par défaut au cas où | 6 | // valeurs par défaut au cas où |
| 7 | static public string $business_name = 'ORDIPOLO'; | 7 | static public string $business_name = 'ORDIPOLO'; |
| 8 | static public string $business_guy = 'Paul Jusot'; | 8 | static public string $business_guy = 'Paul Jusot'; |
| 9 | static public string $business_address = "2A rue de l'île de Man"; | 9 | static public string $business_address = "2A rue de l'île de Man"; |
| @@ -21,24 +21,25 @@ class Config | |||
| 21 | static public string $sgbd = 'sqlite'; | 21 | static public string $sgbd = 'sqlite'; |
| 22 | static public string $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite | 22 | static public string $sqlite_gui = 'sqlitebrowser'; // ne pas utiliser si le sgbd n'est pas sqlite |
| 23 | static public string $date_format = 'euro'; | 23 | static public string $date_format = 'euro'; |
| 24 | static public string $file_explorer = 'xdg-open'; // ouvre l'explorateur de fichiers par défaut quand suivi d'un chemin en paramètre | ||
| 24 | 25 | ||
| 25 | // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance | 26 | // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance |
| 26 | //~ static public $sqliteBin = 'lib/sqlite_linux'; | 27 | //~ static public $sqliteBin = 'lib/sqlite_linux'; |
| 27 | //~ static public $sqliteBin = 'lib/sqlite_win.exe'; | 28 | //~ static public $sqliteBin = 'lib/sqlite_win.exe'; |
| 28 | 29 | ||
| 29 | static private $raw_data; | 30 | static private array|false $raw_data; |
| 30 | 31 | ||
| 31 | static public function readFile($file_path) | 32 | static public function readFile(string $file_path): void |
| 32 | { | 33 | { |
| 33 | self::$raw_data = parse_ini_file($file_path); | 34 | self::$raw_data = parse_ini_file($file_path); |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | static public function hydrate() | 37 | static public function hydrate(): void |
| 37 | { | 38 | { |
| 38 | foreach(self::$raw_data as $field => $value) | 39 | foreach(self::$raw_data as $field => $value) |
| 39 | { | 40 | { |
| 40 | if($value != '') // valeur par défaut | 41 | if($value != '') // valeur par défaut |
| 41 | { | 42 | { |
| 42 | if(isset(self::$$field)) // vérification du nom du champ | 43 | if(isset(self::$$field)) // vérification du nom du champ |
| 43 | { | 44 | { |
| 44 | // problème du slash à la fin du nom d'un dossier | 45 | // problème du slash à la fin du nom d'un dossier |
| @@ -55,37 +56,37 @@ class Config | |||
| 55 | else | 56 | else |
| 56 | { | 57 | { |
| 57 | 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"; | 58 | 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"; |
| 58 | } | 59 | } |
| 59 | } | 60 | } |
| 60 | else | 61 | else |
| 61 | { | 62 | { |
| 62 | echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; | 63 | echo "debug: le champ " . $field . " est vide, la valeur par défaut " . self::$$field . " sera utilisée.\n"; |
| 63 | } | 64 | } |
| 64 | } | 65 | } |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | static private function fieldIsPath($field): bool | 68 | static private function fieldIsPath(string $field): bool |
| 68 | { | 69 | { |
| 69 | if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') | 70 | if($field === 'db_path' || $field === 'latex_path' || $field === 'pdf_path' || $field === 'pub_path') |
| 70 | { | 71 | { |
| 71 | return true; | 72 | return true; |
| 72 | } | 73 | } |
| 73 | else | 74 | else |
| 74 | { | 75 | { |
| 75 | return false; | 76 | return false; |
| 76 | } | 77 | } |
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | static public function slashAtEndOfPath($path): string | 80 | static public function slashAtEndOfPath(string $path): string |
| 80 | { | 81 | { |
| 81 | if(!str_ends_with($path, '/')) | 82 | if(!str_ends_with($path, '/')) |
| 82 | { | 83 | { |
| 83 | return($path . '/'); | 84 | return($path . '/'); |
| 84 | } | 85 | } |
| 85 | else | 86 | else |
| 86 | { | 87 | { |
| 87 | return $path; | 88 | return $path; |
| 88 | } | 89 | } |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | 92 | ||
| @@ -94,21 +95,21 @@ class Config | |||
| 94 | static private function adjustRelativePath($input) | 95 | static private function adjustRelativePath($input) |
| 95 | { | 96 | { |
| 96 | // chemin windows? | 97 | // chemin windows? |
| 97 | 98 | ||
| 98 | // chemin relatif ou absolu (par le 1er caractère) | 99 | // chemin relatif ou absolu (par le 1er caractère) |
| 99 | 100 | ||
| 100 | // obtenir l'emplacement du dossier de l'utilisateur '~' | 101 | // obtenir l'emplacement du dossier de l'utilisateur '~' |
| 101 | $userHomePlace = exec(''); | 102 | $userHomePlace = exec(''); |
| 102 | 103 | ||
| 103 | // obtenir l'emplacement du dossier 'src' | 104 | // obtenir l'emplacement du dossier 'src' |
| 104 | $appExecPlace = getcwd(); | 105 | $appExecPlace = getcwd(); |
| 105 | } | 106 | } |
| 106 | 107 | ||
| 107 | //~ static public function makeDsn() | 108 | //~ static public function makeDsn() |
| 108 | //~ { | 109 | //~ { |
| 109 | //~ if($this->sgbd === 'sqlite') | 110 | //~ if($this->sgbd === 'sqlite') |
| 110 | //~ { | 111 | //~ { |
| 111 | //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; | 112 | //~ $this->dsn = 'sqlite:' . $this->db_name . '.sqlite'; |
| 112 | //~ } | 113 | //~ } |
| 113 | //~ } | 114 | //~ } |
| 114 | } | 115 | } |
