Merge pull request #1822 from open-sausages/pulls/4.0/override-redirectorpage-fields

ENHANCEMENT RedirectorPage extensions can now modify fields
This commit is contained in:
Daniel Hensby 2017-05-16 15:40:31 +01:00 committed by GitHub
commit 63f930c4e9

View File

@ -2,6 +2,7 @@
namespace SilverStripe\CMS\Model; namespace SilverStripe\CMS\Model;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\HeaderField; use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\OptionsetField; use SilverStripe\Forms\OptionsetField;
use SilverStripe\Forms\TextField; use SilverStripe\Forms\TextField;
@ -145,7 +146,7 @@ class RedirectorPage extends Page
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->removeByName('Content', true); $fields->removeByName('Content', true);
// Remove all metadata fields, does not apply for redirector pages // Remove all metadata fields, does not apply for redirector pages
@ -154,26 +155,26 @@ class RedirectorPage extends Page
$fields->addFieldsToTab( $fields->addFieldsToTab(
'Root.Main', 'Root.Main',
array( array(
new HeaderField('RedirectorDescHeader', _t('SilverStripe\\CMS\\Model\\RedirectorPage.HEADER', "This page will redirect users to another page")), new HeaderField('RedirectorDescHeader', _t(__CLASS__.'.HEADER', "This page will redirect users to another page")),
new OptionsetField( new OptionsetField(
"RedirectionType", "RedirectionType",
_t('SilverStripe\\CMS\\Model\\RedirectorPage.REDIRECTTO', "Redirect to"), _t(__CLASS__.'.REDIRECTTO', "Redirect to"),
array( array(
"Internal" => _t('SilverStripe\\CMS\\Model\\RedirectorPage.REDIRECTTOPAGE', "A page on your website"), "Internal" => _t(__CLASS__.'.REDIRECTTOPAGE', "A page on your website"),
"External" => _t('SilverStripe\\CMS\\Model\\RedirectorPage.REDIRECTTOEXTERNAL', "Another website"), "External" => _t(__CLASS__.'.REDIRECTTOEXTERNAL', "Another website"),
), ),
"Internal" "Internal"
), ),
new TreeDropdownField( new TreeDropdownField(
"LinkToID", "LinkToID",
_t('SilverStripe\\CMS\\Model\\RedirectorPage.YOURPAGE', "Page on your website"), _t(__CLASS__.'.YOURPAGE', "Page on your website"),
"SilverStripe\\CMS\\Model\\SiteTree" SiteTree::class
), ),
new TextField("ExternalURL", _t('SilverStripe\\CMS\\Model\\RedirectorPage.OTHERURL', "Other website URL")) new TextField("ExternalURL", _t(__CLASS__.'.OTHERURL', "Other website URL"))
) )
); );
});
return $fields; return parent::getCMSFields();
} }
// Don't cache RedirectorPages // Don't cache RedirectorPages