From d1e66db5ffbd7451e4f1f937b3d47569b7011ddf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 6 Aug 2008 14:58:26 +0000 Subject: [PATCH] Change back --- htdocs/lib/functions.lib.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index ef569084cbe..b60c3d448fe 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> + * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2775,17 +2776,34 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0) } /** - \brief Fonction retournant le nombre de lignes dans un texte format� - \param texte Texte - \return nblines Nombre de lignes + * \brief Fonction retournant le nombre de lignes dans un texte formate + * \param texte Texte + * \return nblines Nombre de lignes */ -function num_lines($texte) +function num_lines($texte,$maxlinesize=0) { $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " "); $texte = strtr($texte, $repTable); $pattern = '/(<[^>]+>)/Uu'; $a = preg_split($pattern, $texte, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $nblines = ((count($a)+1)/2); + // count possible auto line breaks + if($maxlinesize) + { + foreach ($a as $line) + { + if (strlen($line)>$maxlinesize) + { + //$line_dec = html_entity_decode(strip_tags($line)); + $line_dec = html_entity_decode($line); + if(strlen($line_dec)>$maxlinesize) + { + $line_dec=wordwrap($line_dec,$maxlinesize,'\n',true); + $nblines+=substr_count($line_dec,'\n'); + } + } + } + } return $nblines; } -- GitLab