mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Remove redundant phpcs rules, reduce some line lengths and use injector to create checkbox fields
This commit is contained in:
parent
9f9dc67950
commit
9a57c3802c
@ -6,17 +6,5 @@
|
|||||||
<rule ref="PSR2" >
|
<rule ref="PSR2" >
|
||||||
<!-- Current exclusions -->
|
<!-- Current exclusions -->
|
||||||
<exclude name="PSR1.Methods.CamelCapsMethodName" />
|
<exclude name="PSR1.Methods.CamelCapsMethodName" />
|
||||||
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
|
|
||||||
<exclude name="PSR2.Classes.PropertyDeclaration" />
|
|
||||||
<exclude name="PSR2.ControlStructures.SwitchDeclaration" /> <!-- causes php notice while linting -->
|
|
||||||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase" />
|
|
||||||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault" />
|
|
||||||
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
|
|
||||||
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
|
|
||||||
<exclude name="Squiz.Scope.MethodScope" />
|
|
||||||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
|
|
||||||
<exclude name="Generic.Files.LineLength.TooLong" />
|
|
||||||
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
|
|
||||||
</rule>
|
</rule>
|
||||||
|
</ruleset>
|
||||||
</ruleset>
|
|
||||||
|
@ -157,13 +157,16 @@ class CommentsExtension extends DataExtension
|
|||||||
|
|
||||||
// Check if enabled setting should be cms configurable
|
// Check if enabled setting should be cms configurable
|
||||||
if ($this->owner->getCommentsOption('enabled_cms')) {
|
if ($this->owner->getCommentsOption('enabled_cms')) {
|
||||||
$options->push(new CheckboxField('ProvideComments', _t('SilverStripe\\Comments\\Model\\Comment.ALLOWCOMMENTS', 'Allow Comments')));
|
$options->push(CheckboxField::create('ProvideComments', _t(
|
||||||
|
'SilverStripe\\Comments\\Model\\Comment.ALLOWCOMMENTS',
|
||||||
|
'Allow Comments'
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we should require users to login to comment
|
// Check if we should require users to login to comment
|
||||||
if ($this->owner->getCommentsOption('require_login_cms')) {
|
if ($this->owner->getCommentsOption('require_login_cms')) {
|
||||||
$options->push(
|
$options->push(
|
||||||
new CheckboxField(
|
CheckboxField::create(
|
||||||
'CommentsRequireLogin',
|
'CommentsRequireLogin',
|
||||||
_t('Comments.COMMENTSREQUIRELOGIN', 'Require login to comment')
|
_t('Comments.COMMENTSREQUIRELOGIN', 'Require login to comment')
|
||||||
)
|
)
|
||||||
@ -180,16 +183,23 @@ class CommentsExtension extends DataExtension
|
|||||||
|
|
||||||
// Check if moderation should be enabled via cms configurable
|
// Check if moderation should be enabled via cms configurable
|
||||||
if ($this->owner->getCommentsOption('require_moderation_cms')) {
|
if ($this->owner->getCommentsOption('require_moderation_cms')) {
|
||||||
$moderationField = new DropdownField('ModerationRequired', _t(__CLASS__ . '.COMMENTMODERATION', 'Comment Moderation'), array(
|
$moderationField = DropdownField::create(
|
||||||
'None' => _t(__CLASS__ . '.MODERATIONREQUIRED_NONE', 'No moderation required'),
|
'ModerationRequired',
|
||||||
'Required' => _t(__CLASS__ . '.MODERATIONREQUIRED_REQUIRED', 'Moderate all comments'),
|
_t(
|
||||||
'NonMembersOnly' => _t(
|
__CLASS__ . '.COMMENTMODERATION',
|
||||||
__CLASS__ . '.MODERATIONREQUIRED_NONMEMBERSONLY',
|
'Comment Moderation'
|
||||||
'Only moderate non-members'
|
|
||||||
),
|
),
|
||||||
));
|
[
|
||||||
|
'None' => _t(__CLASS__ . '.MODERATIONREQUIRED_NONE', 'No moderation required'),
|
||||||
|
'Required' => _t(__CLASS__ . '.MODERATIONREQUIRED_REQUIRED', 'Moderate all comments'),
|
||||||
|
'NonMembersOnly' => _t(
|
||||||
|
__CLASS__ . '.MODERATIONREQUIRED_NONMEMBERSONLY',
|
||||||
|
'Only moderate non-members'
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
if ($fields->hasTabSet()) {
|
if ($fields->hasTabSet()) {
|
||||||
$fields->addFieldsToTab('Root.Settings', $moderationField);
|
$fields->addFieldToTab('Root.Settings', $moderationField);
|
||||||
} else {
|
} else {
|
||||||
$fields->push($moderationField);
|
$fields->push($moderationField);
|
||||||
}
|
}
|
||||||
|
@ -44,18 +44,27 @@ class CommentForm extends Form
|
|||||||
// Email
|
// Email
|
||||||
EmailField::create(
|
EmailField::create(
|
||||||
'Email',
|
'Email',
|
||||||
_t('SilverStripe\\Comments\\Controllers\\CommentingController.EMAILADDRESS', 'Your email address (will not be published)')
|
_t(
|
||||||
|
'SilverStripe\\Comments\\Controllers\\CommentingController.EMAILADDRESS',
|
||||||
|
'Your email address (will not be published)'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
->setCustomValidationMessage($emailRequired)
|
->setCustomValidationMessage($emailRequired)
|
||||||
->setAttribute('data-msg-required', $emailRequired)
|
->setAttribute('data-msg-required', $emailRequired)
|
||||||
->setAttribute('data-msg-email', $emailInvalid)
|
->setAttribute('data-msg-email', $emailInvalid)
|
||||||
->setAttribute('data-rule-email', true),
|
->setAttribute('data-rule-email', true),
|
||||||
// Url
|
// Url
|
||||||
TextField::create('URL', _t('SilverStripe\\Comments\\Controllers\\CommentingController.WEBSITEURL', 'Your website URL'))
|
TextField::create('URL', _t(
|
||||||
|
'SilverStripe\\Comments\\Controllers\\CommentingController.WEBSITEURL',
|
||||||
|
'Your website URL'
|
||||||
|
))
|
||||||
->setAttribute('data-msg-url', $urlInvalid)
|
->setAttribute('data-msg-url', $urlInvalid)
|
||||||
->setAttribute('data-rule-url', true),
|
->setAttribute('data-rule-url', true),
|
||||||
// Comment
|
// Comment
|
||||||
TextareaField::create('Comment', _t('SilverStripe\\Comments\\Controllers\\CommentingController.COMMENTS', 'Comments'))
|
TextareaField::create('Comment', _t(
|
||||||
|
'SilverStripe\\Comments\\Controllers\\CommentingController.COMMENTS',
|
||||||
|
'Comments'
|
||||||
|
))
|
||||||
->setCustomValidationMessage($commentRequired)
|
->setCustomValidationMessage($commentRequired)
|
||||||
->setAttribute('data-msg-required', $commentRequired)
|
->setAttribute('data-msg-required', $commentRequired)
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user