fixed not working $$time$$ and $$date$$ placeholders, by using egw_time::to() and deprecating format_datetime()

This commit is contained in:
Ralf Becker 2009-12-24 02:00:51 +00:00
parent 08d5ce1f30
commit fdf4dcb9b9

View File

@ -232,17 +232,16 @@ abstract class bo_merge
/** /**
* Format a datetime * Format a datetime
* *
* @param int|string $time unix timestamp or Y-m-d H:i:s string (in user time!) * @param int|string|DateTime $time unix timestamp or Y-m-d H:i:s string (in user time!)
* @param string $format=null format string, default $this->datetime_format * @param string $format=null format string, default $this->datetime_format
* @deprecated use egw_time::to($time='now',$format='')
* @return string * @return string
*/ */
protected function format_datetime($time,$format=null) protected function format_datetime($time,$format=null)
{ {
if (is_null($format)) $format = $this->datetime_format; if (is_null($format)) $format = $this->datetime_format;
if (empty($time)) return ''; return egw_time::to($time,$format);
return date($this->datetime_format,is_numeric($time) ? $time : strtotime($time));
} }
/** /**
@ -323,10 +322,9 @@ abstract class bo_merge
{ {
$replacements += $this->contact_replacements($user,'user'); $replacements += $this->contact_replacements($user,'user');
} }
$now = time()+$this->contacts->tz_offset_s; $replacements['$$date$$'] = egw_time::to('now',true);
$replacements['$$date$$'] = $this->format_datetime($now,$GLOBALS['egw_info']['user']['preferences']['common']['dateformat']); $replacements['$$datetime$$'] = egw_time::to('now');
$replacements['$$datetime$$'] = $this->format_datetime($now); $replacements['$$time$$'] = egw_time::to('now',false);
$replacements['$$time$$'] = $this->format_datetime($now,$GLOBALS['egw_info']['user']['preferences']['common']['timeformat']==12?'h:i a':'H:i');
// does our extending class registered table-plugins AND document contains table tags // does our extending class registered table-plugins AND document contains table tags
if ($this->table_plugins && preg_match_all('/\\$\\$table\\/([A-Za-z0-9_]+)\\$\\$(.*?)\\$\\$endtable\\$\\$/s',$content,$matches,PREG_SET_ORDER)) if ($this->table_plugins && preg_match_all('/\\$\\$table\\/([A-Za-z0-9_]+)\\$\\$(.*?)\\$\\$endtable\\$\\$/s',$content,$matches,PREG_SET_ORDER))