diff options
| author | polo <ordipolo@gmx.fr> | 2024-07-15 17:49:31 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-07-15 17:49:31 +0200 |
| commit | c4a3f80a6dccdff9b2abff6f159ef8fdd4382787 (patch) | |
| tree | 000a98fcff60aba9cd0784f181c0ac4a4056a2c4 /src/Config.php | |
| parent | 14f68d7d93cd6e498a7d15cf5ce5b227ed0683a7 (diff) | |
| download | AppliGestionPHP-c4a3f80a6dccdff9b2abff6f159ef8fdd4382787.tar.gz AppliGestionPHP-c4a3f80a6dccdff9b2abff6f159ef8fdd4382787.tar.bz2 AppliGestionPHP-c4a3f80a6dccdff9b2abff6f159ef8fdd4382787.zip | |
déplacement dossier d'exécution, suppression de Config::checkPath, bugs
Diffstat (limited to 'src/Config.php')
| -rw-r--r-- | src/Config.php | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/src/Config.php b/src/Config.php index b4f8e5b..16aa8ed 100644 --- a/src/Config.php +++ b/src/Config.php | |||
| @@ -10,10 +10,10 @@ class Config | |||
| 10 | static public $business_postcode = '29000'; | 10 | static public $business_postcode = '29000'; |
| 11 | static public $business_city = 'Quimper'; | 11 | static public $business_city = 'Quimper'; |
| 12 | static public $db_name = "ordipolo"; | 12 | static public $db_name = "ordipolo"; |
| 13 | static public $db_path = '../data/'; | 13 | static public $db_path = 'data/'; |
| 14 | static public $latex_path = '../data/latex/'; | 14 | static public $latex_path = 'data/latex/'; |
| 15 | static public $pdf_path = '../data/pdf/'; | 15 | static public $pdf_path = 'data/pdf/'; |
| 16 | static public $pub_path = "../pub/"; | 16 | static public $pub_path = "pub/"; |
| 17 | static public $flyer = "flyer.xcf"; | 17 | static public $flyer = "flyer.xcf"; |
| 18 | static public $business_card = "carte.sla"; | 18 | static public $business_card = "carte.sla"; |
| 19 | static public $image_editor = 'gimp'; | 19 | static public $image_editor = 'gimp'; |
| @@ -26,8 +26,8 @@ class Config | |||
| 26 | //~ static public $dsn = ''; | 26 | //~ static public $dsn = ''; |
| 27 | 27 | ||
| 28 | // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance | 28 | // ça pourrait être bien de founir sqlite avec l'application pour supprimer une dépendance |
| 29 | //~ static public $sqliteBin = '../lib/sqlite_linux'; | 29 | //~ static public $sqliteBin = 'lib/sqlite_linux'; |
| 30 | //~ static public $sqliteBin = '../lib/sqlite_win.exe'; | 30 | //~ static public $sqliteBin = 'lib/sqlite_win.exe'; |
| 31 | 31 | ||
| 32 | static private $raw_data; | 32 | static private $raw_data; |
| 33 | 33 | ||
| @@ -44,14 +44,10 @@ class Config | |||
| 44 | { | 44 | { |
| 45 | if(isset(self::$$field)) // vérification du nom du champ | 45 | if(isset(self::$$field)) // vérification du nom du champ |
| 46 | { | 46 | { |
| 47 | // vérification du contenu | 47 | // problème du slash à la fin du nom d'un dossier |
| 48 | if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path | 48 | if(self::fieldIsPath($field)) // pour db_path, latex_path, pdf_path et pub_path |
| 49 | { | 49 | { |
| 50 | if(self::checkPath($field, $value)) | 50 | self::$$field = self::slashAtEndOfPath($value); |
| 51 | { | ||
| 52 | self::$$field = self::slashAtEndOfPath($value); | ||
| 53 | //self::$$field = $value; | ||
| 54 | } | ||
| 55 | } | 51 | } |
| 56 | else // tester le reste? | 52 | else // tester le reste? |
| 57 | { | 53 | { |
| @@ -83,28 +79,6 @@ class Config | |||
| 83 | } | 79 | } |
| 84 | } | 80 | } |
| 85 | 81 | ||
| 86 | static private function checkPath($field, $value): bool | ||
| 87 | { | ||
| 88 | if(!file_exists($value)) | ||
| 89 | { | ||
| 90 | echo "debug: le fichier config.ini comporte une erreur, le dossier " . $value . " renseigné pour le champ " . $field . " n'existe pas,\nla valeur par défaut: " . self::$$field . " sera utilisé\n"; | ||
| 91 | return false; | ||
| 92 | } | ||
| 93 | if(!is_writable($value)) | ||
| 94 | { | ||
| 95 | if($value == self::$$field) | ||
| 96 | { | ||
| 97 | echo "debug: le dossier " . $value . " n'est pas autorisé en écriture\n"; | ||
| 98 | } | ||
| 99 | else | ||
| 100 | { | ||
| 101 | echo "debug: le dossier " . $value . " renseigné pour le champ " . $field . " dans le fichier config.ini n'est pas autorisé en écriture,\nla valeur par défaut: " . self::$$field . " sera utilisée\n"; | ||
| 102 | } | ||
| 103 | return false; | ||
| 104 | } | ||
| 105 | return true; | ||
| 106 | } | ||
| 107 | |||
| 108 | static public function slashAtEndOfPath($path): string | 82 | static public function slashAtEndOfPath($path): string |
| 109 | { | 83 | { |
| 110 | if(!str_ends_with($path, '/')) | 84 | if(!str_ends_with($path, '/')) |
| @@ -117,6 +91,7 @@ class Config | |||
| 117 | } | 91 | } |
| 118 | } | 92 | } |
| 119 | 93 | ||
| 94 | |||
| 120 | // à faire plus tard | 95 | // à faire plus tard |
| 121 | // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme | 96 | // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme |
| 122 | static private function adjustRelativePath($input) | 97 | static private function adjustRelativePath($input) |
