tips:prettyrecentfix
This is an old revision of the document!
Table of Contents
Introduction
This tips gives you a “Recents” page in a more pretty way. You have the different changes set by day.
This is an updated and enhanced version of the original work of http://ktyp.com/dev/doku/dokuwiki/hacks/prettyrecent and the “old version” below and the Dokuwiki source. Thanks to the original authors of this work. — Jean-Philippe Georget 2005-10-17 11:26
HowTo
for 2005-09-19 version
To obtain pretty recents pages, in your ./inc/html.php file, replace the html_recent() function with:
function html_recent($first=0){ global $conf; global $lang; global $ID; $recents = getRecents($first,$conf['recent'] + 1,true,getNS($ID)); print p_locale_xhtml('recent'); // counter initialization $cdate = '0000-00-00'; echo $recents[$id]['date']; foreach($recents as $id => $val){ if(date("Y-m-d",$val['date']) != $cdate){ echo '<h1><b>',date($conf['dformat'],$val['date']),'</b></h1>',"\n"; $cdate = date("Y-m-d",$val['date']); } $date = date($conf['dformat'],$val['date']); print '<div class="level2">'; print $date.' '.html_wikilink($id,$id); print '<a href="'.wl($val['id'],"do=diff").'">'; $p = array(); $p['src'] = DOKU_BASE.'lib/images/diff.png'; $p['border'] = 0; $p['width'] = 15; $p['height'] = 11; $p['title'] = $lang['diff']; $p['alt'] = $lang['diff']; $att = buildAttributes($p); print "<img $att />"; print '</a> '; print '<a href="'.wl($val['id'],"do=revisions").'">'; $p = array(); $p['src'] = DOKU_BASE.'lib/images/history.png'; $p['border'] = 0; $p['width'] = 12; $p['height'] = 14; $p['title'] = $lang['btn_revs']; $p['alt'] = $lang['btn_revs']; $att = buildAttributes($p); print "<img $att />"; print '</a> '; print html_wikilink(':'.$val['id'],$conf['useheading']?NULL:$val['id']); print ' '.htmlspecialchars($val['sum']); print ' <span class="user">'; if($val['user']){ print $val['user']; // if you prefer display the real name instead of the username // comment the previous line "print $val['user'];" // and decomment the 2 following lines // $userdata = auth_getUserData($val['user']); // print $userdata['name']; }else{ print $val['ip']; } print '</span>'; print '</div>'; print "\n"; } print '<div class="pagenav">'; $last = $first + $conf['recent']; if ($first > 0) { $first -= $conf['recent']; if ($first < 0) $first = 0; print '<div class="pagenav-prev">'; print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); print '</div>'; } if ($conf['recent'] < count($recents)) { print '<div class="pagenav-next">'; print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); print '</div>'; } print '</div>'; }
Old version
I updated this script to work with the July 1st Revision.
function html_recent($first=0){ global $conf; global $lang; /* we need to get one additionally log entry to be able to * decide if this is the last page or is there another one. * This is the cheapest solution to get this information. */ $recents = getRecents($first,$conf['recent'] + 1,true); if(count($recents) == 0 && $first != 0){ $first=0; $recents = getRecents(0,$conf['recent'] + 1,true); } $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; print p_locale_xhtml('recent'); $cdate = '0000-00-00'; foreach($recents as $id => $val){ if(date("Y-m-d",$val['date']) != $cdate){ echo '<h1><b>',date("F d, Y",$val['date']),'</b></h1>',"\n"; $cdate = date("Y-m-d",$val['date']); } $date = date('H:i',$val['date']); print '<div class="level2">'; print $date.' '.html_wikilink($id,$id); print ' '.htmlspecialchars($val['sum']); print ' <span class="user">('; print $val['ip']; if($val['user']) print ' '.$val['user']; print ')</span>'; print '</div>'; print "\n"; } }
Discussion
- Could it be included in the main source (perhaps as an option) ?
If you want the real name instead of the username on each line, change the following:
if($val['user']){ print $val['user'];
to:
if($val['user']){ $userdata = auth_getUserData($val['user']); print $userdata['name'];
— ChristopherArndt 2005-10-17 13:22
Thanks, I added your tip as an “option” in the code Sometimes, you don't want to have the real names appear on the web site. Jean-Philippe Georget 2005-10-17 21:37
tips/prettyrecentfix.1266863519.txt.gz · Last modified: 2010-02-22 19:31 by 74.93.99.97