From af274668a30af2a336a6ab886225c663347f4391 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Mon, 31 Mar 2008 03:31:08 +0000 Subject: [PATCH] Fix: Detection auto des champs text/html. Fix: Dans les PDF, il ne faut pas faire le nl2br standard de PHP lors de la conversion text en HTML car ce dernier ne remplace pas le \n mais ajoute le br hors le writeHTMLCell transforme aussi les \n en br. --- htdocs/adherents/adherent.class.php | 2 +- htdocs/adherents/note.php | 2 +- htdocs/adherents/type.php | 4 +- htdocs/admin/ihm.php | 4 +- htdocs/categories/edit.php | 2 +- htdocs/categories/fiche.php | 2 +- htdocs/comm/action/fiche.php | 4 +- htdocs/comm/action/listactions.php | 10 +-- htdocs/comm/mailing/fiche.php | 2 +- htdocs/comm/propal.php | 6 +- htdocs/commande/fiche.php | 6 +- htdocs/compta/bank/fiche.php | 4 +- htdocs/compta/facture.php | 9 +- .../pdf/pdf_expedition_rouget.modules.php | 6 +- htdocs/fichinter/fiche.php | 4 +- htdocs/fourn/commande/fiche.php | 6 +- .../modules/pdf/pdf_muscadet.modules.php | 8 +- htdocs/html.form.class.php | 87 ++++++++++--------- .../modules/commande/pdf_einstein.modules.php | 10 +-- .../modules/facture/pdf_crabe.modules.php | 30 +++---- .../propale/pdf_propale_azur.modules.php | 10 +-- htdocs/lib/doleditor.class.php | 2 +- htdocs/lib/functions.inc.php | 60 +++++++++---- .../livraison/mods/pdf/pdf_typhon.modules.php | 10 +-- htdocs/product/fiche.php | 4 +- htdocs/product/stock/fiche.php | 4 +- htdocs/product/traduction.php | 4 +- htdocs/societe/socnote.php | 2 +- htdocs/user/group/fiche.php | 2 +- htdocs/user/note.php | 2 +- 30 files changed, 170 insertions(+), 138 deletions(-) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 30a5242d474..3c5e061b207 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -162,7 +162,7 @@ class Adherent extends CommonObject $infos.= $langs->trans("Birthday").": $this->naiss\n"; $infos.= $langs->trans("Photo").": $this->photo\n"; $infos.= $langs->trans("Public").": ".yn($this->public)."\n"; - if ($msgishtml) $infos = dol_htmlentities($infos); + if ($msgishtml) $infos = dol_htmlentitiesbr($infos); // Substitutions $patterns = array ( diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 7a6ed6d8207..cc6a3e4520a 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -118,7 +118,7 @@ if ($id) } else { - print '<textarea name="note" cols="80" rows="10">'.$adh->note.'</textarea>'; + print '<textarea name="note" cols="80" rows="10">'.dol_htmlentitiesbr_decode($adh->note).'</textarea>'; } } else diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 81536b9b198..27bffebd9c2 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -224,7 +224,7 @@ if ($_GET["action"] == 'create') else { print '<textarea class="flat" name="mail_valid" rows="15" cols="90">'; - print $adht->mail_valid; + print dol_htmlentitiesbr_decode($adht->mail_valid); print '</textarea>'; } print '</td></tr>'; @@ -361,7 +361,7 @@ if ($rowid > 0) else { print '<textarea class="flat" name="mail_valid" rows="15" cols="90">'; - print $adht->mail_valid; + print dol_htmlentitiesbr_decode($adht->mail_valid); print '</textarea>'; } print "</td></tr>"; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index bb1846cccc3..b086687a512 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -208,7 +208,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') } else { - print '<textarea name="main_motd" cols="90" rows="'.ROWS_5.'">'.$conf->global->MAIN_MOTD.'</textarea>'; + print '<textarea name="main_motd" cols="90" rows="'.ROWS_5.'">'.dol_htmlentitiesbr_decode($conf->global->MAIN_MOTD).'</textarea>'; } print '</td></tr>'; @@ -225,7 +225,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') } else { - print '<textarea name="main_home" cols="90" rows="'.ROWS_5.'">'.$conf->global->MAIN_HOME.'</textarea>'; + print '<textarea name="main_home" cols="90" rows="'.ROWS_5.'">'.dol_htmlentitiesbr_decode($conf->global->MAIN_HOME).'</textarea>'; } print '</td></tr>'; print '</table>'; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 7e5006f9558..154a084db91 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -126,7 +126,7 @@ if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) else { print '<textarea name="description" rows="'.ROWS_6.'" cols="50">'; - print $categorie->description; + print dol_htmlentitiesbr_decode($categorie->description); print '</textarea>'; } diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index 86f0fa255a3..2d6c4e4c617 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -180,7 +180,7 @@ if ($user->rights->categorie->creer) else { print '<textarea name="description" rows="'.ROWS_6.'" cols="50">'; - print $categorie->description; + print dol_htmlentitiesbr_decode($categorie->description); print '</textarea>'; } diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index f41672b7f16..9b5c454d70e 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -711,7 +711,7 @@ if ($_GET["id"]) } else { - print '<textarea name="note" cols="90" rows="'.ROWS_8.'">'.$act->note.'</textarea>'; + print '<textarea name="note" cols="90" rows="'.ROWS_8.'">'.dol_htmlentitiesbr_decode($act->note).'</textarea>'; } print '</td></tr>'; @@ -794,7 +794,7 @@ if ($_GET["id"]) // Note print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; - print dol_htmlentities($act->note); + print dol_htmlentitiesbr($act->note); print '</td></tr>'; print '</table>'; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 1b2e3b03ebf..edccf83ab6b 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -260,7 +260,7 @@ if ($resql) print $actionstatic->getNomUrl(1,4); print '</td>'; - print '<td align="left" nowrap="nowrap">'; + print '<td align="center" nowrap="nowrap">'; print dolibarr_print_date($obj->dp,"day"); $late=0; if ($obj->percent == 0 && $obj->dp && date("U",$obj->dp) < time()) $late=1; @@ -270,13 +270,13 @@ if ($resql) if ($late) print img_warning($langs->trans("Late")); print '</td>'; - print '<td align="left" nowrap="nowrap">'; + print '<td align="center" nowrap="nowrap">'; print dolibarr_print_date($obj->da2,"day"); print '</td>'; // Titre print '<td>'; - print dolibarr_trunc($obj->label,12); + print dolibarr_trunc($obj->label,10); print '</td>'; // Soci�t� @@ -284,7 +284,7 @@ if ($resql) $societestatic->id=$obj->socid; $societestatic->client=$obj->client; $societestatic->nom=$obj->societe; - print $societestatic->getNomUrl(1,'',8); + print $societestatic->getNomUrl(1,'',6); print '</td>'; // Contact @@ -294,7 +294,7 @@ if ($resql) $contactstatic->name=$obj->name; $contactstatic->firstname=$obj->firstname; $contactstatic->id=$obj->fk_contact; - print $contactstatic->getNomUrl(1,'',8); + print $contactstatic->getNomUrl(1,'',6); } else { diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index ebab542fb13..7fef6262443 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -661,7 +661,7 @@ else else { print '<textarea class="flat" name="body" cols="70" rows="20">'; - print $mil->body.'</textarea>'; + print dol_htmlentitiesbr_decode($mil->body).'</textarea>'; } print '</td></tr>'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 20597666966..d11ea6cb211 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1133,12 +1133,12 @@ if ($_GET['propalid'] > 0) else $text.= img_object($langs->trans('ShowProduct'),'product'); $text.= ' '.$objp->ref.'</a>'; $text.= ' - '.$objp->product; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':$objp->description); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)); print $html->textwithtooltip($text,$description,3,'','',$i); print_date_range($objp->date_start,$objp->date_end); if ($conf->global->PRODUIT_DESC_IN_FORM) { - print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):''; + print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; } print '</td>'; @@ -1353,7 +1353,7 @@ if ($_GET['propalid'] > 0) } else { - print '<textarea name="desc" cols="70" class="flat" rows="'.ROWS_2.'">'.$objp->description.'</textarea>'; + print '<textarea name="desc" cols="70" class="flat" rows="'.ROWS_2.'">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>'; } } print '</td>'; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 38d477ad6dd..26343f6c81c 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1364,13 +1364,13 @@ else else $text.= img_object($langs->trans('ShowProduct'),'product'); $text.= ' '.$objp->ref.'</a>'; $text.= ' - '.$objp->product; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':$objp->description); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)); print $html->textwithtooltip($text,$description,3,'','',$i); // Todo: voir si on insert ou pas en option les dates de debut et de fin de service //print_date_range($objp->date_start,$objp->date_end); if ($conf->global->PRODUIT_DESC_IN_FORM) { - print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):''; + print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; } print '</td>'; @@ -1512,7 +1512,7 @@ else } else { - print '<textarea name="eldesc" class="flat" cols="70" rows="1">'.$objp->description.'</textarea>'; + print '<textarea name="eldesc" class="flat" cols="70" rows="1">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>'; } print '</td>'; print '<td align="right">'; diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 19c87fc672f..d01bfe62a5b 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -225,7 +225,7 @@ if ($_GET["action"] == 'create') else { print '<textarea class="flat" name="account_comment" cols="70" rows="10">'; - print $account->comment.'</textarea>'; + print dol_htmlentitiesbr_decode($account->comment).'</textarea>'; } print '</td></tr>'; @@ -464,7 +464,7 @@ else else { print '<textarea class="flat" name="account_comment" cols="70" rows="10">'; - print $account->comment.'</textarea>'; + print dol_htmlentitiesbr_decode($account->comment).'</textarea>'; } print '</td></tr>'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index fa4204e778a..d9c1a0a4f95 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2363,13 +2363,13 @@ else else $text.= img_object($langs->trans('ShowProduct'),'product'); $text.= ' '.$objp->ref.'</a>'; $text.= ' - '.$objp->product; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':$objp->description); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)); //print $description; print $html->textwithtooltip($text,$description,3,'','',$i); print_date_range($objp->date_start,$objp->date_end); if ($conf->global->PRODUIT_DESC_IN_FORM) { - print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):''; + print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; } print '</td>'; @@ -2505,7 +2505,10 @@ else } else { - print '<textarea name="desc" class="flat" cols="70" rows="'.ROWS_2.'">'.$objp->description.'</textarea>'; + print '<textarea name="desc" class="flat" cols="70" rows="'.ROWS_2.'">'; + //print $objp->description; + print dol_htmlentitiesbr_decode($objp->description); + print '</textarea>'; } print '</td>'; print '<td align="right">'; diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php index 493a54e752e..93de2ccb650 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); + $libelleproduitservice=dol_htmlentitiesbr($this->expe->lignes[$i]->description,1); 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); + if ($libelleproduitservice) $libelleproduitservice.="<br>"; + $libelleproduitservice.=dol_htmlentitiesbr($this->expe->lignes[$i]->description,1); } // Si ligne associ�e � un code produit if ($this->expe->lignes[$i]->fk_product) diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 0135c7a214c..9fa055a06d6 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -621,7 +621,7 @@ elseif ($_GET["id"] > 0) } else { - print '<textarea name="description" wrap="soft" cols="70" rows="12">'.$fichinter->description.'</textarea>'; + print '<textarea name="description" wrap="soft" cols="70" rows="12">'.dol_htmlentitiesbr_decode($fichinter->description).'</textarea>'; } print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; print '</form>'; @@ -758,7 +758,7 @@ elseif ($_GET["id"] > 0) } else { - print '<textarea name="desc" cols="70" class="flat" rows="'.ROWS_2.'">'.$objp->description.'</textarea>'; + print '<textarea name="desc" cols="70" class="flat" rows="'.ROWS_2.'">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>'; } print '</td>'; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 48ee8dac50b..d4679cd4f55 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -707,11 +707,11 @@ else $text.= ' '.$objp->ref_fourn.'</a>'; $text.= ' ('.$objp->ref.')'; $text.= ' - '.$objp->product; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':$objp->description); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)); print $html->textwithtooltip($text,$description,3,'','',$i); if ($conf->global->PRODUIT_DESC_IN_FORM) { - print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):''; + print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; } print "</td>"; @@ -781,7 +781,7 @@ else } else { - print '<textarea name="eldesc" class="flat" cols="70" rows="1">'.$objp->description.'</textarea>'; + print '<textarea name="eldesc" class="flat" cols="70" rows="1">'.dol_htmlentitiesbr_decode($objp->description).'</textarea>'; } print '</td>'; print '<td>'; diff --git a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php index 14f1f1347a7..eb14574658f 100644 --- a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php +++ b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php @@ -239,11 +239,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=dol_htmlentities($com->lignes[$i]->libelle); + $libelleproduitservice=dol_htmlentitiesbr($com->lignes[$i]->libelle,1); if ($com->lignes[$i]->desc&&$com->lignes[$i]->desc!=$com->lignes[$i]->libelle) { - if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=dol_htmlentities($com->lignes[$i]->desc); + if ($libelleproduitservice) $libelleproduitservice.="<br>"; + $libelleproduitservice.=dol_htmlentitiesbr($com->lignes[$i]->desc,1); } // Si ligne associ�e � un code produit if ($com->lignes[$i]->fk_product) @@ -253,7 +253,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders 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).")"); + $libelleproduitservice.="<br>".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",1); } $pdf->SetFont('Arial','', 9); // Dans boucle pour g�rer multi-page diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 294d6ad2506..1b6acd708ec 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -63,59 +63,60 @@ class Form } - /** + /** \brief Affiche un texte+picto avec tooltip sur texte ou sur picto \param text Texte � afficher \param htmltext Contenu html du tooltip, cod� en html \param tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2, 4=tooltip sur les 2 et forc� en Ajax \param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apr�s \param img Code img du picto - \return string Code html du texte,picto - */ - function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10') - { - global $conf; + \return string Code html du tooltip (texte+picto) + */ + function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10') + { + global $conf; if (! $htmltext) return $text; $paramfortooltiptext =''; - $paramfortooltippicto =''; - - // Sanitize tooltip - $htmltext=ereg_replace("'","\'",$htmltext); - $htmltext=ereg_replace("'","\'",$htmltext); - $htmltext=ereg_replace("\r","",$htmltext); - $htmltext=ereg_replace("\n","<br>",$htmltext); - - if ($conf->use_javascript_ajax && $tooltipon == 4) - { - $s = '<div id="tip'.$i.'">'."\n"; - $s.= $text; - $s.= '</div>'."\n"; - $s.= '<div id="tooltip_content" style="display:none">'."\n"; - $s.= $htmltext."\n"; - $s.= '</div>'."\n"; - $s.= '<script type=\'text/javascript\'>'."\n"; - $s.= 'TooltipManager.init("","",{width:'.$width.', shiftX:'.$shiftX.'});'."\n"; - $s.= 'TooltipManager.addHTML("tip'.$i.'", "tooltip_content");'."\n"; - $s.= '</script>'."\n"; - } - else - { - if ($conf->use_javascript_ajax) - { - $htmltext=eregi_replace('"',"\'",$htmltext); - if ($tooltipon==1 || $tooltipon==3) - { - $paramfortooltiptext.=' onmouseover="showtip(\''.$htmltext.'\')"'; - $paramfortooltiptext.=' onMouseout="hidetip()"'; - } - if ($tooltipon==2 || $tooltipon==3) - { - $paramfortooltippicto.=' onmouseover="showtip(\''.$htmltext.'\')"'; - $paramfortooltippicto.=' onMouseout="hidetip()"'; - } - } + $paramfortooltippicto =''; + + // Sanitize tooltip + $htmltext=ereg_replace("'","\'",$htmltext); + $htmltext=ereg_replace("'","\'",$htmltext); + $htmltext=ereg_replace("\r","",$htmltext); + $htmltext=ereg_replace("<br>\n","<br>",$htmltext); + $htmltext=ereg_replace("\n","",$htmltext); + + if ($conf->use_javascript_ajax && $tooltipon == 4) + { + $s = '<div id="tip'.$i.'">'."\n"; + $s.= $text; + $s.= '</div>'."\n"; + $s.= '<div id="tooltip_content" style="display:none">'."\n"; + $s.= $htmltext."\n"; + $s.= '</div>'."\n"; + $s.= '<script type=\'text/javascript\'>'."\n"; + $s.= 'TooltipManager.init("","",{width:'.$width.', shiftX:'.$shiftX.'});'."\n"; + $s.= 'TooltipManager.addHTML("tip'.$i.'", "tooltip_content");'."\n"; + $s.= '</script>'."\n"; + } + else + { + if ($conf->use_javascript_ajax) + { + $htmltext=eregi_replace('"',"\'",$htmltext); + if ($tooltipon==1 || $tooltipon==3) + { + $paramfortooltiptext.=' onmouseover="showtip(\''.$htmltext.'\')"'; + $paramfortooltiptext.=' onMouseout="hidetip()"'; + } + if ($tooltipon==2 || $tooltipon==3) + { + $paramfortooltippicto.=' onmouseover="showtip(\''.$htmltext.'\')"'; + $paramfortooltippicto.=' onMouseout="hidetip()"'; + } + } $s=""; $s.='<table class="nobordernopadding"><tr>'; diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 8a870659f3b..aff85ce6c01 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -231,19 +231,19 @@ class pdf_einstein extends ModelePDFCommandes $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=dol_htmlentities($com->lignes[$i]->libelle); + $libelleproduitservice=dol_htmlentitiesbr($com->lignes[$i]->libelle,1); if ($com->lignes[$i]->desc && $com->lignes[$i]->desc!=$com->lignes[$i]->libelle) { - if ($libelleproduitservice) $libelleproduitservice.="\n"; + if ($libelleproduitservice) $libelleproduitservice.="<br>"; if ($com->lignes[$i]->desc == '(CREDIT_NOTE)' && $com->lignes[$i]->fk_remise_except) { $discount=new DiscountAbsolute($this->db); $discount->fetch($com->lignes[$i]->fk_remise_except); - $libelleproduitservice=$langs->trans("DiscountFromCreditNote",$discount->ref_facture_source); + $libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1); } else { - $libelleproduitservice.=dol_htmlentities($com->lignes[$i]->desc); + $libelleproduitservice.=dol_htmlentitiesbr($com->lignes[$i]->desc,1); } } // Si ligne associ�e � un code produit @@ -269,7 +269,7 @@ class pdf_einstein extends ModelePDFCommandes 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).")"); + $libelleproduitservice.="<br>".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",1); } $pdf->SetFont('Arial','', 9); // Dans boucle pour g�rer multi-page diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index b7ef49f4734..f67dd88b0cd 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> +/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Regis Houssin <regis.houssin@dolibarr.fr> * * This program is free software; you can redistribute it and/or modify @@ -16,8 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ */ /** @@ -25,7 +23,7 @@ \ingroup facture \brief Fichier de la classe permettant de g�n�rer les factures au mod�le Crabe \author Laurent Destailleur - \version $Revision$ + \version $Id$ */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); @@ -206,7 +204,7 @@ class pdf_crabe extends ModelePDFFactures { $tab_top = 88; - $pdf->SetFont('Arial','', 9); // Dans boucle pour g�rer multi-page + $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page $pdf->SetXY ($this->posxdesc-1, $tab_top); $pdf->MultiCell(190, 3, $fac->note_public, 0, 'J'); $nexY = $pdf->GetY(); @@ -234,31 +232,32 @@ class pdf_crabe extends ModelePDFFactures $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=dol_htmlentities($fac->lignes[$i]->libelle); + $libelleproduitservice=dol_htmlentitiesbr($fac->lignes[$i]->libelle,1); if ($fac->lignes[$i]->desc&&$fac->lignes[$i]->desc!=$fac->lignes[$i]->libelle) { - if ($libelleproduitservice) $libelleproduitservice.="\n"; + if ($libelleproduitservice) $libelleproduitservice.="<br>"; if ($fac->lignes[$i]->desc == '(CREDIT_NOTE)' && $fac->lignes[$i]->fk_remise_except) { $discount=new DiscountAbsolute($this->db); $discount->fetch($fac->lignes[$i]->fk_remise_except); - $libelleproduitservice=$langs->trans("DiscountFromCreditNote",$discount->ref_facture_source); + $libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1); } else - { - if ($fac->lignes[$i]->produit_id) + { + if ($fac->lignes[$i]->produit_id) { - $libelleproduitservice.=dol_htmlentities($fac->lignes[$i]->desc); + $libelleproduitservice.=dol_htmlentitiesbr($fac->lignes[$i]->desc,1); } else { - // On v�rifie si les lignes personnalis�es sont format�es avec fckeditor - $libelleproduitservice.=dol_htmlentities($fac->lignes[$i]->desc); + // On verifie si les lignes personnalisees sont formatees avec fckeditor + $libelleproduitservice.=dol_htmlentitiesbr($fac->lignes[$i]->desc,1); } } } - // Si ligne associ�e � un code produit + + // Si ligne associee a un code produit if ($fac->lignes[$i]->produit_id) { $prodser = new Product($this->db); @@ -284,8 +283,9 @@ class pdf_crabe extends ModelePDFFactures if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) { // Affichage duree 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).")"); + $libelleproduitservice.="<br>".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")",1); } + //if ($i==0) { print $libelleproduitservice; exit; } $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 1cced0b71b7..b5b59015da5 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -233,20 +233,20 @@ class pdf_propale_azur extends ModelePDFPropales $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=dol_htmlentities($propale->lignes[$i]->libelle); + $libelleproduitservice=dol_htmlentitiesbr($propale->lignes[$i]->libelle,1); if ($propale->lignes[$i]->desc && $propale->lignes[$i]->desc!=$propale->lignes[$i]->libelle) { - if ($libelleproduitservice) $libelleproduitservice.="\n"; + if ($libelleproduitservice) $libelleproduitservice.="<br>"; if ($propale->lignes[$i]->desc == '(CREDIT_NOTE)' && $propale->lignes[$i]->fk_remise_except) { $discount=new DiscountAbsolute($this->db); $discount->fetch($propale->lignes[$i]->fk_remise_except); - $libelleproduitservice=$langs->trans("DiscountFromCreditNote",$discount->ref_facture_source); + $libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1); } else { - $libelleproduitservice.=dol_htmlentities($propale->lignes[$i]->desc); + $libelleproduitservice.=dol_htmlentitiesbr($propale->lignes[$i]->desc,1); } } // Si ligne associ�e � un code produit @@ -271,7 +271,7 @@ class pdf_propale_azur extends ModelePDFPropales 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).")"); + $libelleproduitservice.="<br>".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($propale->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($propale->lignes[$i]->date_end).")",1); } $pdf->SetFont('Arial','', 9); // Dans boucle pour g�rer multi-page diff --git a/htdocs/lib/doleditor.class.php b/htdocs/lib/doleditor.class.php index 4bbf1a2daa6..b4eefcda2b9 100644 --- a/htdocs/lib/doleditor.class.php +++ b/htdocs/lib/doleditor.class.php @@ -56,7 +56,7 @@ class DolEditor require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php"); - $content=dol_htmlentities($content); // If content is not HTML, we convert to HTML. + $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. $this->editor = new FCKeditor($htmlname); $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 1e505b8eb15..df5e43cce59 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1555,8 +1555,9 @@ function print_liste_field_titre($name, $file, $field, $begin="", $options="", $ // If this is a sort field if ($field) { - print " "; - if (! $sortorder) + //print " "; + print '<img width="2px" src="/theme/common/transparent.png">'; + if (! $sortorder) { print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; @@ -2534,24 +2535,51 @@ function hexbin($hexa){ return $bin; } -/* -* \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 +/** +* \brief Replace CRLF in string with a HTML BR tag. +* \param string2encode String to encode +* \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br +* \return string String encoded */ -function dol_htmlentities($stringtoencode,$htmlinfo=-1) +function dol_nl2br($stringtoencode,$nl2brmode=0) { - if ($htmlinfo == 1) return $stringtoencode; - if ($htmlinfo == 0) return nl2br(htmlentities($stringtoencode)); - if ($htmlinfo == -1) + if (! $nl2brmode) return nl2br($stringtoencode); + else { - if (dol_textishtml($stringtoencode)) return $stringtoencode; - else return nl2br(htmlentities($stringtoencode)); + $ret=ereg_replace("\r","",$stringtoencode); + $ret=ereg_replace("\n","<br>",$ret); + return $ret; } - return $stringtoencode; +} + +/** +* \brief This function is called to encode a string into a HTML string +* \param stringtoencode String to encode +* \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br +* \remarks For PDF usage, you can show text by 2 ways: +* - writeHTMLCell -> param must be encoded into HTML. +* - MultiCell -> param must not be encoded into HTML. +* Because writeHTMLCell convert also \n into <br>, if function +* is used to build PDF, nl2br must be 1. +*/ +function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0) +{ + if (dol_textishtml($stringtoencode)) return $stringtoencode; + else return dol_nl2br(htmlentities($stringtoencode),$nl2brmode); +} + +/* +* \brief This function is called to decode a HTML string +* \param stringtodecode String to decode +*/ +function dol_htmlentitiesbr_decode($stringtodecode) +{ + $ret=html_entity_decode($stringtodecode); + $ret=eregi_replace("\r\n".'<br ?/?>',"<br>",$ret); + $ret=eregi_replace('<br ?/?>'."\r\n","\r\n",$ret); + $ret=eregi_replace('<br ?/?>'."\n","\n",$ret); + $ret=eregi_replace('<br ?/?>',"\n",$ret); + return $ret; } /** diff --git a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php index 0fee25d56e9..76a1f47d72b 100644 --- a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php +++ b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php @@ -197,11 +197,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=dol_htmlentities($delivery->lignes[$i]->label); - if ($delivery->lignes[$i]->description&&$delivery->lignes[$i]->description!=$delivery->lignes[$i]->label) + $libelleproduitservice=dol_htmlentitiesbr($delivery->lignes[$i]->label,1); + if ($delivery->lignes[$i]->description && $delivery->lignes[$i]->description!=$delivery->lignes[$i]->label) { - if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=dol_htmlentities($delivery->lignes[$i]->description); + if ($libelleproduitservice) $libelleproduitservice.="<br>"; + $libelleproduitservice.=dol_htmlentitiesbr($delivery->lignes[$i]->description,1); } // Si ligne associ�e � un code produit if ($delivery->lignes[$i]->fk_product) @@ -226,7 +226,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($delivery->lignes[$i]->date_start && $delivery->lignes[$i]->date_end) { // Affichage dur�e si il y en a une - $libelleproduitservice.="\n(".$langs->transnoentities("From")." ".dolibarr_print_date($delivery->lignes[$i]->date_start)." ".$langs->transnoentities("to")." ".dolibarr_print_date($delivery->lignes[$i]->date_end).")"; + $libelleproduitservice.="<br>".dol_htmlentitiesbr("(".$langs->transnoentities("From")." ".dolibarr_print_date($delivery->lignes[$i]->date_start)." ".$langs->transnoentities("to")." ".dolibarr_print_date($delivery->lignes[$i]->date_end).")",1); } $pdf->SetFont('Arial','', 9); // Dans boucle pour g�rer multi-page diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index e76da39f4f9..020d9e2cf89 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -983,7 +983,7 @@ if ($_GET["id"] || $_GET["ref"]) else { print '<textarea name="desc" rows="4" cols="90">'; - print $product->description; + print dol_htmlentitiesbr_decode($product->description); print "</textarea>"; } print "</td></tr>"; @@ -1029,7 +1029,7 @@ if ($_GET["id"] || $_GET["ref"]) else { print '<textarea name="note" rows="8" cols="70">'; - print $product->note; + print dol_htmlentitiesbr_decode($product->note); print "</textarea>"; } print "</td></tr>"; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 18529acbabd..89d4a94848a 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -161,7 +161,7 @@ if ($_GET["action"] == 'create') } else { - print '<textarea name="desc" cols="70" rows="5">'.$entrepot->description.'</textarea>'; + print '<textarea name="desc" cols="70" rows="5">'.dol_htmlentitiesbr_decode($entrepot->description).'</textarea>'; } print '</td></tr>'; @@ -414,7 +414,7 @@ else } else { - print '<textarea name="desc" cols="70" rows="5">'.$entrepot->description.'</textarea>'; + print '<textarea name="desc" cols="70" rows="5">'.dol_htmlentitiesbr_decode($entrepot->description).'</textarea>'; } print '</td></tr>'; diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 6346f9ddfe9..daacdadb17e 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -168,7 +168,7 @@ if ($_GET["action"] == 'edit') } else { - print '<textarea name="desc-'.$key.'" rows="3" cols="80">'.$product->multilangs[$key]["description"].'</textarea>'; + print '<textarea name="desc-'.$key.'" rows="3" cols="80">'.dol_htmlentitiesbr_decode($product->multilangs[$key]["description"]).'</textarea>'; } print '</td></tr>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>'; @@ -180,7 +180,7 @@ if ($_GET["action"] == 'edit') } else { - print '<textarea name="note-'.$key.'" rows="3" cols="80">'.$product->multilangs[$key]["note"].'</textarea>'; + print '<textarea name="note-'.$key.'" rows="3" cols="80">'.dol_htmlentitiesbr_decode($product->multilangs[$key]["note"]).'</textarea>'; } print '</td></tr>'; print '</tr>'; diff --git a/htdocs/societe/socnote.php b/htdocs/societe/socnote.php index 38cc1d00f10..5b8f1a4c593 100644 --- a/htdocs/societe/socnote.php +++ b/htdocs/societe/socnote.php @@ -106,7 +106,7 @@ if ($socid > 0) } else { - print '<textarea name="note" cols="70" rows="10">'.$societe->note.'</textarea>'; + print '<textarea name="note" cols="70" rows="10">'.dol_htmlentitiesbr_decode($societe->note).'</textarea>'; } } else diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 8f2aafb0d7d..d2a4d4c10f6 100644 --- a/htdocs/user/group/fiche.php +++ b/htdocs/user/group/fiche.php @@ -411,7 +411,7 @@ else else { print '<textarea class="flat" name="note" rows="'.ROWS_8.'" cols="90">'; - print $group->note; + print dol_htmlentitiesbr_decode($group->note); print '</textarea>'; } print '</td>'; diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 59d4e449f50..8240f4ecece 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -122,7 +122,7 @@ if ($id) } else { - print '<textarea name="note" cols="80" rows="10">'.$fuser->note.'</textarea>'; + print '<textarea name="note" cols="80" rows="10">'.dol_htmlentitiesbr_decode($fuser->note).'</textarea>'; } } else -- GitLab