From df6c796413b94642d487a18529c72913a1dd68ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 May 2013 17:09:48 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20[=20bug=20#889=20]=20Titre=20civilit?= =?UTF-8?q?=C3=A9=20ne=20s'affiche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/adherents/class/adherent.class.php | 10 ++++------ htdocs/contact/class/contact.class.php | 6 +++--- htdocs/core/class/translate.class.php | 8 +++++--- htdocs/core/lib/functions.lib.php | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0f2b92622c0..e97a09559af 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1493,19 +1493,17 @@ class Adherent extends CommonObject /** - * Return civility label of a contact + * Return civility label of a member * - * @param int $nohtmlentities 0=Encode with htmlentities for HTML output, 1=No htmlentities for memory translation - * @return string Name translated of civility + * @return string Translated name of civility */ - function getCivilityLabel($nohtmlentities=0) + function getCivilityLabel() { global $langs; $langs->load("dict"); $code=$this->civilite_id; - if ($nohtmlentities) return $langs->transnoentities("Civility".$code)!="Civility".$code ? $langs->transnoentities("Civility".$code) : $code; - else return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : $code; + return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civilite", "code", "civilite", $code); } /** diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e956f40a3e3..fb1ce97fd01 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -874,9 +874,9 @@ class Contact extends CommonObject } /** - * Return label of a civility contact + * Return civility label of contact * - * @return string Translated name of civility + * @return string Translated name of civility */ function getCivilityLabel() { @@ -884,7 +884,7 @@ class Contact extends CommonObject $langs->load("dict"); $code=$this->civilite_id; - return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : ''; + return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civilite", "code", "civilite", $code); } /** diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 433100c4cb4..35271325247 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -643,13 +643,15 @@ class Translate * Store key-label found into cache variable $this->cache_labels to save SQL requests to get labels. * * @param DoliBD $db Database handler - * @param string $key Key to get label (key in language file) + * @param string $key Translation key to get label (key in language file) * @param string $tablename Table name without prefix * @param string $fieldkey Field for key * @param string $fieldlabel Field for label + * @param string $keyforselect Use another value than the translation key for the where into select * @return string Label in UTF8 (but without entities) + * @see dol_getIdFromCode */ - function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel) + function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel,$keyforselect='') { // If key empty if ($key == '') return ''; @@ -670,7 +672,7 @@ class Translate $sql = "SELECT ".$fieldlabel." as label"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; - $sql.= " WHERE ".$fieldkey." = '".$key."'"; + $sql.= " WHERE ".$fieldkey." = '".($keyforselect?$keyforselect:$key)."'"; dol_syslog(get_class($this).'::getLabelFromKey sql='.$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2fc96042895..c440b8d33dd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4071,6 +4071,7 @@ function dol_osencode($str) * @param string $fieldkey Field for code * @param string $fieldid Field for id * @return int Id of code + * @see getLabelFromKey */ function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id') {