mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Compare commits
No commits in common. "3dc22e9c3906f34bf7bb4509b3addfb9d848fbe7" and "3d6e44aaa12b2b1ff278d33f0346f8dc34968ae1" have entirely different histories.
3dc22e9c39
...
3d6e44aaa1
@ -100,7 +100,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
_t(
|
_t(
|
||||||
__CLASS__.'.NewComments',
|
__CLASS__.'.NewComments',
|
||||||
'New ({count})',
|
'New ({count})',
|
||||||
['count' => count($newComments ?? [])]
|
['count' => count($newComments)]
|
||||||
),
|
),
|
||||||
$newGrid
|
$newGrid
|
||||||
),
|
),
|
||||||
@ -109,7 +109,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
_t(
|
_t(
|
||||||
__CLASS__.'.ApprovedComments',
|
__CLASS__.'.ApprovedComments',
|
||||||
'Approved ({count})',
|
'Approved ({count})',
|
||||||
['count' => count($approvedComments ?? [])]
|
['count' => count($approvedComments)]
|
||||||
),
|
),
|
||||||
$approvedGrid
|
$approvedGrid
|
||||||
),
|
),
|
||||||
@ -118,7 +118,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
_t(
|
_t(
|
||||||
__CLASS__.'.SpamComments',
|
__CLASS__.'.SpamComments',
|
||||||
'Spam ({count})',
|
'Spam ({count})',
|
||||||
['count' => count($spamComments ?? [])]
|
['count' => count($spamComments)]
|
||||||
),
|
),
|
||||||
$spamGrid
|
$spamGrid
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,7 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
|
|||||||
*/
|
*/
|
||||||
public function augmentColumns($gridField, &$columns)
|
public function augmentColumns($gridField, &$columns)
|
||||||
{
|
{
|
||||||
if (!in_array('Actions', $columns ?? [])) {
|
if (!in_array('Actions', $columns)) {
|
||||||
$columns[] = 'Actions';
|
$columns[] = 'Actions';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class CommentsGridFieldApproveAction implements
|
|||||||
*/
|
*/
|
||||||
public function augmentColumns($gridField, &$columns)
|
public function augmentColumns($gridField, &$columns)
|
||||||
{
|
{
|
||||||
if (!in_array('Actions', $columns ?? [])) {
|
if (!in_array('Actions', $columns)) {
|
||||||
$columns[] = 'Actions';
|
$columns[] = 'Actions';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class CommentsGridFieldSpamAction implements
|
|||||||
*/
|
*/
|
||||||
public function augmentColumns($gridField, &$columns)
|
public function augmentColumns($gridField, &$columns)
|
||||||
{
|
{
|
||||||
if (!in_array('Actions', $columns ?? [])) {
|
if (!in_array('Actions', $columns)) {
|
||||||
$columns[] = 'Actions';
|
$columns[] = 'Actions';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ class CommentingController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function encodeClassName($input)
|
public function encodeClassName($input)
|
||||||
{
|
{
|
||||||
return str_replace('\\', '-', $input ?? '');
|
return str_replace('\\', '-', $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +126,7 @@ class CommentingController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function decodeClassName($input)
|
public function decodeClassName($input)
|
||||||
{
|
{
|
||||||
return str_replace('-', '\\', $input ?? '');
|
return str_replace('-', '\\', $input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -583,9 +583,9 @@ class CommentsExtension extends DataExtension
|
|||||||
CommentsGridFieldConfig::create()
|
CommentsGridFieldConfig::create()
|
||||||
);
|
);
|
||||||
|
|
||||||
$newCount = '(' . count($newComments ?? []) . ')';
|
$newCount = '(' . count($newComments) . ')';
|
||||||
$approvedCount = '(' . count($approvedComments ?? []) . ')';
|
$approvedCount = '(' . count($approvedComments) . ')';
|
||||||
$spamCount = '(' . count($spamComments ?? []) . ')';
|
$spamCount = '(' . count($spamComments) . ')';
|
||||||
|
|
||||||
if ($fields->hasTabSet()) {
|
if ($fields->hasTabSet()) {
|
||||||
$tabs = TabSet::create(
|
$tabs = TabSet::create(
|
||||||
|
@ -145,8 +145,8 @@ class CommentForm extends Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load user data from previous form request back into form.
|
// load user data from previous form request back into form.
|
||||||
if (array_key_exists('UserData', $data ?? [])) {
|
if (array_key_exists('UserData', $data)) {
|
||||||
$formData = json_decode($data['UserData'] ?? '', true);
|
$formData = json_decode($data['UserData'], true);
|
||||||
|
|
||||||
$this->loadDataFrom([
|
$this->loadDataFrom([
|
||||||
'Name' => isset($formData['Name']) ? $formData['Name'] : '',
|
'Name' => isset($formData['Name']) ? $formData['Name'] : '',
|
||||||
@ -156,7 +156,7 @@ class CommentForm extends Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allow previous value to fill if comment
|
// allow previous value to fill if comment
|
||||||
if (array_key_exists('Comment', $data ?? [])) {
|
if (array_key_exists('Comment', $data)) {
|
||||||
$prevComment = $data['Comment'];
|
$prevComment = $data['Comment'];
|
||||||
|
|
||||||
if ($prevComment && $prevComment != '') {
|
if ($prevComment && $prevComment != '') {
|
||||||
|
@ -608,7 +608,7 @@ class Comment extends DataObject
|
|||||||
*/
|
*/
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
$title = sprintf(_t(__CLASS__ . '.COMMENTBY', 'Comment by %s', 'Name') ?? '', $this->getAuthorName());
|
$title = sprintf(_t(__CLASS__ . '.COMMENTBY', 'Comment by %s', 'Name'), $this->getAuthorName());
|
||||||
|
|
||||||
if ($parent = $this->Parent()) {
|
if ($parent = $this->Parent()) {
|
||||||
if ($parent->Title) {
|
if ($parent->Title) {
|
||||||
@ -726,7 +726,7 @@ class Comment extends DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This injector cannot be set unless the 'p' element is allowed
|
// This injector cannot be set unless the 'p' element is allowed
|
||||||
if (in_array('p', $allowedElements ?? [])) {
|
if (in_array('p', $allowedElements)) {
|
||||||
$config->set('AutoFormat.AutoParagraph', true);
|
$config->set('AutoFormat.AutoParagraph', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ class Comment extends DataObject
|
|||||||
$use_gravatar = $this->getOption('use_gravatar');
|
$use_gravatar = $this->getOption('use_gravatar');
|
||||||
|
|
||||||
if ($use_gravatar) {
|
if ($use_gravatar) {
|
||||||
$gravatar = 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($this->Email ?? '')));
|
$gravatar = 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($this->Email)));
|
||||||
$gravatarsize = $this->getOption('gravatar_size');
|
$gravatarsize = $this->getOption('gravatar_size');
|
||||||
$gravatardefault = $this->getOption('gravatar_default');
|
$gravatardefault = $this->getOption('gravatar_default');
|
||||||
$gravatarrating = $this->getOption('gravatar_rating');
|
$gravatarrating = $this->getOption('gravatar_rating');
|
||||||
|
@ -37,7 +37,7 @@ class SecurityToken
|
|||||||
*/
|
*/
|
||||||
protected function getToken($salt)
|
protected function getToken($salt)
|
||||||
{
|
{
|
||||||
return hash_pbkdf2('sha256', $this->secret ?? '', $salt ?? '', 1000, 30);
|
return hash_pbkdf2('sha256', $this->secret, $salt, 1000, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,8 +74,8 @@ class SecurityToken
|
|||||||
$url,
|
$url,
|
||||||
sprintf(
|
sprintf(
|
||||||
'?t=%s&s=%s',
|
'?t=%s&s=%s',
|
||||||
urlencode($token ?? ''),
|
urlencode($token),
|
||||||
urlencode($salt ?? '')
|
urlencode($salt)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class SecurityToken
|
|||||||
$generator = new RandomGenerator();
|
$generator = new RandomGenerator();
|
||||||
$result = $generator->randomToken('sha256');
|
$result = $generator->randomToken('sha256');
|
||||||
if ($length !== null) {
|
if ($length !== null) {
|
||||||
return substr($result ?? '', 0, $length);
|
return substr($result, 0, $length);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -179,29 +179,21 @@ class CommentingControllerTest extends FunctionalTest
|
|||||||
// comments sitewide
|
// comments sitewide
|
||||||
$response = $this->get('comments/rss');
|
$response = $this->get('comments/rss');
|
||||||
$comment = "10 approved, non spam comments on page 1";
|
$comment = "10 approved, non spam comments on page 1";
|
||||||
$this->assertEquals(10, substr_count($response->getBody() ?? '', "<item>"), $comment);
|
$this->assertEquals(10, substr_count($response->getBody(), "<item>"), $comment);
|
||||||
|
|
||||||
$response = $this->get('comments/rss?start=10');
|
$response = $this->get('comments/rss?start=10');
|
||||||
$this->assertEquals(
|
$this->assertEquals(4, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
|
||||||
4,
|
|
||||||
substr_count($response->getBody() ?? '', "<item>"),
|
|
||||||
"3 approved, non spam comments on page 2"
|
|
||||||
);
|
|
||||||
|
|
||||||
// all comments on a type
|
// all comments on a type
|
||||||
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem');
|
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem');
|
||||||
$this->assertEquals(10, substr_count($response->getBody() ?? '', "<item>"));
|
$this->assertEquals(10, substr_count($response->getBody(), "<item>"));
|
||||||
|
|
||||||
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem?start=10');
|
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem?start=10');
|
||||||
$this->assertEquals(
|
$this->assertEquals(4, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
|
||||||
4,
|
|
||||||
substr_count($response->getBody() ?? '', "<item>"),
|
|
||||||
"3 approved, non spam comments on page 2"
|
|
||||||
);
|
|
||||||
|
|
||||||
// specific page
|
// specific page
|
||||||
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem/'.$item->ID);
|
$response = $this->get('comments/rss/SilverStripe-Comments-Tests-Stubs-CommentableItem/'.$item->ID);
|
||||||
$this->assertEquals(1, substr_count($response->getBody() ?? '', "<item>"));
|
$this->assertEquals(1, substr_count($response->getBody(), "<item>"));
|
||||||
$this->assertStringContainsString('<dc:creator>FA</dc:creator>', $response->getBody());
|
$this->assertStringContainsString('<dc:creator>FA</dc:creator>', $response->getBody());
|
||||||
|
|
||||||
// test accessing comments on a type that doesn't exist
|
// test accessing comments on a type that doesn't exist
|
||||||
|
@ -343,7 +343,7 @@ class CommentsExtensionTest extends FunctionalTest
|
|||||||
$results[0]->Comment
|
$results[0]->Comment
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(4, sizeof($results ?? []));
|
$this->assertEquals(4, sizeof($results));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateModerationFields()
|
public function testUpdateModerationFields()
|
||||||
|
Loading…
Reference in New Issue
Block a user