2
0
forked from Wavyzz/dolibarr

FIX Fix and move dolGetFirstLine function into main

FIX Hang on ->client not defined
This commit is contained in:
Laurent Destailleur
2016-04-22 19:07:32 +02:00
parent 467662143f
commit bfc5be1aad
8 changed files with 36 additions and 31 deletions

View File

@@ -4285,6 +4285,29 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
}
/**
* Return first line of text. Cut will depends if content is HTML or not.
*
* @param string $text Input text
* @return string Output text
* @see dol_nboflines_bis
*/
function dolGetFirstLineOfText($text)
{
if (dol_textishtml($text))
{
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
}
else
{
$firstline=preg_replace('/[\n\r].*/','',$text);
}
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
}
/**
* Replace CRLF in string with a HTML BR tag
*
@@ -4292,6 +4315,7 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
* @param bool $forxml false=Use <br>, true=Use <br />
* @return string String encoded
* @see dol_nboflines, dolGetFirstLineOfText
*/
function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
{
@@ -4429,7 +4453,7 @@ function dol_string_is_good_iso($s)
* @param string $s String to check
* @param int $maxchar Not yet used
* @return int Number of lines
* @see dol_nboflines_bis
* @see dol_nboflines_bis, dolGetFirstLineOfText
*/
function dol_nboflines($s,$maxchar=0)
{