diff --git a/code/Controllers/SilverStripeNavigatorItem_Unversioned.php b/code/Controllers/SilverStripeNavigatorItem_Unversioned.php new file mode 100644 index 00000000..ac489827 --- /dev/null +++ b/code/Controllers/SilverStripeNavigatorItem_Unversioned.php @@ -0,0 +1,67 @@ +getLink()); + $linkTitle = _t('SilverStripe\\CMS\\Controllers\\ContentController.UNVERSIONEDPREVIEW', 'Preview'); + return "$linkTitle"; + } + + public function getLink() + { + return $this->getRecord()->PreviewLink(); + } + + public function getTitle() + { + return _t( + 'SilverStripe\\CMS\\Controllers\\ContentController.UNVERSIONEDPREVIEW', + 'Preview', + 'Used for the Switch between states (if any other other states are added). Needs to be a short label' + ); + } + + /** + * True if the record doesn't have the Versioned extension and is configured to display this item. + * + * @param Member $member + * @return bool + */ + public function canView($member = null) + { + return ( + !$this->getRecord()->hasExtension(Versioned::class) + && $this->showUnversionedLink() + ); + } + + /** + * True if the record is configured to display this item. + * + * @return bool + */ + public function showUnversionedLink(): bool + { + return (bool) Config::inst()->get(get_class($this->record), 'show_unversioned_preview_link'); + } + + /** + * This item is always active, as there are unlikely to be other preview states available for the record. + * + * @return bool + */ + public function isActive() + { + return true; + } +} diff --git a/lang/en.yml b/lang/en.yml index a20e402b..fdbea1d5 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -134,6 +134,7 @@ en: Password: Password PostInstallTutorialIntro: 'This website is a simplistic version of a SilverStripe 3 site. To extend this, please take a look at {link}.' StartEditing: 'You can start editing your content by opening the CMS.' + UNVERSIONEDPREVIEW: 'Preview' UnableDeleteInstall: 'Unable to delete installation files. Please delete the files below manually' VIEWPAGEIN: 'View Page in:' SilverStripe\CMS\Controllers\SilverStripeNavigator: