2
0
forked from Wavyzz/dolibarr

Fix: Correct concat when mixing not html and html descriptions

This commit is contained in:
Laurent Destailleur
2012-09-16 20:23:57 +02:00
parent df3227ef7e
commit 07fa800360
4 changed files with 36 additions and 10 deletions

View File

@@ -714,6 +714,8 @@ else if ($action == "addline" && $user->rights->propal->creer)
}
}
$desc='';
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
@@ -734,8 +736,7 @@ else if ($action == "addline" && $user->rights->propal->creer)
$desc = $prod->description;
}
$desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"<br />\n":"\n") : "";
$desc.= $product_desc;
$desc=dol_concatdesc($desc,$product_desc);
}
$type = $prod->type;

View File

@@ -618,6 +618,8 @@ else if ($action == 'addline' && $user->rights->commande->creer)
}
}
$desc='';
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
@@ -638,8 +640,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
$desc = $prod->description;
}
$desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"<br />\n":"\n") : "";
$desc.= $product_desc;
$desc=dol_concatdesc($desc,$product_desc);
}
$type = $prod->type;

View File

@@ -1049,6 +1049,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
}
}
$desc='';
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
@@ -1069,8 +1071,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$desc = $prod->description;
}
$desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"<br />\n":"\n") : "";
$desc.= $product_desc;
$desc=dol_concatdesc($desc,$product_desc);
}
if (! empty($prod->customcode) || ! empty($prod->country_code))

View File

@@ -3367,11 +3367,12 @@ function dol_microtime_float()
}
/**
* Return if a text is a html content
* Return if a text is a html content
*
* @param string $msg Content to check
* @param int $option 0=Full detection, 1=Fast check
* @return boolean true/false
* @param string $msg Content to check
* @param int $option 0=Full detection, 1=Fast check
* @return boolean true/false
* @see dol_concatdesc
*/
function dol_textishtml($msg,$option=0)
{
@@ -3402,6 +3403,28 @@ function dol_textishtml($msg,$option=0)
}
}
/**
* Concat 2 descriptions (second one after first one)
* text1 html + text2 html => text1 + '<br>' + text2
* text1 html + text2 txt => text1 + '<br>' + dol_nl2br(text2)
* text1 txt + text2 html => dol_nl2br(text1) + '<br>' + text2
* text1 txt + text2 txt => text1 + '\n' + text2
*
* @param string $text1 Text 1
* @param string $text2 Text 2
* @param string $forxml false=Use <br>, true=Use <br />
* @return string Text 1 + new line + Text2
* @see dol_textishtml
*/
function dol_concatdesc($text1,$text2,$forxml=false)
{
$ret='';
$ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1;
$ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"<br \>\n":"<br>\n") : "\n") : "";
$ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2;
return $ret;
}
/**
* Make substition into a string
* There is two type of substitions: