mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00: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()
|
public function getLink()
|
||||||
{
|
{
|
||||||
return Controller::join_links(
|
$link = $this->record->PreviewLink();
|
||||||
$this->record->PreviewLink(),
|
return $link ? Controller::join_links($link, '?archiveDate=' . urlencode($this->record->LastEdited ?? '')) : '';
|
||||||
'?archiveDate=' . urlencode($this->record->LastEdited ?? '')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canView($member = null)
|
public function canView($member = null)
|
||||||
@ -62,6 +60,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem
|
|||||||
&& $this->isArchived()
|
&& $this->isArchived()
|
||||||
// Don't follow redirects in preview, they break the CMS editing form
|
// Don't follow redirects in preview, they break the CMS editing form
|
||||||
&& !($record instanceof RedirectorPage)
|
&& !($record instanceof RedirectorPage)
|
||||||
|
&& $this->getLink()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
|
|||||||
|
|
||||||
public function getLink()
|
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)
|
public function canView($member = null)
|
||||||
@ -60,6 +61,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
|
|||||||
&& $this->showLiveLink()
|
&& $this->showLiveLink()
|
||||||
&& $record->hasStages()
|
&& $record->hasStages()
|
||||||
&& $this->getLivePage()
|
&& $this->getLivePage()
|
||||||
|
&& $this->getLink()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,12 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
|
|||||||
public function getLink()
|
public function getLink()
|
||||||
{
|
{
|
||||||
$date = Versioned::current_archived_date();
|
$date = Versioned::current_archived_date();
|
||||||
|
$link = $this->record->PreviewLink();
|
||||||
|
if (!$link) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return Controller::join_links(
|
return Controller::join_links(
|
||||||
$this->record->PreviewLink(),
|
$link,
|
||||||
'?stage=Stage',
|
'?stage=Stage',
|
||||||
$date ? '?archiveDate=' . $date : null
|
$date ? '?archiveDate=' . $date : null
|
||||||
);
|
);
|
||||||
@ -66,6 +70,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
|
|||||||
&& $this->showStageLink()
|
&& $this->showStageLink()
|
||||||
&& $record->hasStages()
|
&& $record->hasStages()
|
||||||
&& $this->getDraftPage()
|
&& $this->getDraftPage()
|
||||||
|
&& $this->getLink()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem
|
|||||||
|
|
||||||
public function getLink()
|
public function getLink()
|
||||||
{
|
{
|
||||||
return $this->getRecord()->PreviewLink();
|
return $this->getRecord()->PreviewLink() ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
@ -42,6 +42,7 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem
|
|||||||
return (
|
return (
|
||||||
!$this->getRecord()->hasExtension(Versioned::class)
|
!$this->getRecord()->hasExtension(Versioned::class)
|
||||||
&& $this->showUnversionedLink()
|
&& $this->showUnversionedLink()
|
||||||
|
&& $this->getLink()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user