ENHANCEMENT More readable (and linked) output of "you are comparing..." message when viewing version of a page

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@69322 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-12-17 02:49:44 +00:00 committed by Sam Minnee
parent 89eec30d48
commit fa8e4a12a6
2 changed files with 56 additions and 11 deletions

View File

@ -710,6 +710,7 @@ JS;
$id = $this->urlParams['ID'];
$version = str_replace('&ajax=1','',$this->urlParams['OtherID']);
$record = Versioned::get_version("SiteTree", $id, $version);
$versionAuthor = DataObject::get_by_id('Member', $record->AuthorID);
if($record) {
if($record && !$record->canView()) return Security::permissionFailure($this);
@ -719,8 +720,25 @@ JS;
$fields->push(new HiddenField("ID"));
$fields->push(new HiddenField("Version"));
$fields->push(new HeaderField('YouAreViewingHeader', sprintf(_t('CMSMain.VIEWING',"You are viewing version #%d, created %s"),
$version, $record->obj('LastEdited')->Ago())));
$fields->insertBefore(
new LiteralField(
'YouAreViewingHeader',
'<p class="message notice">' .
sprintf(
_t(
'CMSMain.VIEWING',
"You are viewing version #%s, created %s by %s",
PR_MEDIUM,
'Version number is a linked string, created is a relative time (e.g. 2 days ago), by a specific author'
),
"<a href=\"admin/getversion/$record->ID/$version\" title=\"" . $versionAuthor->Title . "\">$version</a>",
$record->obj('LastEdited')->Ago(),
$versionAuthor->Title
) .
'</p>'
),
'Root'
);
$actions = new FieldSet(
new FormAction("email", _t('CMSMain.EMAIL',"Email")),
@ -754,16 +772,23 @@ JS;
));
SSViewer::setOption('rewriteHashlinks', false);
$result = $templateData->renderWith($this->class . '_right');
$parts = split('</?form[^>]*>', $result);
return $parts[sizeof($parts)-2];
if(Director::is_ajax()) {
$result = $templateData->renderWith($this->class . '_right');
$parts = split('</?form[^>]*>', $result);
return $parts[sizeof($parts)-2];
} else {
return $templateData->renderWith('LeftAndMain');
}
}
}
function compareversions() {
$id = $this->urlParams['ID'];
$version1 = $_REQUEST['From'];
$version2 = $_REQUEST['To'];
$id = (int)$this->urlParams['ID'];
$version1 = (int)$_REQUEST['From'];
$version2 = (int)$_REQUEST['To'];
if( $version1 > $version2 ) {
$toVersion = $version1;
@ -777,11 +802,31 @@ JS;
if($page && !$page->canView()) return Security::permissionFailure($this);
$record = $page->compareVersions($fromVersion, $toVersion);
$fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion);
$toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion);
if($record) {
$fromDateNice = $fromVersionRecord->obj('LastEdited')->Ago();
$toDateNice = $toVersionRecord->obj('LastEdited')->Ago();
$fromAuthor = DataObject::get_by_id('Member', $fromVersionRecord->AuthorID);
$toAuthor = DataObject::get_by_id('Member', $toVersionRecord->AuthorID);
$fields = $record->getCMSFields($this);
$fields->push(new HiddenField("ID"));
$fields->push(new HiddenField("Version"));
$fields->insertBefore(new HeaderField('YouAreComparingHeader',sprintf(_t('CMSMain.COMPARINGV',"You are comparing versions #%d and #%d"),$fromVersion,$toVersion)), "Root");
$fields->insertBefore(
new LiteralField(
'YouAreComparingHeader',
'<p class="message notice">' .
sprintf(
_t('CMSMain.COMPARINGV',"Comparing versions %s and %s"),
"<a href=\"admin/getversion/$id/$fromVersionRecord->Version\" title=\"$fromAuthor->Title\">$fromVersionRecord->Version</a> <small>($fromDateNice)</small>",
"<a href=\"admin/getversion/$id/$toVersionRecord->Version\" title=\"$toAuthor->Title\">$toVersionRecord->Version</a> <small>($toDateNice)</small>"
) .
'</p>'
),
"Root"
);
$actions = new FieldSet();

View File

@ -76,7 +76,7 @@ $lang['en_US']['CMSMain']['ACCESS'] = array(
$lang['en_US']['CMSMain']['ACCESSALLINTERFACES'] = 'Access to all CMS interfaces';
$lang['en_US']['CMSMain']['CANCEL'] = 'Cancel';
$lang['en_US']['CMSMain']['CHOOSEREPORT'] = '(Choose a report)';
$lang['en_US']['CMSMain']['COMPARINGV'] = 'You are comparing versions #%d and #%d';
$lang['en_US']['CMSMain']['COMPARINGV'] = 'You are comparing versions %s and %s';
$lang['en_US']['CMSMain']['COPYPUBTOSTAGE'] = 'Do you really want to copy the published content to the stage site?';
$lang['en_US']['CMSMain']['DELETE'] = 'Delete from the draft site';
$lang['en_US']['CMSMain']['DESCREMOVED'] = 'and %s descendants';
@ -135,7 +135,7 @@ $lang['en_US']['CMSMain']['VERSIONSNOPAGE'] = array(
'Can\'t find page #%d',
PR_LOW
);
$lang['en_US']['CMSMain']['VIEWING'] = 'You are viewing version #%d, created %s';
$lang['en_US']['CMSMain']['VIEWING'] = 'You are viewing version %s, created %s by %s';
$lang['en_US']['CMSMain']['VISITRESTORE'] = array(
'visit restorepage/(ID)',
PR_LOW,