mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Negotiator amends: Make it possible to disable Preview links in the CMS
Existing functionality is limited to `RedirectorPage` Another option would be to use the HiddenClass methodology
This commit is contained in:
parent
c1159c849f
commit
31f99445bd
@ -58,11 +58,20 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
|
|||||||
$record->hasExtension(Versioned::class)
|
$record->hasExtension(Versioned::class)
|
||||||
&& $record->hasStages()
|
&& $record->hasStages()
|
||||||
&& $this->getLivePage()
|
&& $this->getLivePage()
|
||||||
// Don't follow redirects in preview, they break the CMS editing form
|
&& $this->showLiveLink()
|
||||||
&& !($this->record instanceof RedirectorPage)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showLiveLink()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->record->config()->get('show_live_link');
|
||||||
|
} catch (\BadMethodCallException $e) {
|
||||||
|
// Not using `config()` or similar
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function isActive()
|
public function isActive()
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
|
@ -64,11 +64,20 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
|
|||||||
$record->hasExtension(Versioned::class)
|
$record->hasExtension(Versioned::class)
|
||||||
&& $record->hasStages()
|
&& $record->hasStages()
|
||||||
&& $this->getDraftPage()
|
&& $this->getDraftPage()
|
||||||
// Don't follow redirects in preview, they break the CMS editing form
|
&& $this->showStageLink()
|
||||||
&& !($record instanceof RedirectorPage)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showStageLink()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->record->config()->get('show_stage_link');
|
||||||
|
} catch (\BadMethodCallException $e) {
|
||||||
|
// Not using `config()` or similar
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function isActive()
|
public function isActive()
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
|
@ -24,6 +24,10 @@ class RedirectorPage extends Page
|
|||||||
|
|
||||||
private static $icon_class = 'font-icon-p-redirect';
|
private static $icon_class = 'font-icon-p-redirect';
|
||||||
|
|
||||||
|
private static $show_stage_link = false;
|
||||||
|
|
||||||
|
private static $show_live_link = false;
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
"RedirectionType" => "Enum('Internal,External','Internal')",
|
"RedirectionType" => "Enum('Internal,External','Internal')",
|
||||||
"ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer.
|
"ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer.
|
||||||
|
@ -137,6 +137,10 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
|||||||
*/
|
*/
|
||||||
protected static $_allowedChildren = array();
|
protected static $_allowedChildren = array();
|
||||||
|
|
||||||
|
private static $show_stage_link = true;
|
||||||
|
|
||||||
|
private static $show_live_link = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default child class for this page.
|
* The default child class for this page.
|
||||||
* Note: Value might be cached, see {@link $allowed_chilren}.
|
* Note: Value might be cached, see {@link $allowed_chilren}.
|
||||||
|
Loading…
Reference in New Issue
Block a user