Skip to content

Commit

Permalink
Update code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 16, 2017
1 parent bd7c4fe commit 695c231
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -4823,20 +4823,25 @@ function picto_required()


/**
* Clean a string from all HTML tags and entities
* Clean a string from all HTML tags and entities.
* This function differs from strip_tags because:
* - <br> are replace with \n
* - if entities are found, they are decoded before the strip
* - you can decide to convert line feed into spaces
*
* @param string $StringHtml String to clean
* @param string $stringtoclean String to clean
* @param integer $removelinefeed 1=Replace also new lines by a space, 0=Only last one are removed
* @param string $pagecodeto Encoding of input/output string
* @return string String cleaned
*
* @see dol_escape_htmltag
* @see dol_escape_htmltag strip_tags
*/
function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8')
{
// TODO Try to replace with strip_tags($stringtoclean)
$pattern = "/<[^<>]+>/";
$StringHtml = preg_replace('/<br[^>]*>/', "\n", $StringHtml);
$temp = dol_html_entity_decode($StringHtml,ENT_COMPAT,$pagecodeto);
$stringtoclean = preg_replace('/<br[^>]*>/', "\n", $stringtoclean);
$temp = dol_html_entity_decode($stringtoclean,ENT_COMPAT,$pagecodeto);

// Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
$temp = preg_replace($pattern,"",$temp); // pass 1
Expand All @@ -4852,8 +4857,8 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
{
$temp = str_replace(" "," ",$temp);
}
$CleanString = trim($temp);
return $CleanString;

return trim($temp);
}


Expand Down

0 comments on commit 695c231

Please sign in to comment.