diff --git a/inc/common.php b/inc/common.php index 82d5f69eebf019b6ddeb3f011dbafd6873026bbe..a15cb5c62b3696dfcb2fc0ee583e7173f6d8fa3a 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1082,7 +1082,7 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ } $ip = clientIP(); - $text = str_replace('@DATE@',strftime($conf['dformat']),$text); + $text = str_replace('@DATE@',dformat(),$text); $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text); $text = str_replace('@IPADDRESS@',$ip,$text); $text = str_replace('@HOSTNAME@',gethostsbyaddrs($ip),$text); @@ -1223,6 +1223,26 @@ function datetime_h($dt){ } +/** + * Wraps around strftime but provides support for fuzzy dates + * + * The format default to $conf['dformat']. It is passed to + * strftime - %f can be used to get the value from datetime_h() + * + * @see datetime_h + * @author Andreas Gohr <gohr@cosmocode.de> + */ +function dformat($dt=null,$format=''){ + global $conf; + + if(is_null($dt)) $dt = time(); + $dt = (int) $dt; + if(!$format) $format = $conf['dformat']; + + $format = str_replace('%f',datetime_h($dt),$format); + return strftime($format,$dt); +} + /** * return an obfuscated email address in line with $conf['mailguard'] setting * diff --git a/inc/html.php b/inc/html.php index 46ced1de12f6edabe44c8663ba197788dd475ac1..0ea72c06c0b8eb21ec438cb8d1ed5307563ec2fd 100644 --- a/inc/html.php +++ b/inc/html.php @@ -249,7 +249,7 @@ function html_draft(){ $form->addHidden('date', $draft['date']); $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); - $form->addElement($lang['draftdate'].' '. strftime($conf['dformat'],filemtime($INFO['draft']))); + $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft']))); $form->addElement(form_makeCloseTag('div')); $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); @@ -382,7 +382,7 @@ function html_locked(){ global $INFO; $locktime = filemtime(wikiLockFN($ID)); - $expire = @strftime($conf['dformat'], $locktime + $conf['locktime'] ); + $expire = dformat($locktime + $conf['locktime']); $min = round(($conf['locktime'] - (time() - $locktime) )/60); print p_locale_xhtml('locked'); @@ -418,7 +418,7 @@ function html_revisions($first=0){ array_pop($revisions); // remove extra log entry } - $date = @strftime($conf['dformat'],$INFO['lastmod']); + $date = dformat($INFO['lastmod']); print p_locale_xhtml('revisions'); @@ -466,7 +466,7 @@ function html_revisions($first=0){ } foreach($revisions as $rev){ - $date = strftime($conf['dformat'],$rev); + $date = dformat($rev); $info = getRevisionInfo($ID,$rev,true); $exists = page_exists($ID,$rev); @@ -593,7 +593,7 @@ function html_recent($first=0){ $form->addElement(form_makeOpenTag('ul')); foreach($recents as $recent){ - $date = strftime($conf['dformat'],$recent['date']); + $date = dformat($recent['date']); if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); else @@ -878,7 +878,7 @@ function html_diff($text='',$intro=true){ $l_rev = ''; $l_text = rawWiki($ID,''); $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. - $ID.' '.strftime($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. + $ID.' '.dformat((int) @filemtime(wikiFN($ID))).'</a> '. $lang['current']; $r_rev = ''; @@ -925,7 +925,7 @@ function html_diff($text='',$intro=true){ if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"'; $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'. - $ID.' ['.strftime($conf['dformat'],$l_rev).']</a>'. + $ID.' ['.dformat($l_rev).']</a>'. '<br />'.$l_user.' '.$l_sum; } @@ -939,7 +939,7 @@ function html_diff($text='',$intro=true){ if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'. - $ID.' ['.strftime($conf['dformat'],$r_rev).']</a>'. + $ID.' ['.dformat($r_rev).']</a>'. '<br />'.$r_user.' '.$r_sum; }elseif($_rev = @filemtime(wikiFN($ID))){ $_info = getRevisionInfo($ID,$_rev,true); @@ -951,7 +951,7 @@ function html_diff($text='',$intro=true){ if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; $r_head = '<a class="wikilink1" href="'.wl($ID).'">'. - $ID.' ['.strftime($conf['dformat'],$_rev).']</a> '. + $ID.' ['.dformat($_rev).']</a> '. '('.$lang['current'].')'. '<br />'.$_user.' '.$_sum; }else{ @@ -1173,7 +1173,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed? <div style="width:99%;"> <div class="toolbar"> - <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.strftime($conf['dformat']);?></div> + <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div> <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php index 530b0bc24aff033aba11b9c1f218ca1e9a4c5c7e..1ab03e4c14a9f025e73220d9bb0d4558641e5f6a 100644 --- a/inc/lang/de/lang.php +++ b/inc/lang/de/lang.php @@ -247,3 +247,10 @@ $lang['mu_filetypes'] = 'Erlaubte Dateitypen'; $lang['mu_info'] = 'Dateien hochgeladen!'; $lang['mu_lasterr'] = 'Letzter Fehler:'; $lang['recent_global'] = 'Im Moment sehen Sie die Änderungen im Namensraum <b>%s</b>. Sie können auch <a href="%s">die Änderungen im gesamten Wiki sehen</a>.'; + +$lang['years'] = 'vor %d Jahren'; +$lang['months'] = 'vor %d Monaten'; +$lang['weeks'] = 'vor %d Wochen'; +$lang['days'] = 'vor %d Tagen'; +$lang['hours'] = 'vor %d Stunden'; +$lang['seconds'] = 'vor %d Sekunden'; diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index fbde8cab06893215ff6e0c87afc9ac3f98a88b5e..dfe45bf83bf06b32d1bf92deb495fb44349595af 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -269,11 +269,11 @@ $lang['mu_lasterr'] = 'Last error:'; $lang['recent_global'] = 'You\'re currently watching the changes inside the <b>%s</b> namespace. You can also <a href="%s">view the recent changes of the whole wiki</a>.'; -$lang['years'] = '%d years'; -$lang['months'] = '%d months'; -$lang['weeks'] = '%d weeks'; -$lang['days'] = '%d days'; -$lang['hours'] = '%d hours'; -$lang['seconds'] = '%d seconds'; +$lang['years'] = '%d years ago'; +$lang['months'] = '%d months ago'; +$lang['weeks'] = '%d weeks ago'; +$lang['days'] = '%d days ago'; +$lang['hours'] = '%d hours ago'; +$lang['seconds'] = '%d seconds ago'; //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/inc/media.php b/inc/media.php index 4ad7047b2024066339cf20481b332c1aa63d38b3..2a45b6d805647801bdf275c2f7f8beaccd9c205d 100644 --- a/inc/media.php +++ b/inc/media.php @@ -404,7 +404,7 @@ function media_notify($id,$file,$mime){ $ip = clientIP(); $text = rawLocale('uploadmail'); - $text = str_replace('@DATE@',strftime($conf['dformat']),$text); + $text = str_replace('@DATE@',dformat(),$text); $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text); $text = str_replace('@IPADDRESS@',$ip,$text); $text = str_replace('@HOSTNAME@',gethostsbyaddrs($ip),$text); @@ -570,7 +570,7 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ $info .= (int) $item['meta']->getField('File.Height'); $info .= ' '; } - $info .= '<i>'.strftime($conf['dformat'],$item['mtime']).'</i>'; + $info .= '<i>'.dformat($item['mtime']).'</i>'; $info .= ' '; $info .= filesize_h($item['size']); diff --git a/inc/template.php b/inc/template.php index c181c164c815d9b97f3894a50c27912337d0f414..e26c5202a1dfcff04c7654ef55ca2fcf342587c1 100644 --- a/inc/template.php +++ b/inc/template.php @@ -958,7 +958,7 @@ function tpl_pageinfo($ret=false){ } } $fn = utf8_decodeFN($fn); - $date = strftime($conf['dformat'],$INFO['lastmod']); + $date = dformat($INFO['lastmod']); // print it if($INFO['exists']){ diff --git a/inc/toolbar.php b/inc/toolbar.php index a1851c7467e73c440c2c0c9ead4256ce0f0c714e..701723b583adf57e08abfbd6124de78367eb8fd7 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -236,7 +236,7 @@ function toolbar_signature(){ $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig); $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig); $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig); - $sig = str_replace('@DATE@',strftime($conf['dformat']),$sig); + $sig = str_replace('@DATE@',dformat(),$sig); $sig = str_replace('\\\\n','\\n',addslashes($sig)); return $sig; } diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 4d9a8105ac3139c95cc8582bdf961e0eb6a83665..4618abd711e18f243c009ebdb8c9cca23f6628d7 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -152,7 +152,7 @@ function ajax_lock(){ ); $cname = getCacheName($draft['client'].$id,'.draft'); if(io_saveFile($cname,serialize($draft))){ - echo $lang['draftdate'].' '.strftime($conf['dformat']); + echo $lang['draftdate'].' '.dformat(); } } diff --git a/lib/tpl/default/detail.php b/lib/tpl/default/detail.php index 76535856805dccd4017dc0ac715d58e41b3b65f1..4f42b116e4beed01395cb5d4839ab01398b0c562 100644 --- a/lib/tpl/default/detail.php +++ b/lib/tpl/default/detail.php @@ -53,7 +53,7 @@ if (!defined('DOKU_INC')) die(); <dl class="img_tags"> <?php $t = tpl_img_getTag('Date.EarliestTime'); - if($t) print '<dt>'.$lang['img_date'].':</dt><dd>'.strftime($conf['dformat'],$t).'</dd>'; + if($t) print '<dt>'.$lang['img_date'].':</dt><dd>'.dformat($t).'</dd>'; $t = tpl_img_getTag('File.Name'); if($t) print '<dt>'.$lang['img_fname'].':</dt><dd>'.hsc($t).'</dd>';