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 /inc/html.php | |
parent | c495dc45dedcf43c372ac75d0f966501950bfb6e (diff) | |
download | rpg-7216538165621816dc3f751adc0746bf66805421.tar.gz rpg-7216538165621816dc3f751adc0746bf66805421.tar.bz2 |
Make diff type selectable
Diffstat (limited to 'inc/html.php')
-rw-r--r-- | inc/html.php | 46 |
1 files changed, 41 insertions, 5 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?> |