|
@@ -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)
|
|
|
{
|