BUG Use AbsoluteLiveLink() for CMS previews

It uses the correct live URLSegments for its parents
by setting the global Versioned reading mode correctly,
see 8a514d8b64 for detail.
This commit is contained in:
Ingo Schommer 2012-08-28 19:07:12 +02:00
parent 8a514d8b64
commit cec461b767

View File

@ -573,22 +573,21 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$fields->push($idField = new HiddenField("ID", false, $id));
// Necessary for different subsites
$fields->push($liveURLField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
$fields->push($liveURLField = new HiddenField("LiveLink"));
$fields->push($stageURLField = new HiddenField("StageLink"));
$fields->push($liveLinkField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
$fields->push($liveLinkField = new HiddenField("LiveLink"));
$fields->push($stageLinkField = new HiddenField("StageLink"));
$fields->push(new HiddenField("TreeTitle", false, $record->TreeTitle));
$fields->push(new HiddenField('Sort','', $record->Sort));
if($record->ID && is_numeric( $record->ID ) ) {
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $record->ID");
if($liveRecord) {
$liveURLField->setValue(Controller::join_links($liveRecord->AbsoluteLink(), '?stage=Live'));
$liveLink = $record->getAbsoluteLiveLink();
if($liveLink) $liveLinkField->setValue($liveLink);
if(!$deletedFromStage) {
$stageLink = Controller::join_links($record->AbsoluteLink(), '?stage=Stage');
if($stageLink) $stageLinkField->setValue($stageLink);
}
}
if(!$deletedFromStage) {
$stageURLField->setValue(Controller::join_links($record->AbsoluteLink(), '?stage=Stage'));
}
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
if(in_array('CMSPreviewable', class_implements($record)) && !$fields->fieldByName('SilverStripeNavigator')) {