".XL('deleted:')." ";
$DoubleBrackets['/^-ce-c-.+$/'] = "
".XL('changed from:')." ";
$DoubleBrackets['/^-ce-t-.+$/'] = "".XL('to:')." ";
$DoubleBrackets['/^-ce-f-.+$/'] = "
";
function HandleConcurrentEdit($pagename) {
global $restore,$preview,$HandleActions,$Text,
$HandleEditFmt,$PageStartFmt,$PageEditFmt,$PagePreviewFmt,$PageEndFmt,$EditMessageFmt,
$DiffClassMinor,$PatchFunction,
$EditLastRev, $ConcurrentEditFmt;
$page = RetrieveAuthPage($pagename,"edit");
if( $page ) {
$EditLastRev = $page['rev'];
## Change the edit form to include the hidden time field
## Note the regexp!
$PageEditFmt = preg_replace('/(?=\
", $PageEditFmt, 1);
}
if (@$_POST['post']) {
$PreEditRev = @$_REQUEST['startedit'];
if( !isset($PreEditRev) || !isset($EditLastRev) || ($PreEditRev >= $EditLastRev) ) {
$handle = $HandleActions['post'];
return $handle($pagename);
}
// somebody have modified page text while we were editing it
$concur = 'Concur';
$EditMessageFmt .= $ConcurrentEditFmt;
}
// the rest is copy-pasted from pmwiki.php 1:1
if (!$page) { Abort("?cannot edit $pagename"); }
SetPageVars($pagename,$page,"Edit $pagename");
if ($restore && $PatchFunction) { $text = $PatchFunction($page,$restore); }
else if ($preview) { $text = stripmagic($_POST['text']); }
// except this line:
else if ($concur) { $text = MergeWithPage(str_replace("\r","",stripmagic($_POST['text'])), $page['text']); }
else { $text = $page['text']; }
$Text = $text;
$DiffClassMinor = '';
if (@$_POST['diffclass']=='minor') $DiffClassMinor="checked='checked'";
SDV($HandleEditFmt,array(&$PageStartFmt,
&$PageEditFmt,
&$PagePreviewFmt,
&$PageEndFmt));
PrintFmt($pagename,$HandleEditFmt);
}
// Does some kind of a merge function.
// It simply does diff and inserts results into a page
// offering user to apply changes, removing informational
// lines.
function MergeWithPage($newtext, $oldtext) {
global $DiffFunction, $MergeLineWidth;
$MergeAddHeader = str_pad(' '.XL('added:'), $MergeLineWidth, '-', STR_PAD_LEFT);
$MergeDeleteHeader = str_pad(' '.XL('removed:'), $MergeLineWidth, '-', STR_PAD_LEFT);
$MergeChangeFromHeader = str_pad(' '.XL('changed from:'), $MergeLineWidth, '-', STR_PAD_LEFT);
$MergeChangeToHeader = str_pad(' '.XL('to:'), $MergeLineWidth, '-', STR_PAD_LEFT);
$MergeFooter = str_repeat('-', $MergeLineWidth);
$diff = $DiffFunction($oldtext, $newtext);
# echo '
'.$diff.' ';
$d = explode("\n", $diff);
$t = explode("\n", $oldtext);
// initializing line offsets array
//$o = array_fill(0, count($t)+1, 0);
$o = array();
for($i=0;$i<=count($t);$i++) $o[] = $i;
// now applying changes... in our way
$insend = 0;
foreach($d as $x) {
if (preg_match('/^(\\d+)(?:,(\\d+))?([adc])(\\d+)(?:,(\\d+))?/',$x,$match)) {
if($insend>0) {
array_splice($t,$o[$insend],0,'-ce-f-'.$MergeFooter);
for($i=$insend;$i
(.*)$/',$x,$match)) {
array_splice($t,$o[$b1-1],0,$match[1]);
for($i=$b1-1; $i0) {
array_splice($t,$o[$insend],0,'-ce-f-'.$MergeFooter);
for($i=$insend;$i