FIX Add warnings as descriptions to settings tabs, not literal fields. Remove duplicated translation

This commit is contained in:
Robbie Averill 2017-12-18 15:56:39 +13:00
parent 952b67a5cb
commit 6b6f4ec622
3 changed files with 31 additions and 31 deletions

View File

@ -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.'

View File

@ -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<br>" .
"accessible may result in publicising all historical changes on these pages too. Please review<br>" .
"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<br>"
. "accessible may result in publicising all historical changes on these pages too. Please review"
. "<br> this section's \"Public history\" settings to ascertain only intended information is "
. "disclosed."
));
}
}
}

View File

@ -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."
))