====== Diff ====== This set of changes allows diffs between any two versions of the existing file. ===== Sample Screenshots ===== ==== First (original) Screenshot ==== {{http://www.boelter.org/images/diff.png}} ==== Second Screenshot ==== update by ryan on 1-15-2006 (new, more expansive and descriptive layout in a table) * I created a more organized and symetrical diff layout. I can post the code if interested, leave a message. * I would prefer to just have a single column of radio button or checkboxes like phpwiki (I think two radio buttons per line is too confusing). I doubt anyone would need to do a reverse diff and the second radio button may just confuse some users. I'd also like to highlight the table row onclick, but I don't know how to do that. {{http://www.sevaa.net/images/multi-select-diff2.png}} To use the alternative layout above, you need change the //function html_revisions()// in /inc/html.php in addition to all the other changes described on this page for implement the multiple diffs. They are all HTML layout changes. I don't have a specific list of the changes, but the function is rather short. So, I pasted this function in its entirety below. Do these changes last AFTER you've done all the other changes described on this page. /** * list old revisions * * @author Andreas Gohr */ function html_revisions(){ global $ID; global $INFO; global $conf; global $lang; $revisions = getRevisions($ID); $date = @date($conf['dformat'],$INFO['lastmod']); //print ''; print p_locale_xhtml('revisions'); print '

'.$ID.'

'; print '
'; print ''; print ''; print ' = COMPARE TO CURRENT VERSION
Select Any Two: Compare to
Current Version:
Edited on: View Page Version: Editor\'s comments (if any): Edited by:
'; // print '
    '; if($INFO['exists']){ // print ($INFO['minor']) ? '
  • ' : '
  • '; print '
'; print ' '; print ''; print ''; } $checked = false; foreach($revisions as $rev){ $date = date($conf['dformat'],$rev); $info = getRevisionInfo($ID,$rev); print ''; print ''; print ''; print ''; // print ''; } // print ''; print '
'; //print ''; print ''; print '('.$lang['current'].')'; print ''; print $date; print 'current'; // print '.$ID.'; print ' '; print $INFO['sum']; print ''; print $INFO['editor']; print ''; print '
'; //print ($info['minor']) ? '
  • ' : '
  • '; print ''; print ''; print ''; if( !$checked ){ print ''; $checked = true; } else print '
  • '; $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 ""; print ' '; print $date; print 'older version '; print htmlspecialchars($info['sum']); print ''; if($info['user']){ print $info['user']; }else{ print $info['ip']; } print '
    '; }
    ===== How it works ===== I also started extending the diff function to (maybe?) allow linking to the current revision with a rev tag even though it hasn't been archived in the attic yet. Linking to a diff between two revs looks this: http://localhost/doku.php?id=start&do=diff&rev=1110935500&rev2=1110848901 ^ Parameter ^ Required ^ Default ^ Notes ^ | id | yes | NA | The usual wiki id | | do | yes | NA | The diff action | | rev | no | current | The first revision date to diff | | rev2 | no | current | The second revision date to diff | ===== DOKU.PHP DIFF ===== This is a diff against the 2006-03-09 release. The only change was to parse out rev2 in addition to rev. --- doku.php.orig 2006-04-15 18:58:52.000000000 -0700 +++ doku.php 2006-04-15 17:57:15.000000000 -0700 @@ -20,6 +20,7 @@ $QUERY = trim($_REQUEST['id']); $ID = getID(); $REV = $_REQUEST['rev']; + $REV2 = $_REQUEST['rev2']; $ACT = $_REQUEST['do']; $IDX = $_REQUEST['idx']; $DATE = $_REQUEST['date']; ===== HTML.PHP DIFF ===== This diff modifies two functions html_revisions() and html_diff(). html_revisions() now creates a form that links back to doku.php with rev and rev2 parameters for the files to be compared. The method uses two columns of radio buttons similar to MediaWiki (but not nearly as fancy). html_diff() is now modifed (it is very verbose to document the how) to compare //rev vs rev2//, //current vs rev2// or //rev vs current//. If rev or rev2 is the same as the filemtime of the current revision, rev/rev2 will be set to %%''%% to force a compare to the current revision. [Checking against the current filemtime appears to work, and I think it should always work.] --- html.php.orig 2006-03-09 12:32:34.000000000 -0800 +++ html.php 2006-04-15 18:48:19.000000000 -0700 @@ -421,11 +421,22 @@ $date = @date($conf['dformat'],$INFO['lastmod']); print p_locale_xhtml('revisions'); - print '