From eb55afc103d315775f01adb7f2b4d0934175e170 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 25 Jul 2019 21:24:44 +0200 Subject: [PATCH] fixup! fixup! Code cleaning : split database into database (for noalyss) and databasecore , with the functions --- include/class/database.class.php | 21 +++++++++++++++++ include/lib/database_core.class.php | 36 ++++++----------------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/include/class/database.class.php b/include/class/database.class.php index eed0e60f5..71dce9ccc 100644 --- a/include/class/database.class.php +++ b/include/class/database.class.php @@ -222,4 +222,25 @@ class Database extends DatabaseCore echo ''; } + /** + * return the name of the database with the domain name + * @param $p_id of the folder WITHOUT the domain name + * @param $p_type dos for folder mod for template + * @return formatted name + */ + function format_name($p_id, $p_type) + { + switch ($p_type) { + case 'dos': + $sys_name = sprintf("%sdossier%d", strtolower(domaine), $p_id); + break; + case 'mod': + $sys_name = sprintf("%smod%d", strtolower(domaine), $p_id); + break; + default: + echo_error(__FILE__ . " format_name invalid type " . $p_type, __LINE__); + throw new Exception(__FILE__ . " format_name invalid type " . $p_type . __LINE__); + } + return $sys_name; + } } \ No newline at end of file diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index 2b3bd9e8e..aa0aa5999 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -57,17 +57,16 @@ class DatabaseCore if ($this->db == false) { if (DEBUG) { - echo '

Impossible de se connecter à postgreSql !

'; + echo '

'._('Impossible de se connecter à postgreSql').'

'; echo '

'; - echo "Vos paramètres sont incorrectes :
"; + echo _("Vos paramètres sont incorrectes").":
"; echo "
"; - echo "base de donnée : $p_dbname
"; - echo "Port $p_port
"; - echo "Utilisateur : $p_user
"; + printf (_("base de donnée = %s"), $p_dbname)."
"; + printf (_("Port %s"),$p_port )."
"; + printf ( _("Utilisateur : %s"),$p_user )."
"; echo '

'; - die("Connection impossible : vérifiez vos paramètres de base - de données"); + die(); } else { echo '

' . _('Erreur de connexion !') . '

'; $this->is_open = false; @@ -462,7 +461,7 @@ class DatabaseCore $array = $this->get_array($p_sql, $p_array); if (empty($array)) return null; if (count($array) == 1) return $array[0]; - throw new Exception("Database:get_row retourne trop de lignes", 100); + throw new Exception(_("Database:get_row retourne trop de lignes"), 100); } /** @@ -521,27 +520,6 @@ class DatabaseCore return false; } - /** - * return the name of the database with the domain name - * @param $p_id of the folder WITHOUT the domain name - * @param $p_type dos for folder mod for template - * @return formatted name - */ - function format_name($p_id, $p_type) - { - switch ($p_type) { - case 'dos': - $sys_name = sprintf("%sdossier%d", strtolower(domaine), $p_id); - break; - case 'mod': - $sys_name = sprintf("%smod%d", strtolower(domaine), $p_id); - break; - default: - echo_error(__FILE__ . " format_name invalid type " . $p_type, __LINE__); - throw new Exception(__FILE__ . " format_name invalid type " . $p_type . __LINE__); - } - return $sys_name; - } /** * Count the database name in a system view