mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX Allow empty PreviewURLs for CMSPreviewable objects
An empty PreviewURL will result in the "no preview available" message displaying instead of a 404 error.
This commit is contained in:
parent
1563ab3fcf
commit
c02549cf30
@ -46,10 +46,8 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
return Controller::join_links(
|
||||
$this->record->PreviewLink(),
|
||||
'?archiveDate=' . urlencode($this->record->LastEdited ?? '')
|
||||
);
|
||||
$link = $this->record->PreviewLink();
|
||||
return $link ? Controller::join_links($link, '?archiveDate=' . urlencode($this->record->LastEdited ?? '')) : '';
|
||||
}
|
||||
|
||||
public function canView($member = null)
|
||||
@ -62,6 +60,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem
|
||||
&& $this->isArchived()
|
||||
// Don't follow redirects in preview, they break the CMS editing form
|
||||
&& !($record instanceof RedirectorPage)
|
||||
&& $this->getLink()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,8 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
return Controller::join_links($this->getLivePage()->PreviewLink(), '?stage=Live');
|
||||
$link = $this->getLivePage()->PreviewLink();
|
||||
return $link ? Controller::join_links($link, '?stage=Live') : '';
|
||||
}
|
||||
|
||||
public function canView($member = null)
|
||||
@ -60,6 +61,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
|
||||
&& $this->showLiveLink()
|
||||
&& $record->hasStages()
|
||||
&& $this->getLivePage()
|
||||
&& $this->getLink()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,12 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
|
||||
public function getLink()
|
||||
{
|
||||
$date = Versioned::current_archived_date();
|
||||
$link = $this->record->PreviewLink();
|
||||
if (!$link) {
|
||||
return '';
|
||||
}
|
||||
return Controller::join_links(
|
||||
$this->record->PreviewLink(),
|
||||
$link,
|
||||
'?stage=Stage',
|
||||
$date ? '?archiveDate=' . $date : null
|
||||
);
|
||||
@ -66,6 +70,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
|
||||
&& $this->showStageLink()
|
||||
&& $record->hasStages()
|
||||
&& $this->getDraftPage()
|
||||
&& $this->getLink()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
return $this->getRecord()->PreviewLink();
|
||||
return $this->getRecord()->PreviewLink() ?? '';
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
@ -42,6 +42,7 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem
|
||||
return (
|
||||
!$this->getRecord()->hasExtension(Versioned::class)
|
||||
&& $this->showUnversionedLink()
|
||||
&& $this->getLink()
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user