diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2011-01-31 14:00:32 +0100 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2011-01-31 14:00:32 +0100 |
commit | 7216538165621816dc3f751adc0746bf66805421 (patch) | |
tree | 4dc0af079985a6e43873d5ec2230dd6b3fade78c | |
parent | c495dc45dedcf43c372ac75d0f966501950bfb6e (diff) | |
download | rpg-7216538165621816dc3f751adc0746bf66805421.tar.gz rpg-7216538165621816dc3f751adc0746bf66805421.tar.bz2 |
Make diff type selectable
-rw-r--r-- | inc/html.php | 46 | ||||
-rw-r--r-- | inc/lang/en/lang.php | 3 | ||||
-rw-r--r-- | lib/tpl/default/design.css | 6 |
3 files changed, 48 insertions, 7 deletions
diff --git a/inc/html.php b/inc/html.php index b962c6075..7abb05d2e 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 9ccbe14e0..8abd4314c 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 09a9ecf01..42f9f622e 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 { |