diff --git a/inc/html.php b/inc/html.php index b962c60753c33e8255d180882e57fc590bc5f17b..7abb05d2e4782b2dda26ef8ea34019113c95a92f 100644 --- a/inc/html.php +++ b/inc/html.php @@ -870,13 +870,18 @@ function html_backlinks(){ * show diff * * @author Andreas Gohr <andi@splitbrain.org> + * @param string $text - compare with this text with most current version + * @param bool $intr - display the intro text */ -function html_diff($text='',$intro=true){ +function html_diff($text='',$intro=true,$type=null){ global $ID; global $REV; global $lang; global $conf; + if(!$type) $type = $_REQUEST['difftype']; + if($type != 'inline') $type = 'sidebyside'; + // we're trying to be clever here, revisions to compare can be either // given as rev and rev2 parameters, with rev2 being optional. Or in an // array in rev2. @@ -993,17 +998,48 @@ function html_diff($text='',$intro=true){ $df = new Diff(explode("\n",htmlspecialchars($l_text)), explode("\n",htmlspecialchars($r_text))); - $tdf = new TableDiffFormatter(); + if($type == 'inline'){ + $tdf = new InlineDiffFormatter(); + } else { + $tdf = new TableDiffFormatter(); + } + + + if($intro) print p_locale_xhtml('diff'); if (!$text) { - $diffurl = wl($ID, array('do'=>'diff', 'rev2[0]'=>$l_rev, 'rev2[1]'=>$r_rev)); ptln('<p class="difflink">'); - ptln(' <a class="wikilink1" href="'.$diffurl.'">'.$lang['difflink'].'</a>'); + + $form = new Doku_Form(array('action'=>wl())); + $form->addHidden('ID',$ID); + $form->addHidden('rev2[0]',$l_rev); + $form->addHidden('rev2[1]',$r_rev); + $form->addHidden('do','diff'); + $form->addElement(form_makeListboxField( + 'difftype', + array( + 'sidebyside' => $lang['diff_side'], + 'inline' => $lang['diff_inline']), + $type, + $lang['diff_type'], + '','', + array('class'=>'quickselect'))); + $form->addElement(form_makeButton('submit', 'diff','Go')); + $form->printForm(); + + + $diffurl = wl($ID, array( + 'do' => 'diff', + 'rev2[0]' => $l_rev, + 'rev2[1]' => $r_rev, + 'difftype' => $type, + )); + ptln('<br /><a class="wikilink1" href="'.$diffurl.'">'.$lang['difflink'].'</a>'); ptln('</p>'); } ?> - <table class="diff"> + <table class="diff diff_<?php echo $type?>"> <tr> <th colspan="2" <?php echo $l_minor?>> <?php echo $l_head?> diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 9ccbe14e0d553e172acb8b64448ae6e45803f478..8abd4314cbf1a644efc258eddeb3745cd8ab8df3 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -164,6 +164,9 @@ $lang['yours'] = 'Your Version'; $lang['diff'] = 'Show differences to current revisions'; $lang['diff2'] = 'Show differences between selected revisions'; $lang['difflink'] = 'Link to this comparison view'; +$lang['diff_type'] = 'View differences:'; +$lang['diff_inline']= 'Inline'; +$lang['diff_side'] = 'Side by Side'; $lang['line'] = 'Line'; $lang['breadcrumb'] = 'Trace'; $lang['youarehere'] = 'You are here'; diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css index 09a9ecf016e9ff54a7a3d1b87bcc600f58d6095e..42f9f622e517bc29b9c3ec0c417831947d8673a1 100644 --- a/lib/tpl/default/design.css +++ b/lib/tpl/default/design.css @@ -652,10 +652,12 @@ div.dokuwiki table.diff td { font-family: monospace; font-size: 100%; } -div.dokuwiki td.diff-addedline { +div.dokuwiki td.diff-addedline, +div.dokuwiki span.diff-addedline { background-color: #ddffdd; } -div.dokuwiki td.diff-deletedline { +div.dokuwiki td.diff-deletedline, +div.dokuwiki span.diff-deletedline { background-color: #ffffbb; } div.dokuwiki td.diff-context {