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: SilverStripe\VersionFeed\VersionFeedSiteConfig:
ALLCHANGES: 'All page changes' ALLCHANGES: 'All page changes'
ALLCHANGESLABEL: 'Make global changes feed public' 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; namespace SilverStripe\VersionFeed;
use SilverStripe\ORM\FieldType\DBField; use SilverStripe\CMS\Model\SiteTreeExtension;
use SilverStripe\View\Parsers\Diff;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Forms\FieldList;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup; 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\SiteConfig\SiteConfig;
use SilverStripe\CMS\Model\SiteTreeExtension; use SilverStripe\View\Parsers\Diff;
class VersionFeed extends SiteTreeExtension class VersionFeed extends SiteTreeExtension
{ {
@ -146,7 +146,7 @@ class VersionFeed extends SiteTreeExtension
* Return a single diff representing this version. * Return a single diff representing this version.
* Returns the initial version if there is nothing to compare to. * 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() public function getDiff()
{ {
@ -179,32 +179,34 @@ class VersionFeed extends SiteTreeExtension
public function updateSettingsFields(FieldList $fields) public function updateSettingsFields(FieldList $fields)
{ {
if (!Config::inst()->get(get_class(), 'changes_enabled')) { if (!$this->owner->config()->get('changes_enabled')) {
return; return;
} }
// Add public history field. // Add public history field.
$fields->addFieldToTab('Root.Settings', $publicHistory = new FieldGroup( $fields->addFieldToTab(
new CheckboxField('PublicHistory', $this->owner->fieldLabel('PublicHistory')) 'Root.Settings',
)); $publicHistory = FieldGroup::create(
CheckboxField::create('PublicHistory', $this->owner->fieldLabel('PublicHistory'))
$warning = _t( )
__CLASS__ . '.Warning', ->setDescription(_t(
"Publicising the history will also disclose the changes that have at the time been protected " . __CLASS__ . '.Warning',
"from the public view." "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') {
$canViewType = $fields->fieldByName('Root.Settings.CanViewType');
if ($this->owner->CanViewType!='Anyone') { if ($canViewType) {
$warning = _t( $canViewType->setDescription(_t(
__CLASS__ . '.Warning2', __CLASS__ . '.Warning2',
"Changing access settings in such a way that this page or pages under it become publicly<br>" . "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>" . . "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." . "<br> this section's \"Public history\" settings to ascertain only intended information is "
); . "disclosed."
));
$fields->addFieldToTab('Root.Settings', new LiteralField('PublicHistoryWarning2', $warning), 'CanViewType'); }
} }
} }

View File

@ -2,11 +2,10 @@
namespace SilverStripe\VersionFeed; namespace SilverStripe\VersionFeed;
use SilverStripe\Forms\FieldList;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\VersionFeed\VersionFeed;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup; use SilverStripe\Forms\FieldGroup;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
/** /**
@ -39,7 +38,7 @@ class VersionFeedSiteConfig extends DataExtension
FieldGroup::create(new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled'))) FieldGroup::create(new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled')))
->setTitle(_t(__CLASS__ . '.ALLCHANGES', 'All page changes')) ->setTitle(_t(__CLASS__ . '.ALLCHANGES', 'All page changes'))
->setDescription(_t( ->setDescription(_t(
__CLASS__ . '.Warning', 'SilverStripe\\VersionFeed\\VersionFeed.Warning',
"Publicising the history will also disclose the changes that have at the time been protected " . "Publicising the history will also disclose the changes that have at the time been protected " .
"from the public view." "from the public view."
)) ))