function diff2($page1, $page2) { $page1 = split("\n", $page1); $page2 = split("\n", $page2); $z = new WikiDiff($page1, $page2); if ($z->isEmpty()) { $html = '<hr><br />[' . tra("Versions are identical") . ']<br /><br />'; } else { //$fmt = new WikiDiffFormatter; $fmt = new WikiUnifiedDiffFormatter(); $html = $fmt->format($z, $page1); } return $html; }
$to_version = $gContent->mInfo["version"]; $to_lines = explode("\n", $gContent->mInfo["data"]); } /** * run 'pear install Text_Diff' to install the library, */ if ($gBitSystem->isFeatureActive('liberty_inline_diff') && @(include_once 'Text/Diff.php')) { include_once 'Text/Diff/Renderer/inline.php'; $diff = new Text_Diff($from_lines, $to_lines); $renderer = new Text_Diff_Renderer_inline(); $html = $renderer->render($diff); } else { include_once UTIL_PKG_PATH . 'diff.php'; $diffx = new WikiDiff($from_lines, $to_lines); $fmt = new WikiUnifiedDiffFormatter(); $html = $fmt->format($diffx, $from_lines); } $gBitSmarty->assign('diffdata', $html); $gBitSmarty->assign('diff2', 'y'); $gBitSmarty->assign('version_from', $from_version); $gBitSmarty->assign('version_to', $to_version); } elseif (@BitBase::verifyId($_REQUEST["compare"])) { $from_version = $_REQUEST["compare"]; $from_page = $gContent->getHistory($from_version); $from_page['data'][0]['no_cache'] = TRUE; $gBitSmarty->assign('compare', 'y'); $gBitSmarty->assign_by_ref('diff_from', $gContent->parseData($from_page['data'][0])); $gBitSmarty->assign_by_ref('diff_to', $gContent->parseData()); $gBitSmarty->assign_by_ref('version_from', $from_version); } elseif (@BitBase::verifyId($_REQUEST["rollback"])) { $gContent->verifyUserPermission(!empty($rollbackPerm) ? $rollbackPerm : $gContent->mUpdateContentPerm);
$aText = $aLang == "en" ? "Archived page:" : "Page archivée :"; $html .= "<dl><dt>{$aText}</dt>"; if (is_array($archive)) { $html .= "\n<dd>"; $html .= sprintf(gettext("Version %s"), $archive['version']); $html .= "\n</dd><dd>"; $aText = $aLang == "en" ? "Last modified on %s" : "Dernière modification : %s"; $html .= sprintf($aText, date($datetimeformat, $archive['lastmodified'])); $html .= "\n</dd><dd>"; $aText = $aLang == "en" ? "By %s" : "Par %s"; $html .= sprintf($aText, $archive['author']); $html .= "</dd>"; } else { $html .= "<dd><em>"; $html .= $aLang == "en" ? "None" : "Aucune"; $html .= "</em></dd>"; } $html .= "</dl></div>\n"; if (is_array($wiki) && is_array($archive)) { $diff = new WikiDiff($archive['content'], $wiki['content']); if ($diff->isEmpty()) { $aText = $aLang == "en" ? "Versions are identical" : "Les versions sont identiques"; $html .= '<hr>[' . $aText . ']'; } else { //$fmt = new WikiDiffFormatter; $fmt = new WikiUnifiedDiffFormatter(); $html .= $fmt->format($diff, $archive['content']); } } GeneratePage('MESSAGE2', $html, sprintf("Diff %s", htmlspecialchars($pagename)), 0); }