From c4a3f80a6dccdff9b2abff6f159ef8fdd4382787 Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 15 Jul 2024 17:49:31 +0200 Subject: =?UTF-8?q?d=C3=A9placement=20dossier=20d'ex=C3=A9cution,=20suppre?= =?UTF-8?q?ssion=20de=20Config::checkPath,=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 45 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) (limited to 'src/Config.php') 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 static public $business_postcode = '29000'; static public $business_city = 'Quimper'; static public $db_name = "ordipolo"; - static public $db_path = '../data/'; - static public $latex_path = '../data/latex/'; - static public $pdf_path = '../data/pdf/'; - static public $pub_path = "../pub/"; + static public $db_path = 'data/'; + static public $latex_path = 'data/latex/'; + static public $pdf_path = 'data/pdf/'; + static public $pub_path = "pub/"; static public $flyer = "flyer.xcf"; static public $business_card = "carte.sla"; static public $image_editor = 'gimp'; @@ -26,8 +26,8 @@ class Config //~ static public $dsn = ''; // ç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 public $sqliteBin = 'lib/sqlite_linux'; + //~ static public $sqliteBin = 'lib/sqlite_win.exe'; static private $raw_data; @@ -44,14 +44,10 @@ class Config { if(isset(self::$$field)) // vérification du nom du champ { - // vérification du contenu - if(self::fieldIsPath($field)) // cas où le champ db_path, latex_path, pdf_path ou pub_path + // problème du slash à la fin du nom d'un dossier + if(self::fieldIsPath($field)) // pour db_path, latex_path, pdf_path et pub_path { - if(self::checkPath($field, $value)) - { - self::$$field = self::slashAtEndOfPath($value); - //self::$$field = $value; - } + self::$$field = self::slashAtEndOfPath($value); } else // tester le reste? { @@ -83,28 +79,6 @@ class Config } } - static private function checkPath($field, $value): bool - { - if(!file_exists($value)) - { - 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"; - return false; - } - if(!is_writable($value)) - { - if($value == self::$$field) - { - echo "debug: le dossier " . $value . " n'est pas autorisé en écriture\n"; - } - else - { - 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"; - } - return false; - } - return true; - } - static public function slashAtEndOfPath($path): string { if(!str_ends_with($path, '/')) @@ -117,6 +91,7 @@ class Config } } + // à faire plus tard // transformer les chemins pour qu'ils soient relatifs au dossier 'src' où s'exécute le programme static private function adjustRelativePath($input) -- cgit v1.2.3