From ad8c4b977785035013ea2f722f38409958e1793d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 18 Aug 2005 17:48:35 +0000 Subject: [PATCH] =?UTF-8?q?Perf:=20Opitmisation=20fonction=20currency=5Fna?= =?UTF-8?q?me=20(on=20=E9vite=20acc=E8s=20base=20si=20inutile).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/html.form.class.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 0436cb2873a..fa3ab2956d3 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -719,18 +719,24 @@ class Form } } - - - /** - * \brief Retourne le nom traduit ou code+nom d'une devise - * \param code_iso Code iso de la devise - * \param withcode 1=affiche code + nom - * \return string Nom traduit de la devise - */ - function currency_name($code_iso,$withcode=0) + + /** + * \brief Retourne le nom traduit ou code+nom d'une devise + * \param code_iso Code iso de la devise + * \param withcode 1=affiche code + nom + * \return string Nom traduit de la devise + */ + function currency_name($code_iso,$withcode=0) { global $langs; + // Si il existe une traduction, on peut renvoyer de suite le libellé + if ($langs->trans("Currency".$code_iso)!="Currency".$code_iso) + { + return $langs->trans("Currency".$code_iso); + } + + // Si pas de traduction, on consulte libellé par défaut en table $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " WHERE code_iso='$code_iso';"; @@ -741,7 +747,7 @@ class Form if ($num) { $obj = $this->db->fetch_object(); - $label=$langs->trans("Currency".$code_iso)!="Currency".$code_iso?$langs->trans("Currency".$code_iso):($obj->label!='-'?$obj->label:''); + $label=($obj->label!='-'?$obj->label:''); if ($withcode) return $label==$code_iso?"$code_iso":"$code_iso - $label"; else return $label; }