mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge branch '3.1'
This commit is contained in:
commit
d504d4a847
@ -2,7 +2,16 @@
|
||||
* @package comments
|
||||
*/
|
||||
(function($) {
|
||||
// The above closure encapsulates the $ variable away from the global scope
|
||||
// and the one below is the `$(document).ready(...)` shorthand.
|
||||
$(function() {
|
||||
// Override the default URL validator in order to extend it to allow protocol-less URLs
|
||||
$.validator.methods.url = function( value, element ) {
|
||||
// This line is copied directly from the jQuery.validation source (version 1.19.0)
|
||||
// the only change is a single question mark added here ---------v
|
||||
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)?(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable form validation
|
||||
*/
|
||||
|
10
lang/en.yml
10
lang/en.yml
@ -18,10 +18,10 @@ en:
|
||||
CommentsInterface_pendingcomment_ss:
|
||||
AWAITINGMODERATION: 'Your comment has been submitted and is now awaiting moderation.'
|
||||
CommentsInterface_singlecomment_ss:
|
||||
APPROVE: 'approve it'
|
||||
ISNTSPAM: 'not spam'
|
||||
ISSPAM: 'spam it'
|
||||
REMCOM: 'reject it'
|
||||
APPROVE: 'Approve it'
|
||||
ISNTSPAM: 'Not spam'
|
||||
ISSPAM: 'Spam it'
|
||||
REMCOM: 'Reject it'
|
||||
REPLYTO: 'Reply to'
|
||||
CommentsInterface_ss:
|
||||
AWAITINGMODERATION: 'Your comment has been submitted and is now awaiting moderation.'
|
||||
@ -74,7 +74,7 @@ en:
|
||||
EMAIL: Email
|
||||
ISSPAM: 'Spam?'
|
||||
MODERATED: 'Moderated?'
|
||||
NAME: 'Author Name'
|
||||
NAME: 'Author name'
|
||||
'ON': 'on'
|
||||
OPTIONS: Options
|
||||
OPTION_DESCRIPTION: 'Unmoderated and spam comments will not be displayed until approved'
|
||||
|
@ -27,7 +27,7 @@ abstract class CommentHandler extends Handler
|
||||
$this->updateComment($comment);
|
||||
}
|
||||
|
||||
$response = new HTTPResponse(Convert::raw2json([
|
||||
$response = new HTTPResponse(json_encode([
|
||||
'done' => true,
|
||||
'records' => $ids,
|
||||
]));
|
||||
|
@ -37,7 +37,7 @@ class Handler extends GridFieldBulkActionHandler
|
||||
$record->markSpam();
|
||||
}
|
||||
|
||||
$response = new HTTPResponse(Convert::raw2json(array(
|
||||
$response = new HTTPResponse(json_encode(array(
|
||||
'done' => true,
|
||||
'records' => $ids
|
||||
)));
|
||||
@ -60,7 +60,7 @@ class Handler extends GridFieldBulkActionHandler
|
||||
$record->markApproved();
|
||||
}
|
||||
|
||||
$response = new HTTPResponse(Convert::raw2json(array(
|
||||
$response = new HTTPResponse(json_encode(array(
|
||||
'done' => true,
|
||||
'records' => $ids
|
||||
)));
|
||||
|
@ -441,7 +441,7 @@ class CommentsExtension extends DataExtension
|
||||
{
|
||||
return Controller::join_links(
|
||||
$this->getCommentRSSLink(),
|
||||
str_replace('\\', '-', $this->owner->baseClass()),
|
||||
str_replace('\\', '-', get_class($this->owner)),
|
||||
$this->owner->ID
|
||||
);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class CommentForm extends Form
|
||||
|
||||
// load user data from previous form request back into form.
|
||||
if (array_key_exists('UserData', $data)) {
|
||||
$formData = Convert::json2array($data['UserData']);
|
||||
$formData = json_decode($data['UserData'], true);
|
||||
|
||||
$this->loadDataFrom([
|
||||
'Name' => isset($formData['Name']) ? $formData['Name'] : '',
|
||||
@ -199,7 +199,7 @@ class CommentForm extends Form
|
||||
|
||||
// cache users data
|
||||
$form->setSessionData([
|
||||
'UserData' => Convert::raw2json($data),
|
||||
'UserData' => json_encode($data),
|
||||
'Comment' => $data['Comment']
|
||||
]);
|
||||
|
||||
@ -270,7 +270,7 @@ class CommentForm extends Form
|
||||
|
||||
// cache users data (name, email, etc to prepopulate on other forms).
|
||||
$form->setSessionData([
|
||||
'UserData' => Convert::raw2json($data),
|
||||
'UserData' => json_encode($data),
|
||||
]);
|
||||
|
||||
// Find parent link
|
||||
|
@ -125,8 +125,8 @@ class Comment extends DataObject
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
private static $summary_fields = array(
|
||||
'Name' => 'Submitted By',
|
||||
'Email' => 'Email',
|
||||
'getAuthorName' => 'Submitted By',
|
||||
'getAuthorEmail' => 'Email',
|
||||
'Comment.LimitWordCount' => 'Comment',
|
||||
'Created' => 'Date Posted',
|
||||
'Parent.Title' => 'Post',
|
||||
@ -219,7 +219,7 @@ class Comment extends DataObject
|
||||
{
|
||||
$labels = parent::fieldLabels($includerelations);
|
||||
|
||||
$labels['Name'] = _t(__CLASS__ . '.NAME', 'Author Name');
|
||||
$labels['Name'] = _t(__CLASS__ . '.NAME', 'Author name');
|
||||
$labels['Comment'] = _t(__CLASS__ . '.COMMENT', 'Comment');
|
||||
$labels['Email'] = _t(__CLASS__ . '.EMAIL', 'Email');
|
||||
$labels['URL'] = _t(__CLASS__ . '.URL', 'URL');
|
||||
@ -450,6 +450,20 @@ class Comment extends DataObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the comment authors email address
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthorEmail()
|
||||
{
|
||||
if ($this->Email) {
|
||||
return $this->Email;
|
||||
} elseif ($author = $this->Author()) {
|
||||
return $author->Email;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a secure admin-action link authorised for the specified member
|
||||
*
|
||||
|
@ -20,21 +20,21 @@
|
||||
<div class="comment-action-links">
|
||||
<div class="comment-moderation-options">
|
||||
<% if $ApproveLink %>
|
||||
<a href="$ApproveLink.ATT" class="approve"><% _t('CommentsInterface_singlecomment_ss.APPROVE', 'approve it') %></a>
|
||||
<a href="$ApproveLink.ATT" class="approve"><%t CommentsInterface_singlecomment_ss.APPROVE "Approve it" %></a>
|
||||
<% end_if %>
|
||||
<% if $SpamLink %>
|
||||
<a href="$SpamLink.ATT" class="spam"><% _t('CommentsInterface_singlecomment_ss.ISSPAM','spam it') %></a>
|
||||
<a href="$SpamLink.ATT" class="spam"><%t CommentsInterface_singlecomment_ss.ISSPAM "Spam it" %></a>
|
||||
<% end_if %>
|
||||
<% if $HamLink %>
|
||||
<a href="$HamLink.ATT" class="ham"><% _t('CommentsInterface_singlecomment_ss.ISNTSPAM','not spam') %></a>
|
||||
<a href="$HamLink.ATT" class="ham"><%t CommentsInterface_singlecomment_ss.ISNTSPAM "Not spam" %></a>
|
||||
<% end_if %>
|
||||
<% if $DeleteLink %>
|
||||
<a href="$DeleteLink.ATT" class="delete"><% _t('CommentsInterface_singlecomment_ss.REMCOM','reject it') %></a>
|
||||
<a href="$DeleteLink.ATT" class="delete"><%t CommentsInterface_singlecomment_ss.REMCOM "Reject it" %></a>
|
||||
<% end_if %>
|
||||
</div>
|
||||
<% if $RepliesEnabled && $canPostComment %>
|
||||
<button class="comment-reply-link" type="button" aria-controls="$ReplyForm.FormName" aria-expanded="false">
|
||||
<% _t('CommentsInterface_singlecomment_ss.REPLYTO','Reply to') %> $AuthorName.XML
|
||||
<%t CommentsInterface_singlecomment_ss.REPLYTO "Reply to" %> $AuthorName.XML
|
||||
</button>
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
@ -605,52 +605,19 @@ class CommentsTest extends FunctionalTest
|
||||
*/
|
||||
public function testFieldLabels()
|
||||
{
|
||||
$locale = i18n::get_locale();
|
||||
i18n::set_locale('fr');
|
||||
|
||||
/** @var Comment $comment */
|
||||
$comment = $this->objFromFixture(Comment::class, 'firstComA');
|
||||
|
||||
$labels = $comment->FieldLabels();
|
||||
$expected = array(
|
||||
'Name' => 'Nom de l\'Auteur',
|
||||
'Comment' => 'Commentaire',
|
||||
'Email' => 'Email',
|
||||
'URL' => 'URL',
|
||||
'Moderated' => 'Modéré?',
|
||||
'IsSpam' => 'Spam?',
|
||||
'AllowHtml' => 'Allow Html',
|
||||
'SecretToken' => 'Secret Token',
|
||||
'Depth' => 'Depth',
|
||||
'Author' => 'Author Member',
|
||||
'ParentComment' => 'Parent Comment',
|
||||
'ChildComments' => 'Child Comments',
|
||||
'ParentTitle' => 'Parent',
|
||||
'Created' => 'Date de publication',
|
||||
'Parent' => 'Parent'
|
||||
);
|
||||
i18n::set_locale($locale);
|
||||
foreach ($expected as $key => $value) {
|
||||
$this->assertEquals($value, $labels[$key]);
|
||||
}
|
||||
|
||||
$labels = $comment->FieldLabels();
|
||||
$expected = array(
|
||||
'Name' => 'Author Name',
|
||||
'Name' => 'Author name',
|
||||
'Comment' => 'Comment',
|
||||
'Email' => 'Email',
|
||||
'URL' => 'URL',
|
||||
'Moderated' => 'Moderated?',
|
||||
'IsSpam' => 'Spam?',
|
||||
'AllowHtml' => 'Allow Html',
|
||||
'SecretToken' => 'Secret Token',
|
||||
'Depth' => 'Depth',
|
||||
'Author' => 'Author Member',
|
||||
'ParentComment' => 'Parent Comment',
|
||||
'ChildComments' => 'Child Comments',
|
||||
'Moderated' => 'Moderated?',
|
||||
'ParentTitle' => 'Parent',
|
||||
'Created' => 'Date posted',
|
||||
'Parent' => 'Parent'
|
||||
);
|
||||
foreach ($expected as $key => $value) {
|
||||
$this->assertEquals($value, $labels[$key]);
|
||||
|
Loading…
Reference in New Issue
Block a user