Negotiator amends: Make it possible to disable Preview links in… (#2492)

Negotiator amends: Make it possible to disable Preview links in the CMS
This commit is contained in:
Guy Marriott 2019-11-28 09:18:32 -08:00 committed by GitHub
commit 3a028ac1ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 4 deletions

View File

@ -3,6 +3,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;
@ -56,13 +57,20 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
$record = $this->record;
return (
$record->hasExtension(Versioned::class)
&& $this->showLiveLink()
&& $record->hasStages()
&& $this->getLivePage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
);
}
/**
* @return bool
*/
public function showLiveLink()
{
return (bool)Config::inst()->get(get_class($this->record), 'show_live_link');
}
public function isActive()
{
return (

View File

@ -3,6 +3,7 @@ namespace SilverStripe\CMS\Controllers;
use SilverStripe\CMS\Model\RedirectorPage;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
@ -62,13 +63,20 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
$record = $this->record;
return (
$record->hasExtension(Versioned::class)
&& $this->showStageLink()
&& $record->hasStages()
&& $this->getDraftPage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($record instanceof RedirectorPage)
);
}
/**
* @return bool
*/
public function showStageLink()
{
return (bool)Config::inst()->get(get_class($this->record), 'show_stage_link');
}
public function isActive()
{
return (

View File

@ -24,6 +24,10 @@ class RedirectorPage extends Page
private static $icon_class = 'font-icon-p-redirect';
private static $show_stage_link = false;
private static $show_live_link = false;
private static $db = array(
"RedirectionType" => "Enum('Internal,External','Internal')",
"ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer.

View File

@ -137,6 +137,18 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/
protected static $_allowedChildren = array();
/**
* Determines if the Draft Preview panel will appear when in the CMS admin
* @var bool
*/
private static $show_stage_link = true;
/**
* Determines if the Live Preview panel will appear when in the CMS admin
* @var bool
*/
private static $show_live_link = true;
/**
* The default child class for this page.
* Note: Value might be cached, see {@link $allowed_chilren}.