silverstripe /
silverstripe-versionfeed
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SilverStripe\VersionFeed; |
||
| 4 | |||
| 5 | use SilverStripe\Core\Config\Config; |
||
| 6 | use SilverStripe\Forms\CheckboxField; |
||
| 7 | use SilverStripe\Forms\FieldGroup; |
||
| 8 | use SilverStripe\Forms\FieldList; |
||
| 9 | use SilverStripe\ORM\DataExtension; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Allows global configuration of all changes |
||
| 13 | */ |
||
| 14 | class VersionFeedSiteConfig extends DataExtension |
||
| 15 | { |
||
| 16 | |||
| 17 | private static $db = array( |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 18 | 'AllChangesEnabled' => 'Boolean(true)' |
||
| 19 | ); |
||
| 20 | |||
| 21 | private static $defaults = array( |
||
|
0 ignored issues
–
show
|
|||
| 22 | 'AllChangesEnabled' => true |
||
| 23 | ); |
||
| 24 | |||
| 25 | public function updateFieldLabels(&$labels) |
||
| 26 | { |
||
| 27 | $labels['AllChangesEnabled'] = _t(__CLASS__ . '.ALLCHANGESLABEL', 'Make global changes feed public'); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function updateCMSFields(FieldList $fields) |
||
| 31 | { |
||
| 32 | if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')) { |
||
| 33 | return; |
||
| 34 | } |
||
| 35 | |||
| 36 | $fields->addFieldToTab( |
||
| 37 | 'Root.Access', |
||
| 38 | FieldGroup::create(new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled'))) |
||
| 39 | ->setTitle(_t(__CLASS__ . '.ALLCHANGES', 'All page changes')) |
||
| 40 | ->setDescription(_t( |
||
| 41 | 'SilverStripe\\VersionFeed\\VersionFeed.Warning', |
||
| 42 | "Publicising the history will also disclose the changes that have at the time been protected " . |
||
| 43 | "from the public view." |
||
| 44 | )) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |