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… (#2492)
Negotiator amends: Make it possible to disable Preview links in the CMS
This commit is contained in:
commit
3a028ac1ec
@ -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 (
|
||||
|
@ -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 (
|
||||
|
@ -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.
|
||||
|
@ -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}.
|
||||
|
Loading…
Reference in New Issue
Block a user