diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php index ff46abd4dd0..493a54e752e 100644 --- a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php @@ -215,11 +215,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition } // Description de la ligne produit - $libelleproduitservice=_dol_htmlentities($this->expe->lignes[$i]->description,0); + $libelleproduitservice=dol_htmlentities($this->expe->lignes[$i]->description); if ($this->expe->lignes[$i]->description&&$this->expe->lignes[$i]->description!=$com->lignes[$i]->libelle) { if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=_dol_htmlentities($this->expe->lignes[$i]->description,$conf->global->FCKEDITOR_ENABLE_DETAILS); + $libelleproduitservice.=dol_htmlentities($this->expe->lignes[$i]->description); } // Si ligne associée à un code produit if ($this->expe->lignes[$i]->fk_product) @@ -243,17 +243,8 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - if ($conf->fckeditor->enabled) - { - $pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $libelleproduitservice, 0, 1); -// $pdf->SetXY ($this->posxdesc, $curY); -// $pdf->MultiCell(150, 3, "zzzz g dg fdgdfgfgfgfdg dfg dfgdfgfdggggggggggggggggggg f g fd g fdgfdgggggggggggggggggggggggggggg fg df g ff hf hz", 0, 'J'); - } - else - { - $pdf->SetXY ($this->posxdesc, $curY); - $pdf->MultiCell(150, 3, $libelleproduitservice, 0, 'J'); - } + $pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $libelleproduitservice, 0, 1); + $pdf->SetXY (160, $curY); $pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_commande); diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 4e11312dd7e..542d6a53c74 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -232,7 +232,7 @@ class pdf_einstein extends ModelePDFCommandes $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=_dol_htmlentities($com->lignes[$i]->libelle,0); + $libelleproduitservice=dol_htmlentities($com->lignes[$i]->libelle); if ($com->lignes[$i]->desc&&$com->lignes[$i]->desc!=$com->lignes[$i]->libelle) { if ($libelleproduitservice) $libelleproduitservice.="\n"; @@ -244,7 +244,7 @@ class pdf_einstein extends ModelePDFCommandes } else { - $libelleproduitservice.=_dol_htmlentities($com->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS); + $libelleproduitservice.=dol_htmlentities($com->lignes[$i]->desc); } } // Si ligne associée à un code produit @@ -265,34 +265,17 @@ class pdf_einstein extends ModelePDFCommandes $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; } - // Ajoute description du produit - if ($conf->global->PRODUIT_DESC_IN_FORM && !$conf->global->PRODUIT_CHANGE_PROD_DESC) - { - if ($com->lignes[$i]->product_desc&&$com->lignes[$i]->product_desc!=$com->lignes[$i]->libelle&&$com->lignes[$i]->product_desc!=$com->lignes[$i]->desc) - { - if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=$com->lignes[$i]->product_desc; - } - } } if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) { // Affichage durée si il y en a une - $libelleproduitservice.=_dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",0); + $libelleproduitservice.=dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")"); } $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); - } - else - { - $pdf->SetXY ($this->posxdesc-1, $curY); - $pdf->MultiCell(108, 4, dol_entity_decode($libelleproduitservice), 0, 'J'); - } + $pdf->writeHTMLCell(112, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 6349b803011..5c6e440211b 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -230,7 +230,7 @@ class pdf_crabe extends ModelePDFFactures $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=_dol_htmlentities($fac->lignes[$i]->libelle,0); + $libelleproduitservice=dol_htmlentities($fac->lignes[$i]->libelle); if ($fac->lignes[$i]->desc&&$fac->lignes[$i]->desc!=$fac->lignes[$i]->libelle) { if ($libelleproduitservice) $libelleproduitservice.="\n"; @@ -245,12 +245,12 @@ class pdf_crabe extends ModelePDFFactures { if ($fac->lignes[$i]->produit_id) { - $libelleproduitservice.=_dol_htmlentities($fac->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS); + $libelleproduitservice.=dol_htmlentities($fac->lignes[$i]->desc); } else { // On vérifie si les lignes personnalisées sont formatées avec fckeditor - $libelleproduitservice.=_dol_htmlentities($fac->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS_PERSO); + $libelleproduitservice.=dol_htmlentities($fac->lignes[$i]->desc); } } } @@ -275,34 +275,17 @@ class pdf_crabe extends ModelePDFFactures $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; } - // Ajoute description du produit - if ($conf->global->PRODUIT_DESC_IN_FORM && !$conf->global->PRODUIT_CHANGE_PROD_DESC) - { - if ($fac->lignes[$i]->product_desc&&$fac->lignes[$i]->product_desc!=$fac->lignes[$i]->libelle&&$fac->lignes[$i]->product_desc!=$fac->lignes[$i]->desc) - { - if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=$fac->lignes[$i]->product_desc; - } - } } if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) { // Affichage durée si il y en a une - $libelleproduitservice.=_dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")",0); + $libelleproduitservice.=dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")"); } $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); - } - else - { - $pdf->SetXY ($this->posxdesc-1, $curY); - $pdf->MultiCell(108, 4, dol_entity_decode($libelleproduitservice), 0, 'J'); - } + $pdf->writeHTMLCell(112, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut $nexY = $pdf->GetY(); diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 6aee25b8304..ed576c4605f 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -229,7 +229,7 @@ class pdf_propale_azur extends ModelePDFPropales $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=_dol_htmlentities($propale->lignes[$i]->libelle,0); + $libelleproduitservice=dol_htmlentities($propale->lignes[$i]->libelle); if ($propale->lignes[$i]->desc && $propale->lignes[$i]->desc!=$propale->lignes[$i]->libelle) { if ($libelleproduitservice) $libelleproduitservice.="\n"; @@ -242,7 +242,7 @@ class pdf_propale_azur extends ModelePDFPropales } else { - $libelleproduitservice.=_dol_htmlentities($propale->lignes[$i]->desc,$conf->global->FCKEDITOR_ENABLE_DETAILS); + $libelleproduitservice.=dol_htmlentities($propale->lignes[$i]->desc); } } // Si ligne associée à un code produit @@ -263,33 +263,16 @@ class pdf_propale_azur extends ModelePDFPropales $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; } - // Ajoute description complète du produit - if ($conf->global->PRODUIT_DESC_IN_FORM && !$conf->global->PRODUIT_CHANGE_PROD_DESC) - { - if ($propale->lignes[$i]->product_desc && $propale->lignes[$i]->product_desc!=$propale->lignes[$i]->libelle && $propale->lignes[$i]->product_desc!=$propale->lignes[$i]->desc) - { - if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=$propale->lignes[$i]->product_desc; - } - } } if ($propale->lignes[$i]->date_start && $propale->lignes[$i]->date_end) { // Affichage durée si il y en a une - $libelleproduitservice.=_dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($propale->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($propale->lignes[$i]->date_end).")",0); + $libelleproduitservice.=dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($propale->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($propale->lignes[$i]->date_end).")"); } $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); - } - else - { - $pdf->SetXY ($this->posxdesc-1, $curY); - $pdf->MultiCell(108, 4, dol_entity_decode($libelleproduitservice), 0, 'J'); - } + $pdf->writeHTMLCell(112, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut $nexY = $pdf->GetY(); diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index 6bb7c879dce..18f38970ea2 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -102,9 +102,7 @@ class CMailFile if ($msgishtml == 2) { $this->msgishtml = 0; - if (eregi('msgishtml = 1; - elseif (eregi('msgishtml = 1; - elseif (eregi('msgishtml = 1; + if (dol_textishtml($msg,1)) $this->msgishtml = 1; } else { diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 2d3101c408b..a71bb4ea7c7 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -2820,16 +2820,23 @@ function hexbin($hexa){ return $bin; } -// Cette fonction est appelée pour coder ou non une chaine en html -// selon qu'on compte l'afficher dans le PDF avec: -// writeHTMLCell -> a besoin d'etre encodé en HTML -// MultiCell -> ne doit pas etre encodé en HTML -function _dol_htmlentities($stringtoencode,$isstringalreadyhtml) +/* +* \brief Cette fonction est appelée pour coder ou non une chaine en html. +* \param stringtoencode String to encode +* \param htmlinfo 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection +* \remarks Selon qu'on compte l'afficher dans le PDF avec: +* writeHTMLCell -> a besoin d'etre encodé en HTML +* MultiCell -> ne doit pas etre encodé en HTML +*/ +function dol_htmlentities($stringtoencode,$htmlinfo=-1) { - global $conf; - - if ($isstringalreadyhtml) return $stringtoencode; - if ($conf->fckeditor->enabled) return htmlentities($stringtoencode); + if ($htmlinfo == 1) return $stringtoencode; + if ($htmlinfo == 0) return htmlentities($stringtoencode); + if ($htmlinfo == -1) + { + if (dol_textishtml($stringtoencode)) return $stringtoencode; + else return htmlentities($stringtoencode); + } return $stringtoencode; } @@ -3188,6 +3195,33 @@ function dol_microtime_float() return ((float)$usec + (float)$sec); } +/* + * \brief Return if a text is a html content + * \param msg Content to check + * \param option 0=Full detection, 1=Fast check + * \return boolean true/false + */ +function dol_textishtml($msg,$option=0) +{ + if ($option == 1) + { + if (eregi('