BUGFIX Disable CMS preview for RedirectorPage (fixes #7127)

If the redirect is to an internal page, the preview iframe
will automatically load this new URL, causing the CMS edit
form to switch as well - effectively making it impossible
to edit a redirector page in the CMS as soon as it is saved
with an internal redirection target.
This commit is contained in:
Ingo Schommer 2013-01-09 21:44:52 +01:00
parent caca15034b
commit ffc6d6ffad

View File

@ -212,8 +212,12 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
}
public function canView($member = null) {
// Don't show in CMS
return !(Controller::curr() instanceof CMSMain);
return (
// Don't show in CMS
!(Controller::curr() instanceof CMSMain)
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
);
}
}
@ -246,7 +250,12 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
}
public function canView($member = null) {
return ($this->record->hasExtension('Versioned') && $this->getDraftPage());
return (
$this->record->hasExtension('Versioned')
&& $this->getDraftPage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
);
}
public function isActive() {
@ -294,7 +303,12 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
}
public function canView($member = null) {
return ($this->record->hasExtension('Versioned') && $this->getLivePage());
return (
$this->record->hasExtension('Versioned')
&& $this->getLivePage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
);
}
public function isActive() {
@ -340,7 +354,12 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
}
public function canView($member = null) {
return ($this->record->hasExtension('Versioned') && $this->isArchived());
return (
$this->record->hasExtension('Versioned')
&& $this->isArchived()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
);
}
public function isActive() {