BUGFIX: Fixed bugs in content differencer, and improved styling.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@77661 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-05-23 03:30:57 +00:00
parent ef2c47feb8
commit 646ed9342a
3 changed files with 13 additions and 8 deletions

View File

@ -847,12 +847,16 @@ JS;
$record = $page->compareVersions($fromVersion, $toVersion); $record = $page->compareVersions($fromVersion, $toVersion);
$fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion); $fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion);
$toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion); $toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion);
if(!$fromVersionRecord) user_error("Can't find version $fromVersion of page $id", E_USER_ERROR);
if(!$toVersionRecord) user_error("Can't find version $toVersion of page $id", E_USER_ERROR);
if($record) { if($record) {
$fromDateNice = $fromVersionRecord->obj('LastEdited')->Ago(); $fromDateNice = $fromVersionRecord->obj('LastEdited')->Ago();
$toDateNice = $toVersionRecord->obj('LastEdited')->Ago(); $toDateNice = $toVersionRecord->obj('LastEdited')->Ago();
$fromAuthor = DataObject::get_by_id('Member', $fromVersionRecord->AuthorID); $fromAuthor = DataObject::get_by_id('Member', $fromVersionRecord->AuthorID);
if(!$fromAuthor) $fromAuthor = new ArrayData(array('Title' => 'Unknown author'));
$toAuthor = DataObject::get_by_id('Member', $toVersionRecord->AuthorID); $toAuthor = DataObject::get_by_id('Member', $toVersionRecord->AuthorID);
if(!$toAuthor) $toAuthor = new ArrayData(array('Title' => 'Unknown author'));
$fields = $record->getCMSFields($this); $fields = $record->getCMSFields($this);
$fields->push(new HiddenField("ID")); $fields->push(new HiddenField("ID"));

View File

@ -664,9 +664,12 @@ class Diff
// First split up the content into words and tags // First split up the content into words and tags
$set1 = self::getHTMLChunks($from); $set1 = self::getHTMLChunks($from);
$set2 = self::getHTMLChunks($to); $set2 = self::getHTMLChunks($to);
// Diff that // Diff that
$diff = new Diff($set1, $set2); $diff = new Diff($set1, $set2);
$tagStack[1] = $tagStack[2] = 0;
$rechunked[1] = $rechunked[2] = array();
// Go through everything, converting edited tags (and their content) into single chunks. Otherwise // Go through everything, converting edited tags (and their content) into single chunks. Otherwise
// the generated HTML gets crusty // the generated HTML gets crusty
@ -704,12 +707,12 @@ class Diff
if($chunks) { if($chunks) {
foreach($chunks as $item) { foreach($chunks as $item) {
// $tagStack > 0 indicates that we should be tag-building // $tagStack > 0 indicates that we should be tag-building
if(isset($tagStack[$listName])) $rechunked[$listName][sizeof($rechunked[$listName])-1] .= ' ' . $item; if($tagStack[$listName]) $rechunked[$listName][sizeof($rechunked[$listName])-1] .= ' ' . $item;
else $rechunked[$listName][] = $item; else $rechunked[$listName][] = $item;
if($lookForTag && isset($item[0]) && $item[0] == "<" && substr($item,0,2) != "</") { if($lookForTag && isset($item[0]) && $item[0] == "<" && substr($item,0,2) != "</") {
$tagStack[$listName] = 1; $tagStack[$listName] = 1;
} else if(isset($tagStack[$listName])) { } else if($tagStack[$listName]) {
if(substr($item,0,2) == "</") $tagStack[$listName]--; if(substr($item,0,2) == "</") $tagStack[$listName]--;
else if(isset($item[0]) && $item[0] == "<") $tagStack[$listName]++; else if(isset($item[0]) && $item[0] == "<") $tagStack[$listName]++;
} }
@ -719,7 +722,6 @@ class Diff
} }
} }
} }
// Diff the re-chunked data, turning it into maked up HTML // Diff the re-chunked data, turning it into maked up HTML
$diff = new Diff($rechunked[1], $rechunked[2]); $diff = new Diff($rechunked[1], $rechunked[2]);

View File

@ -394,15 +394,14 @@ ul.tree span.untranslated a:visited {
width: 70%; width: 70%;
} }
/* Change detection CSS */
#right ins, #right ins * { #right ins, #right ins * {
background-color: green; background-color: #99EE66;
color: white;
text-decoration: none; text-decoration: none;
} }
#right del, #right del *{ #right del, #right del *{
background-color: red; background-color: #FF9999;
color: white;
text-decoration: strikethough; text-decoration: strikethough;
} }