rework of bofelamimail::_strtotime, to make propper use of egw_time; performance issue: limit the number of links and email to be parsed (and adapted) to 100 each, as it should be sufficient for most standard emails; try to further improve the display of textmails; backport of bofelamimails version of wordwrap from trunk (allow to skip lines that start with )

This commit is contained in:
Klaus Leithoff 2010-09-07 09:14:14 +00:00
parent b08373cde5
commit f7652eeb07
4 changed files with 3836 additions and 10 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2706,7 +2706,7 @@
return $userACL;
}
static function wordwrap($str, $cols, $cut)
static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false)
{
$lines = explode("\n", $str);
$newStr = '';
@ -2716,7 +2716,14 @@
//$line = str_replace("\t"," ",$line);
//$newStr .= wordwrap($line, $cols, $cut);
$allowedLength = $cols-strlen($cut);
if (strlen($line) > $allowedLength) {
if (strlen($line) > $allowedLength &&
($dontbreaklinesstartingwith==false ||
($dontbreaklinesstartingwith &&
strlen($dontbreaklinesstartingwith)>=1 &&
substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith
)
)
) {
$s=explode(" ", $line);
$line = "";
$linecnt = 0;
@ -2932,21 +2939,26 @@
/**
* Helper function to handle wrong or unrecognized timezones
* returns the date as it is parseable by strtotime, or current timestamp if everything failes
* @param string date to be parsed/formatted
* @param string format string, if none is passed, use the users common dateformat supplemented by the time hour:minute:second
* @return string returns the date as it is parseable by strtotime, or current timestamp if everything failes
*/
static function _strtotime($date='')
static function _strtotime($date='',$format=NULL)
{
if (strtotime($date)===false)
if ($format==NULL) $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '.'H:i:s';
$date2return = egw_time::to($date,$format);
if ($date2return==null)
{
$dtarr = explode(' ',$date);
$test = false;
while ($test===false && count($dtarr)>=1)
$test = null;
while ($test===null && count($dtarr)>=1)
{
array_pop($dtarr);
$test=strtotime(implode(' ',$dtarr));
if ($test) $date = implode(' ',$dtarr);
$test= egw_time::to(implode(' ',$dtarr),$format);
if ($test) $date2return = $test;
}
if ($test===false) $date = strtotime('now');
if ($test===null) $date2return = egw_time::to('now',$format);
}
return $date;
return $date2return;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff