Translations of this page?:

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 orginal 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(array_keys($recents) as $id){
    if(date("Y-m-d",$recents[$id]['date']) != $cdate){
 
      echo '<h1><b>',date($conf['dformat'],$recents[$id]['date']),'</b></h1>',"\n";
 
      $cdate = date("Y-m-d",$recents[$id]['date']);
 
     }
 
    $date = date($conf['dformat'],$recents[$id]['date']);
 
    print '<div class="level2">';
 
    print $date.' '.html_wikilink($id,$id);
 
    print '<a href="'.wl($recents[$id]['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($recents[$id]['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(':'.$recents[$id]['id'],$conf['useheading']?NULL:$recents[$id]['id']);
    print ' '.htmlspecialchars($recents[$id]['sum']);
    print ' <span class="user">';
    if($recents[$id]['user']){
      print $recents[$id]['user'];
      // if you prefer display the real name instead of the username
      // comment the previous line  "print $recents[$id]['user'];" 
      // and decomment the 2 following lines 
      // $userdata = auth_getUserData($recents[$id]['user']);
      // print $userdata['name'];
    }else{
      print $recents[$id]['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(array_keys($recents) as $id){
    if(date("Y-m-d",$recents[$id]['date']) != $cdate){
 
      echo '<h1><b>',date("F d, Y",$recents[$id]['date']),'</b></h1>',"\n";
      $cdate = date("Y-m-d",$recents[$id]['date']);
     }
 
    $date = date('H:i',$recents[$id]['date']);
 
    print '<div class="level2">';
    print $date.' '.html_wikilink($id,$id);
    print ' '.htmlspecialchars($recents[$id]['sum']);
    print ' <span class="user">(';
    print $recents[$id]['ip'];
    if($recents[$id]['user']) print ' '.$recents[$id]['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($recents[$id]['user']){
      print $recents[$id]['user'];
to:
    if($recents[$id]['user']){
      $userdata = auth_getUserData($recents[$id]['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
 
wiki/tips/prettyrecentfix.txt · Last modified: 2005/10/17 21:40 by 80.119.101.27
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate