diff --git a/lang/en.yml b/lang/en.yml
index bb2bbd5..bef8471 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -9,4 +9,3 @@ en:
SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'All page changes'
ALLCHANGESLABEL: 'Make global changes feed public'
- Warning: 'Publicising the history will also disclose the changes that have at the time been protected from the public view.'
diff --git a/src/VersionFeed.php b/src/VersionFeed.php
index ae09c69..4150ae8 100644
--- a/src/VersionFeed.php
+++ b/src/VersionFeed.php
@@ -2,16 +2,16 @@
namespace SilverStripe\VersionFeed;
-use SilverStripe\ORM\FieldType\DBField;
-use SilverStripe\View\Parsers\Diff;
-use SilverStripe\ORM\ArrayList;
-use SilverStripe\Forms\FieldList;
+use SilverStripe\CMS\Model\SiteTreeExtension;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup;
-use SilverStripe\Forms\LiteralField;
+use SilverStripe\Forms\FieldList;
+use SilverStripe\ORM\ArrayList;
+use SilverStripe\ORM\DataObject;
+use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\SiteConfig\SiteConfig;
-use SilverStripe\CMS\Model\SiteTreeExtension;
+use SilverStripe\View\Parsers\Diff;
class VersionFeed extends SiteTreeExtension
{
@@ -146,7 +146,7 @@ class VersionFeed extends SiteTreeExtension
* Return a single diff representing this version.
* Returns the initial version if there is nothing to compare to.
*
- * @returns DataObject Object with relevant fields diffed.
+ * @return DataObject|null Object with relevant fields diffed.
*/
public function getDiff()
{
@@ -179,32 +179,34 @@ class VersionFeed extends SiteTreeExtension
public function updateSettingsFields(FieldList $fields)
{
- if (!Config::inst()->get(get_class(), 'changes_enabled')) {
+ if (!$this->owner->config()->get('changes_enabled')) {
return;
}
// Add public history field.
- $fields->addFieldToTab('Root.Settings', $publicHistory = new FieldGroup(
- new CheckboxField('PublicHistory', $this->owner->fieldLabel('PublicHistory'))
- ));
-
- $warning = _t(
- __CLASS__ . '.Warning',
- "Publicising the history will also disclose the changes that have at the time been protected " .
- "from the public view."
+ $fields->addFieldToTab(
+ 'Root.Settings',
+ $publicHistory = FieldGroup::create(
+ CheckboxField::create('PublicHistory', $this->owner->fieldLabel('PublicHistory'))
+ )
+ ->setDescription(_t(
+ __CLASS__ . '.Warning',
+ "Publicising the history will also disclose the changes that have at the "
+ . "time been protected from the public view."
+ ))
);
- $fields->addFieldToTab('Root.Settings', new LiteralField('PublicHistoryWarning', $warning), 'PublicHistory');
-
- if ($this->owner->CanViewType!='Anyone') {
- $warning = _t(
- __CLASS__ . '.Warning2',
- "Changing access settings in such a way that this page or pages under it become publicly
" .
- "accessible may result in publicising all historical changes on these pages too. Please review
" .
- "this section's \"Public history\" settings to ascertain only intended information is disclosed."
- );
-
- $fields->addFieldToTab('Root.Settings', new LiteralField('PublicHistoryWarning2', $warning), 'CanViewType');
+ if ($this->owner->CanViewType != 'Anyone') {
+ $canViewType = $fields->fieldByName('Root.Settings.CanViewType');
+ if ($canViewType) {
+ $canViewType->setDescription(_t(
+ __CLASS__ . '.Warning2',
+ "Changing access settings in such a way that this page or pages under it become publicly
"
+ . "accessible may result in publicising all historical changes on these pages too. Please review"
+ . "
this section's \"Public history\" settings to ascertain only intended information is "
+ . "disclosed."
+ ));
+ }
}
}
diff --git a/src/VersionFeedSiteConfig.php b/src/VersionFeedSiteConfig.php
index d6bbaba..099ff85 100644
--- a/src/VersionFeedSiteConfig.php
+++ b/src/VersionFeedSiteConfig.php
@@ -2,11 +2,10 @@
namespace SilverStripe\VersionFeed;
-use SilverStripe\Forms\FieldList;
use SilverStripe\Core\Config\Config;
-use SilverStripe\VersionFeed\VersionFeed;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup;
+use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
/**
@@ -39,7 +38,7 @@ class VersionFeedSiteConfig extends DataExtension
FieldGroup::create(new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled')))
->setTitle(_t(__CLASS__ . '.ALLCHANGES', 'All page changes'))
->setDescription(_t(
- __CLASS__ . '.Warning',
+ 'SilverStripe\\VersionFeed\\VersionFeed.Warning',
"Publicising the history will also disclose the changes that have at the time been protected " .
"from the public view."
))