More comments

This commit is contained in:
Laurent Destailleur 2015-03-03 17:47:17 +01:00
parent 7050ef6176
commit 35733c4c08

View File

@ -3759,8 +3759,8 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
/** /**
* This function is called to encode a string into a HTML string but differs from htmlentities because * This function is called to encode a string into a HTML string but differs from htmlentities because
* all entities but &,<,> are converted. This permits to encode special chars to entities with no double * a detection is done before to see if text is already HTML or not. Also, all entities but &,<,> are converted.
* encoding for already encoded HTML strings. * This permits to encode special chars to entities with no double encoding for already encoded HTML strings.
* This function also remove last EOL or BR if $removelasteolbr=1 (default). * This function also remove last EOL or BR if $removelasteolbr=1 (default).
* For PDF usage, you can show text by 2 ways: * For PDF usage, you can show text by 2 ways:
* - writeHTMLCell -> param must be encoded into HTML. * - writeHTMLCell -> param must be encoded into HTML.
@ -3777,7 +3777,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$removelasteolbr=1) function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$removelasteolbr=1)
{ {
$newstring=$stringtoencode; $newstring=$stringtoencode;
if (dol_textishtml($stringtoencode)) if (dol_textishtml($stringtoencode)) // Check if text is already HTML or not
{ {
$newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. $newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
if ($removelasteolbr) $newstring=preg_replace('/<br>$/i','',$newstring); // Remove last <br> (remove only last one) if ($removelasteolbr) $newstring=preg_replace('/<br>$/i','',$newstring); // Remove last <br> (remove only last one)