function name is more clear

This commit is contained in:
Laurent Destailleur 2008-11-06 01:31:57 +00:00
parent be8714813e
commit 3119f8125b
5 changed files with 26 additions and 10 deletions

View File

@ -206,7 +206,7 @@ class ExportCsv extends ModeleExports
$addquote=0; $addquote=0;
// Rule Dolibarr: No HTML // Rule Dolibarr: No HTML
$newvalue=clean_html($newvalue); $newvalue=dol_string_nohtmltag($newvalue);
// Rule 1 CSV: No CR, LF in cells // Rule 1 CSV: No CR, LF in cells
$newvalue=ereg_replace("\r",'',$newvalue); $newvalue=ereg_replace("\r",'',$newvalue);

View File

@ -192,8 +192,9 @@ class ExportExcel extends ModeleExports
{ {
$alias=$array_alias[$code]; $alias=$array_alias[$code];
$newvalue=$objp->$alias; $newvalue=$objp->$alias;
// Nettoyage newvalue
$newvalue=clean_html($newvalue); $newvalue=$this->excel_clean($newvalue);
// Traduction newvalue // Traduction newvalue
if (eregi('^\((.*)\)$',$newvalue,$reg)) if (eregi('^\((.*)\)$',$newvalue,$reg))
{ {
@ -241,6 +242,19 @@ class ExportExcel extends ModeleExports
return 0; return 0;
} }
/**
* Clean a cell to respect rules of Excel file cells
* @param newvalue String to clean
* @return string Value cleaned
*/
function excel_clean($newvalue)
{
// Rule Dolibarr: No HTML
$newvalue=dol_string_nohtmltag($newvalue);
return $newvalue;
}
} }
?> ?>

View File

@ -204,7 +204,7 @@ class ExportTsv extends ModeleExports
function tsv_clean($newvalue) function tsv_clean($newvalue)
{ {
// Rule Dolibarr: No HTML // Rule Dolibarr: No HTML
$newvalue=clean_html($newvalue); $newvalue=dol_string_nohtmltag($newvalue);
// Rule 1 TSV: No CR, LF in cells // Rule 1 TSV: No CR, LF in cells
$newvalue=ereg_replace("\r",'',$newvalue); $newvalue=ereg_replace("\r",'',$newvalue);

View File

@ -2626,12 +2626,12 @@ function clean_url($url,$http=1)
/** /**
* \brief Clean a string from all html tags * \brief Clean a string from all HTML tags and entities
* \param StringHtml String to clean * \param StringHtml String to clean
* \param removelinefeed Replace also all lines feeds by a space * \param removelinefeed Replace also all lines feeds by a space
* \return string String cleaned * \return string String cleaned
*/ */
function clean_html($StringHtml,$removelinefeed=1) function dol_string_nohtmltag($StringHtml,$removelinefeed=1)
{ {
$pattern = "<[^>]+>"; $pattern = "<[^>]+>";
$temp = dol_entity_decode($StringHtml); $temp = dol_entity_decode($StringHtml);
@ -2748,13 +2748,15 @@ function dol_htmlcleanlastbr($stringtodecode)
} }
/** /**
* \brief This function is called to decode a HTML string (it decodes entities tags) * \brief This function is called to decode a string with HTML entities (it decodes entities tags)
* \param string stringhtml * \param string stringhtml
* \return string decodestring * \return string decodestring
*/ */
function dol_entity_decode($stringhtml,$pagecodeto='UTF-8') function dol_entity_decode($stringhtml,$pagecodeto='UTF-8')
{ {
$ret=html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto); //print 'x'.$stringhtml;
//$ret=html_entity_decode($stringhtml,ENT_COMPAT,$pagecodeto);
$ret=html_entity_decode($stringhtml,ENT_COMPAT);
return $ret; return $ret;
} }

View File

@ -87,7 +87,7 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
$url = $event['url']; $url = $event['url'];
$transparency = $event['transparency']; // OPAQUE or TRANSPARENT $transparency = $event['transparency']; // OPAQUE or TRANSPARENT
$description=eregi_replace('<br[ \/]?>',"\n",$event['desc']); $description=eregi_replace('<br[ \/]?>',"\n",$event['desc']);
$description=clean_html($description,0); // Remove html tags $description=dol_string_nohtmltag($description,0); // Remove html tags
// Uncomment for tests // Uncomment for tests
//$summary="Resume"; //$summary="Resume";
@ -296,7 +296,7 @@ function build_rssfile($format='rss',$title,$desc,$events_array,$outputfile,$fil
$author = $event['author']; $author = $event['author'];
$category = $event['category']; $category = $event['category'];
$description=eregi_replace('<br[ \/]?>',"\n",$event['desc']); $description=eregi_replace('<br[ \/]?>',"\n",$event['desc']);
$description=clean_html($description,0); // Remove html tags $description=dol_string_nohtmltag($description,0); // Remove html tags
fwrite ($fichier, "<item>\n"); fwrite ($fichier, "<item>\n");
fwrite ($fichier, "<title><![CDATA[".$summary."]]></title>"."\n"); fwrite ($fichier, "<title><![CDATA[".$summary."]]></title>"."\n");