mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #469 from creative-commoners/pulls/3/further-ss4-compat
ENHANCEMENT - SS4 compatibility
This commit is contained in:
commit
de0e8e0100
@ -1,8 +1 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the name of the current module folder name.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
**/
|
|
||||||
define('BLOGGER_DIR', basename(dirname(__FILE__)));
|
|
||||||
|
@ -54,8 +54,8 @@ For example in BlogPost:
|
|||||||
|
|
||||||
```php
|
```php
|
||||||
protected function getCandidateAuthors() {
|
protected function getCandidateAuthors() {
|
||||||
if($this->config()->restrict_authors_to_group) {
|
if($this->config()->get('restrict_authors_to_group')) {
|
||||||
return Group::get()->filter('Code', $this->config()->restrict_authors_to_group)->first()->Members();
|
return Group::get()->filter('Code', $this->config()->get('restrict_authors_to_group'))->first()->Members();
|
||||||
} else {
|
} else {
|
||||||
$list = Member::get();
|
$list = Member::get();
|
||||||
$this->extend('updateCandidateAuthors', $list);
|
$this->extend('updateCandidateAuthors', $list);
|
||||||
|
@ -8,10 +8,10 @@ gulp.task("scss", function () {
|
|||||||
.pipe(gulp.dest("./css"));
|
.pipe(gulp.dest("./css"));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('watch', ['scss'], function() {
|
gulp.task('watch', ['scss'], function () {
|
||||||
gulp.watch('./scss/*.scss', ['scss']);
|
gulp.watch('./scss/*.scss', ['scss']);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', ['scss'], function() {
|
gulp.task('default', ['scss'], function () {
|
||||||
// noop
|
// noop
|
||||||
});
|
});
|
||||||
|
192
js/cms.js
192
js/cms.js
@ -1,6 +1,6 @@
|
|||||||
(function ($) {
|
(function ($) {
|
||||||
|
|
||||||
$.entwine('ss', function ($) {
|
$.entwine('ss', function ($) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The page success/error message sits outside of the html block
|
* The page success/error message sits outside of the html block
|
||||||
@ -10,136 +10,136 @@
|
|||||||
* @see https://github.com/silverstripe/silverstripe-blog/issues/210
|
* @see https://github.com/silverstripe/silverstripe-blog/issues/210
|
||||||
*/
|
*/
|
||||||
$('.cms-content-fields > #Form_EditForm_error').entwine({
|
$('.cms-content-fields > #Form_EditForm_error').entwine({
|
||||||
'onadd': function() {
|
'onadd': function () {
|
||||||
var $target = $('.blog-admin-outer');
|
var $target = $('.blog-admin-outer');
|
||||||
if($target.length == 1) {
|
if ($target.length == 1) {
|
||||||
$target.prepend(this);
|
$target.prepend(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register expandable help text functions with fields.
|
* Register expandable help text functions with fields.
|
||||||
*/
|
*/
|
||||||
$('.toggle-description').entwine({
|
$('.toggle-description').entwine({
|
||||||
'onadd': function () {
|
'onadd': function () {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent multiple events being added.
|
* Prevent multiple events being added.
|
||||||
*/
|
*/
|
||||||
if ($this.hasClass('toggle-description-enabled')) {
|
if ($this.hasClass('toggle-description-enabled')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.addClass('toggle-description-enabled');
|
$this.addClass('toggle-description-enabled');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle next description when button is clicked.
|
* Toggle next description when button is clicked.
|
||||||
*/
|
*/
|
||||||
var shown = false;
|
var shown = false;
|
||||||
|
|
||||||
$this.on('click', function() {
|
$this.on('click', function () {
|
||||||
$this.parent().next('.description')[shown ? 'hide' : 'show']();
|
$this.parent().next('.description')[shown ? 'hide' : 'show']();
|
||||||
|
|
||||||
$this.toggleClass('toggle-description-shown');
|
$this.toggleClass('toggle-description-shown');
|
||||||
|
|
||||||
shown = !shown;
|
shown = !shown;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide next description by default.
|
* Hide next description by default.
|
||||||
*/
|
*/
|
||||||
$this.parent().next('.description').hide();
|
$this.parent().next('.description').hide();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add classes to correct inherited layout issues in a small context.
|
* Add classes to correct inherited layout issues in a small context.
|
||||||
*/
|
*/
|
||||||
$this.parent().addClass('toggle-description-correct-right');
|
$this.parent().addClass('toggle-description-correct-right');
|
||||||
$this.parent().prev('.middleColumn').addClass('toggle-description-correct-middle');
|
$this.parent().prev('.middleColumn').addClass('toggle-description-correct-middle');
|
||||||
$this.parent().next('.description').addClass('toggle-description-correct-description');
|
$this.parent().next('.description').addClass('toggle-description-correct-description');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom merge actions for tags and categories
|
* Custom merge actions for tags and categories
|
||||||
*/
|
*/
|
||||||
$('.MergeAction').entwine({
|
$('.MergeAction').entwine({
|
||||||
'onadd': function() {
|
'onadd': function () {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
|
|
||||||
$this.on('click', 'select', function() {
|
$this.on('click', 'select', function () {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$this.children('button').each(function(i, button) {
|
$this.children('button').each(function (i, button) {
|
||||||
var $button = $(button);
|
var $button = $(button);
|
||||||
var $select = $button.prev('select');
|
var $select = $button.prev('select');
|
||||||
|
|
||||||
$button.before('<input type="hidden" name="' + $button.attr('data-target') + '" value="' + $select.val() + '" />');
|
$button.before('<input type="hidden" name="' + $button.attr('data-target') + '" value="' + $select.val() + '" />');
|
||||||
});
|
});
|
||||||
|
|
||||||
$this.on('change', 'select', function(e) {
|
$this.on('change', 'select', function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
$target.next('input').val($target.val());
|
$target.next('input').val($target.val());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this.children('button, select').hide();
|
$this.children('button, select').hide();
|
||||||
|
|
||||||
$this.on('click', '.MergeActionReveal', function(e) {
|
$this.on('click', '.MergeActionReveal', function (e) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
$target.parent().children('button, select').show();
|
$target.parent().children('button, select').show();
|
||||||
$target.hide();
|
$target.hide();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customise the cms-panel behaviour for blog sidebar
|
* Customise the cms-panel behaviour for blog sidebar
|
||||||
*
|
*
|
||||||
* see LeftAndMain.Panel.js for base behaviour
|
* see LeftAndMain.Panel.js for base behaviour
|
||||||
*/
|
*/
|
||||||
$('.blog-admin-sidebar.cms-panel').entwine({
|
$('.blog-admin-sidebar.cms-panel').entwine({
|
||||||
MinInnerWidth: 620,
|
MinInnerWidth: 620,
|
||||||
onadd: function() {
|
onadd: function () {
|
||||||
this._super();
|
this._super();
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
|
|
||||||
// If this panel is open and the left hand column is smaller than the minimum, contract it instead
|
// If this panel is open and the left hand column is smaller than the minimum, contract it instead
|
||||||
if(!this.hasClass('collapsed') && ($(".blog-admin-outer").width() < this.getMinInnerWidth())) {
|
if (!this.hasClass('collapsed') && ($(".blog-admin-outer").width() < this.getMinInnerWidth())) {
|
||||||
this.collapsePanel();
|
this.collapsePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onresize = function() {
|
window.onresize = function () {
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
},
|
},
|
||||||
togglePanel: function(bool, silent) {
|
togglePanel: function (bool, silent) {
|
||||||
this._super(bool, silent);
|
this._super(bool, silent);
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Adjust minimum width of content to account for extra panel
|
* Adjust minimum width of content to account for extra panel
|
||||||
*
|
*
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
updateLayout: function() {
|
updateLayout: function () {
|
||||||
$(this).css('height', '100%');
|
$(this).css('height', '100%');
|
||||||
var currentHeight = $(this).outerHeight();
|
var currentHeight = $(this).outerHeight();
|
||||||
var bottomHeight = $('.cms-content-actions').eq(0).outerHeight();
|
var bottomHeight = $('.cms-content-actions').eq(0).outerHeight();
|
||||||
$(this).css('height', (currentHeight - bottomHeight) + "px");
|
$(this).css('height', (currentHeight - bottomHeight) + "px");
|
||||||
$(this).css('bottom', bottomHeight + "px");
|
$(this).css('bottom', bottomHeight + "px");
|
||||||
|
|
||||||
$('.cms-container').updateLayoutOptions({
|
$('.cms-container').updateLayoutOptions({
|
||||||
minContentWidth: 820 + this.width()
|
minContentWidth: 820 + this.width()
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -23,11 +23,11 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
|||||||
$this->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldAddNewButton');
|
$this->removeComponentsByType('SilverStripe\\Forms\\GridField\\GridFieldAddNewButton');
|
||||||
|
|
||||||
$this->addComponent(
|
$this->addComponent(
|
||||||
new GridFieldAddByDBField('buttons-before-left')
|
GridFieldAddByDBField::create('buttons-before-left')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addComponent(
|
$this->addComponent(
|
||||||
new GridFieldMergeAction($mergeRecords, $parentType, $parentMethod, $childMethod)
|
GridFieldMergeAction::create($mergeRecords, $parentType, $parentMethod, $childMethod)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,11 +36,11 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
|||||||
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
||||||
|
|
||||||
$columns->setFieldFormatting(
|
$columns->setFieldFormatting(
|
||||||
array(
|
[
|
||||||
'BlogPostsCount' => function ($value, CategorisationObject $item) {
|
'BlogPostsCount' => function ($value, CategorisationObject $item) {
|
||||||
return $item->BlogPosts()->Count();
|
return $item->BlogPosts()->Count();
|
||||||
}
|
}
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->changeColumnOrder();
|
$this->changeColumnOrder();
|
||||||
@ -57,12 +57,12 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
|||||||
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
$columns = $this->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
||||||
|
|
||||||
$columns->setDisplayFields(
|
$columns->setDisplayFields(
|
||||||
array(
|
[
|
||||||
'Title' => 'Title',
|
'Title' => 'Title',
|
||||||
'BlogPostsCount' => 'Posts',
|
'BlogPostsCount' => 'Posts',
|
||||||
'MergeAction' => 'MergeAction',
|
'MergeAction' => 'MergeAction',
|
||||||
'Actions' => 'Actions'
|
'Actions' => 'Actions'
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ class GridFieldFormAction extends GridField_FormAction
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $extraAttributes = array();
|
protected $extraAttributes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
|
@ -4,16 +4,16 @@ namespace SilverStripe\Blog\Admin;
|
|||||||
|
|
||||||
use SilverStripe\Blog\Admin\GridFieldFormAction;
|
use SilverStripe\Blog\Admin\GridFieldFormAction;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Core\Injector\Injectable;
|
||||||
use Silverstripe\Forms\DropdownField;
|
use Silverstripe\Forms\DropdownField;
|
||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use SilverStripe\Forms\GridField\GridField_ActionProvider;
|
use SilverStripe\Forms\GridField\GridField_ActionProvider;
|
||||||
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
|
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
|
||||||
|
|
||||||
/**
|
|
||||||
* @package blog
|
|
||||||
*/
|
|
||||||
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
|
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
|
||||||
{
|
{
|
||||||
|
use Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of records to show in the MergeAction column.
|
* List of records to show in the MergeAction column.
|
||||||
*
|
*
|
||||||
@ -48,7 +48,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
* @param string $parentMethod
|
* @param string $parentMethod
|
||||||
* @param string $childMethod
|
* @param string $childMethod
|
||||||
*/
|
*/
|
||||||
public function __construct($records = array(), $parentType, $parentMethod, $childMethod)
|
public function __construct($records = [], $parentType, $parentMethod, $childMethod)
|
||||||
{
|
{
|
||||||
$this->records = $records;
|
$this->records = $records;
|
||||||
$this->parentType = $parentType;
|
$this->parentType = $parentType;
|
||||||
@ -73,7 +73,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
*/
|
*/
|
||||||
public function getColumnsHandled($gridField)
|
public function getColumnsHandled($gridField)
|
||||||
{
|
{
|
||||||
return array('MergeAction');
|
return ['MergeAction'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,20 +86,20 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
$dropdown->setAttribute('id', 'Target_'.$record->ID);
|
$dropdown->setAttribute('id', 'Target_'.$record->ID);
|
||||||
$prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
|
$prefix = strtolower($this->parentMethod . '-' . $this->childMethod);
|
||||||
|
|
||||||
$action = new GridFieldFormAction(
|
$action = GridFieldFormAction::create(
|
||||||
$gridField,
|
$gridField,
|
||||||
'MergeAction' . $record->ID,
|
'MergeAction' . $record->ID,
|
||||||
'Move',
|
'Move',
|
||||||
'merge',
|
'merge',
|
||||||
array(
|
[
|
||||||
'record' => $record->ID,
|
'record' => $record->ID,
|
||||||
'target' => $prefix . '-target-record-' . $record->ID,
|
'target' => $prefix . '-target-record-' . $record->ID,
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$action->setExtraAttributes(array(
|
$action->setExtraAttributes([
|
||||||
'data-target' => $prefix . '-target-record-' . $record->ID
|
'data-target' => $prefix . '-target-record-' . $record->ID
|
||||||
));
|
]);
|
||||||
|
|
||||||
return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
|
return $dropdown->Field() . $action->Field() . '<a title="Move posts to" class="MergeActionReveal">move posts to</a>';
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
*/
|
*/
|
||||||
public function getColumnAttributes($gridField, $record, $columnName)
|
public function getColumnAttributes($gridField, $record, $columnName)
|
||||||
{
|
{
|
||||||
return array('class' => 'MergeAction');
|
return ['class' => 'MergeAction'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,7 +120,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
*/
|
*/
|
||||||
public function getColumnMetadata($gridField, $columnName)
|
public function getColumnMetadata($gridField, $columnName)
|
||||||
{
|
{
|
||||||
return array('title' => 'Move posts to');
|
return ['title' => 'Move posts to'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -128,7 +128,7 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
|||||||
*/
|
*/
|
||||||
public function getActions($gridField)
|
public function getActions($gridField)
|
||||||
{
|
{
|
||||||
return array('merge');
|
return ['merge'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Blog\Forms\GridField;
|
namespace SilverStripe\Blog\Forms\GridField;
|
||||||
|
|
||||||
|
use SilverStripe\Core\Injector\Injectable;
|
||||||
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use UnexpectedValueException;
|
use UnexpectedValueException;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
@ -15,14 +17,10 @@ use SilverStripe\Security\Security;
|
|||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\View\ArrayData;
|
||||||
use SilverStripe\View\Requirements;
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a component which allows a user to add a new DataObject by database field.
|
|
||||||
*
|
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
|
||||||
class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLProvider
|
class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLProvider
|
||||||
{
|
{
|
||||||
|
use Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTML Fragment to render the field.
|
* HTML Fragment to render the field.
|
||||||
*
|
*
|
||||||
@ -59,9 +57,9 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
*/
|
*/
|
||||||
public function getActions($gridField)
|
public function getActions($gridField)
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
'add',
|
'add',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +84,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
/**
|
/**
|
||||||
* @var DataObject $obj
|
* @var DataObject $obj
|
||||||
*/
|
*/
|
||||||
$obj = new $objClass();
|
$obj = $objClass::create();
|
||||||
|
|
||||||
if ($obj->hasField($dbField)) {
|
if ($obj->hasField($dbField)) {
|
||||||
$obj->setCastedField($dbField, $data['gridfieldaddbydbfield'][$obj->ClassName][$dbField]);
|
$obj->setCastedField($dbField, $data['gridfieldaddbydbfield'][$obj->ClassName][$dbField]);
|
||||||
@ -96,12 +94,12 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
if (!$id) {
|
if (!$id) {
|
||||||
$gridField->setCustomValidationMessage(
|
$gridField->setCustomValidationMessage(
|
||||||
_t(
|
_t(
|
||||||
'GridFieldAddByDBField.AddFail',
|
__CLASS__ . '.AddFail',
|
||||||
'Unable to save {class} to the database.',
|
'Unable to save {class} to the database.',
|
||||||
'Unable to add the DataObject.',
|
'Unable to add the DataObject.',
|
||||||
array(
|
[
|
||||||
'class' => get_class($obj),
|
'class' => get_class($obj),
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -109,12 +107,12 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
return Security::permissionFailure(
|
return Security::permissionFailure(
|
||||||
Controller::curr(),
|
Controller::curr(),
|
||||||
_t(
|
_t(
|
||||||
'GridFieldAddByDBField.PermissionFail',
|
__CLASS__ . '.PermissionFail',
|
||||||
'You don\'t have permission to create a {class}.',
|
'You don\'t have permission to create a {class}.',
|
||||||
'Unable to add the DataObject.',
|
'Unable to add the DataObject.',
|
||||||
array(
|
[
|
||||||
'class' => get_class($obj)
|
'class' => get_class($obj)
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -161,7 +159,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
*/
|
*/
|
||||||
public function getHTMLFragments($gridField)
|
public function getHTMLFragments($gridField)
|
||||||
{
|
{
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/gridfieldaddbydbfield.js');
|
Requirements::javascript(ModuleLoader::getModule('silverstripe/blog')->getRelativeResourcePath('js/gridfieldaddbydbfield.js'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DataList $dataList
|
* @var DataList $dataList
|
||||||
@ -188,11 +186,11 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
->setAttribute('placeholder', $obj->fieldLabel($dbField))
|
->setAttribute('placeholder', $obj->fieldLabel($dbField))
|
||||||
->addExtraClass('no-change-track');
|
->addExtraClass('no-change-track');
|
||||||
|
|
||||||
$addAction = new GridField_FormAction(
|
$addAction = GridField_FormAction::create(
|
||||||
$gridField,
|
$gridField,
|
||||||
'add',
|
'add',
|
||||||
_t(
|
_t(
|
||||||
'GridFieldAddByDBField.Add',
|
__CLASS__ . '.Add',
|
||||||
'Add {name}',
|
'Add {name}',
|
||||||
'Add button text',
|
'Add button text',
|
||||||
['name' => $obj->i18n_singular_name()]
|
['name' => $obj->i18n_singular_name()]
|
||||||
@ -203,12 +201,12 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
$addAction->setAttribute('data-icon', 'add');
|
$addAction->setAttribute('data-icon', 'add');
|
||||||
$addAction->addExtraClass('btn btn-primary');
|
$addAction->addExtraClass('btn btn-primary');
|
||||||
|
|
||||||
$forTemplate = new ArrayData(array());
|
$forTemplate = ArrayData::create([]);
|
||||||
|
|
||||||
$forTemplate->Fields = new ArrayList();
|
$forTemplate->Fields = ArrayList::create();
|
||||||
$forTemplate->Fields->push($textField);
|
$forTemplate->Fields->push($textField);
|
||||||
$forTemplate->Fields->push($addAction);
|
$forTemplate->Fields->push($addAction);
|
||||||
|
|
||||||
return array($this->targetFragment => $forTemplate->renderWith(self::class));
|
return [$this->targetFragment => $forTemplate->renderWith(self::class)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\Blog\Forms\GridField;
|
namespace SilverStripe\Blog\Forms\GridField;
|
||||||
|
|
||||||
use SilverStripe\Blog\Model\BlogPost;
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState;
|
use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState;
|
||||||
use SilverStripe\View\Requirements;
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
@ -10,8 +11,6 @@ use SilverStripe\View\Requirements;
|
|||||||
* Provides a component to the {@link GridField} which tells the user whether or not a blog post
|
* Provides a component to the {@link GridField} which tells the user whether or not a blog post
|
||||||
* has been published and when.
|
* has been published and when.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
*/
|
||||||
class GridFieldBlogPostState extends GridFieldSiteTreeState
|
class GridFieldBlogPostState extends GridFieldSiteTreeState
|
||||||
{
|
{
|
||||||
@ -21,12 +20,12 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
|
|||||||
public function getColumnContent($gridField, $record, $columnName)
|
public function getColumnContent($gridField, $record, $columnName)
|
||||||
{
|
{
|
||||||
if ($columnName == 'State') {
|
if ($columnName == 'State') {
|
||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
Requirements::css(ModuleLoader::getModule('silverstripe/blog')->getRelativeResourcePath('css/cms.css'));
|
||||||
if ($record instanceof BlogPost) {
|
if ($record instanceof BlogPost) {
|
||||||
$modifiedLabel = '';
|
$modifiedLabel = '';
|
||||||
|
|
||||||
if ($record->isModifiedOnStage) {
|
if ($record->isModifiedOnStage) {
|
||||||
$modifiedLabel = '<span class="modified">' . _t('GridFieldBlogPostState.Modified') . '</span>';
|
$modifiedLabel = '<span class="modified">' . _t(__CLASS__ . '.Modified') . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$record->isPublished()) {
|
if (!$record->isPublished()) {
|
||||||
@ -36,12 +35,12 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
|
|||||||
$lastEdited = $record->dbObject('LastEdited');
|
$lastEdited = $record->dbObject('LastEdited');
|
||||||
|
|
||||||
return _t(
|
return _t(
|
||||||
'GridFieldBlogPostState.Draft',
|
__CLASS__ . '.Draft',
|
||||||
'<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
|
'<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
|
||||||
'State for when a post is saved.',
|
'State for when a post is saved.',
|
||||||
array(
|
[
|
||||||
'date' => $lastEdited->FormatFromSettings(),
|
'date' => $lastEdited->FormatFromSettings(),
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,22 +51,22 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
|
|||||||
|
|
||||||
if (strtotime($record->PublishDate) > time()) {
|
if (strtotime($record->PublishDate) > time()) {
|
||||||
return _t(
|
return _t(
|
||||||
'GridFieldBlogPostState.Timer',
|
__CLASS__ . '.Timer',
|
||||||
'<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}',
|
'<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}',
|
||||||
'State for when a post is published.',
|
'State for when a post is published.',
|
||||||
array(
|
[
|
||||||
'date' => $publishDate->FormatFromSettings(),
|
'date' => $publishDate->FormatFromSettings(),
|
||||||
)
|
]
|
||||||
) . $modifiedLabel;
|
) . $modifiedLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _t(
|
return _t(
|
||||||
'GridFieldBlogPostState.Published',
|
__CLASS__ . '.Published',
|
||||||
'<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
|
'<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
|
||||||
'State for when a post is published.',
|
'State for when a post is published.',
|
||||||
array(
|
[
|
||||||
'date' => $publishDate->FormatFromSettings(),
|
'date' => $publishDate->FormatFromSettings(),
|
||||||
)
|
]
|
||||||
) . $modifiedLabel;
|
) . $modifiedLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,12 +91,12 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
|
|||||||
$class = 'gridfield-icon published';
|
$class = 'gridfield-icon published';
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return [
|
||||||
'class' => $class,
|
'class' => $class,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState;
|
|||||||
/**
|
/**
|
||||||
* GridField config necessary for managing a SiteTree object.
|
* GridField config necessary for managing a SiteTree object.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
*/
|
||||||
class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack
|
class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack
|
||||||
{
|
{
|
||||||
@ -21,6 +19,6 @@ class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack
|
|||||||
parent::__construct($itemsPerPage);
|
parent::__construct($itemsPerPage);
|
||||||
|
|
||||||
$this->removeComponentsByType(GridFieldSiteTreeState::class);
|
$this->removeComponentsByType(GridFieldSiteTreeState::class);
|
||||||
$this->addComponent(new GridFieldBlogPostState());
|
$this->addComponent(GridFieldBlogPostState::create());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ use SilverStripe\CMS\Controllers\RootURLController;
|
|||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Control\RSS\RSSFeed;
|
use SilverStripe\Control\RSS\RSSFeed;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use SilverStripe\Forms\ListboxField;
|
use SilverStripe\Forms\ListboxField;
|
||||||
use SilverStripe\Forms\NumericField;
|
use SilverStripe\Forms\NumericField;
|
||||||
@ -27,14 +28,12 @@ use SilverStripe\Security\Group;
|
|||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
use SilverStripe\Security\PermissionProvider;
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\View\Requirements;
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blog Holder
|
* Blog Holder
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*
|
|
||||||
* @method HasManyList Tags() List of tags in this blog
|
* @method HasManyList Tags() List of tags in this blog
|
||||||
* @method HasManyList Categories() List of categories in this blog
|
* @method HasManyList Categories() List of categories in this blog
|
||||||
* @method ManyManyList Editors() List of editors
|
* @method ManyManyList Editors() List of editors
|
||||||
@ -88,48 +87,48 @@ class Blog extends Page implements PermissionProvider
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'PostsPerPage' => 'Int',
|
'PostsPerPage' => 'Int',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_many = array(
|
private static $has_many = [
|
||||||
'Tags' => BlogTag::class,
|
'Tags' => BlogTag::class,
|
||||||
'Categories' => BlogCategory::class,
|
'Categories' => BlogCategory::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $many_many = array(
|
private static $many_many = [
|
||||||
'Editors' => Member::class,
|
'Editors' => Member::class,
|
||||||
'Writers' => Member::class,
|
'Writers' => Member::class,
|
||||||
'Contributors' => Member::class,
|
'Contributors' => Member::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_children = array(
|
private static $allowed_children = [
|
||||||
BlogPost::class,
|
BlogPost::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $extensions = array(
|
private static $extensions = [
|
||||||
BlogFilter::class,
|
BlogFilter::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $defaults = array(
|
private static $defaults = [
|
||||||
'ProvideComments' => false,
|
'ProvideComments' => false,
|
||||||
'PostsPerPage' => 10
|
'PostsPerPage' => 10
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -143,8 +142,9 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
$module = ModuleLoader::getModule('silverstripe/blog');
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
Requirements::css($module->getRelativeResourcePath('css/cms.css'));
|
||||||
|
Requirements::javascript($module->getRelativeResourcePath('js/cms.js'));
|
||||||
|
|
||||||
$this->beforeUpdateCMSFields(function ($fields) {
|
$this->beforeUpdateCMSFields(function ($fields) {
|
||||||
if (!$this->canEdit()) {
|
if (!$this->canEdit()) {
|
||||||
@ -153,7 +153,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
|
|
||||||
$categories = GridField::create(
|
$categories = GridField::create(
|
||||||
'Categories',
|
'Categories',
|
||||||
_t('Blog.Categories', 'Categories'),
|
_t(__CLASS__ . '.Categories', 'Categories'),
|
||||||
$this->Categories(),
|
$this->Categories(),
|
||||||
GridFieldCategorisationConfig::create(
|
GridFieldCategorisationConfig::create(
|
||||||
15,
|
15,
|
||||||
@ -166,7 +166,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
|
|
||||||
$tags = GridField::create(
|
$tags = GridField::create(
|
||||||
'Tags',
|
'Tags',
|
||||||
_t('Blog.Tags', 'Tags'),
|
_t(__CLASS__ . '.Tags', 'Tags'),
|
||||||
$this->Tags(),
|
$this->Tags(),
|
||||||
GridFieldCategorisationConfig::create(
|
GridFieldCategorisationConfig::create(
|
||||||
15,
|
15,
|
||||||
@ -182,10 +182,10 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
$fields->addFieldsToTab(
|
$fields->addFieldsToTab(
|
||||||
'Root.Categorisation',
|
'Root.Categorisation',
|
||||||
array(
|
[
|
||||||
$categories,
|
$categories,
|
||||||
$tags
|
$tags
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation');
|
$fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation');
|
||||||
@ -216,7 +216,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
protected function getMember($member = null)
|
protected function getMember($member = null)
|
||||||
{
|
{
|
||||||
if (!$member) {
|
if (!$member) {
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($member)) {
|
if (is_numeric($member)) {
|
||||||
@ -284,15 +284,15 @@ class Blog extends Page implements PermissionProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isEditor($member)) {
|
if ($this->isEditor($member)) {
|
||||||
return _t('Blog.EDITOR', 'Editor');
|
return _t(__CLASS__ . '.EDITOR', 'Editor');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isWriter($member)) {
|
if ($this->isWriter($member)) {
|
||||||
return _t('Blog.WRITER', 'Writer');
|
return _t(__CLASS__ . '.WRITER', 'Writer');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isContributor($member)) {
|
if ($this->isContributor($member)) {
|
||||||
return _t('Blog.CONTRIBUTOR', 'Contributor');
|
return _t(__CLASS__ . '.CONTRIBUTOR', 'Contributor');
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -351,7 +351,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Settings',
|
'Root.Settings',
|
||||||
NumericField::create('PostsPerPage', _t('Blog.PostsPerPage', 'Posts Per Page'))
|
NumericField::create('PostsPerPage', _t(__CLASS__ . '.PostsPerPage', 'Posts Per Page'))
|
||||||
);
|
);
|
||||||
|
|
||||||
$members = $this->getCandidateUsers()->map()->toArray();
|
$members = $this->getCandidateUsers()->map()->toArray();
|
||||||
@ -408,11 +408,11 @@ class Blog extends Page implements PermissionProvider
|
|||||||
|
|
||||||
$fields->addFieldsToTab(
|
$fields->addFieldsToTab(
|
||||||
'Root.Users',
|
'Root.Users',
|
||||||
array(
|
[
|
||||||
$editorField,
|
$editorField,
|
||||||
$writerField,
|
$writerField,
|
||||||
$contributorField
|
$contributorField
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
@ -425,13 +425,13 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
protected function getCandidateUsers()
|
protected function getCandidateUsers()
|
||||||
{
|
{
|
||||||
if ($this->config()->grant_user_access) {
|
if ($this->config()->get('grant_user_access')) {
|
||||||
$list = Member::get();
|
$list = Member::get();
|
||||||
$this->extend('updateCandidateUsers', $list);
|
$this->extend('updateCandidateUsers', $list);
|
||||||
return $list;
|
return $list;
|
||||||
} else {
|
} else {
|
||||||
return Permission::get_members_by_permission(
|
return Permission::get_members_by_permission(
|
||||||
$this->config()->grant_user_permission
|
$this->config()->get('grant_user_permission')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
sprintf('"SiteTree%s"."ID" = "BlogPost%s"."ID"', $stage, $stage)
|
sprintf('"SiteTree%s"."ID" = "BlogPost%s"."ID"', $stage, $stage)
|
||||||
);
|
);
|
||||||
|
|
||||||
$conn = DB::getConn();
|
$conn = DB::get_conn();
|
||||||
|
|
||||||
// Filter by year
|
// Filter by year
|
||||||
$yearCond = $conn->formattedDatetimeClause('"BlogPost"."PublishDate"', '%Y');
|
$yearCond = $conn->formattedDatetimeClause('"BlogPost"."PublishDate"', '%Y');
|
||||||
@ -588,7 +588,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
public function getLumberjackTitle()
|
public function getLumberjackTitle()
|
||||||
{
|
{
|
||||||
return _t('Blog.LumberjackTitle', 'Blog Posts');
|
return _t(__CLASS__ . '.LumberjackTitle', 'Blog Posts');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -606,20 +606,20 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
public function providePermissions()
|
public function providePermissions()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
Blog::MANAGE_USERS => array(
|
Blog::MANAGE_USERS => [
|
||||||
'name' => _t(
|
'name' => _t(
|
||||||
'Blog.PERMISSION_MANAGE_USERS_DESCRIPTION',
|
__CLASS__ . '.PERMISSION_MANAGE_USERS_DESCRIPTION',
|
||||||
'Manage users for individual blogs'
|
'Manage users for individual blogs'
|
||||||
),
|
),
|
||||||
'help' => _t(
|
'help' => _t(
|
||||||
'Blog.PERMISSION_MANAGE_USERS_HELP',
|
__CLASS__ . '.PERMISSION_MANAGE_USERS_HELP',
|
||||||
'Allow assignment of Editors, Writers, or Contributors to blogs'
|
'Allow assignment of Editors, Writers, or Contributors to blogs'
|
||||||
),
|
),
|
||||||
'category' => _t('Blog.PERMISSIONS_CATEGORY', 'Blog permissions'),
|
'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'Blog permissions'),
|
||||||
'sort' => 100
|
'sort' => 100
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -636,7 +636,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
protected function assignGroup()
|
protected function assignGroup()
|
||||||
{
|
{
|
||||||
if (!$this->config()->grant_user_access) {
|
if (!$this->config()->get('grant_user_access')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +644,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
|
|
||||||
// Must check if the method exists or else an error occurs when changing page type
|
// Must check if the method exists or else an error occurs when changing page type
|
||||||
if ($this->hasMethod('Editors')) {
|
if ($this->hasMethod('Editors')) {
|
||||||
foreach (array($this->Editors(), $this->Writers(), $this->Contributors()) as $levels) {
|
foreach ([$this->Editors(), $this->Writers(), $this->Contributors()] as $levels) {
|
||||||
foreach ($levels as $user) {
|
foreach ($levels as $user) {
|
||||||
if (!$user->inGroup($group)) {
|
if (!$user->inGroup($group)) {
|
||||||
$user->Groups()->add($group);
|
$user->Groups()->add($group);
|
||||||
@ -661,7 +661,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
protected function getUserGroup()
|
protected function getUserGroup()
|
||||||
{
|
{
|
||||||
$code = $this->config()->grant_user_group;
|
$code = $this->config()->get('grant_user_group');
|
||||||
|
|
||||||
$group = Group::get()->filter('Code', $code)->first();
|
$group = Group::get()->filter('Code', $code)->first();
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
$group->write();
|
$group->write();
|
||||||
|
|
||||||
$permission = Permission::create();
|
$permission = Permission::create();
|
||||||
$permission->Code = $this->config()->grant_user_permission;
|
$permission->Code = $this->config()->get('grant_user_permission');
|
||||||
|
|
||||||
$group->Permissions()->add($permission);
|
$group->Permissions()->add($permission);
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@ use SilverStripe\ORM\DataObject;
|
|||||||
/**
|
/**
|
||||||
* A blog category for generalising blog posts.
|
* A blog category for generalising blog posts.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
*
|
||||||
* @subpackage blog
|
|
||||||
*
|
|
||||||
* @method Blog Blog()
|
* @method Blog Blog()
|
||||||
*
|
*
|
||||||
* @property string $Title
|
* @property string $Title
|
||||||
@ -42,24 +40,24 @@ class BlogCategory extends DataObject implements CategorisationObject
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'Title' => 'Varchar(255)',
|
'Title' => 'Varchar(255)',
|
||||||
'URLSegment' => 'Varchar(255)'
|
'URLSegment' => 'Varchar(255)'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class,
|
'Blog' => Blog::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = [
|
||||||
'BlogPosts' => BlogPost::class,
|
'BlogPosts' => BlogPost::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -74,6 +72,6 @@ class BlogCategory extends DataObject implements CategorisationObject
|
|||||||
*/
|
*/
|
||||||
protected function getDuplicateError()
|
protected function getDuplicateError()
|
||||||
{
|
{
|
||||||
return _t('BlogCategory.Duplicate', 'A blog category already exists with that name.');
|
return _t(__CLASS__ . '.Duplicate', 'A blog category already exists with that name.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,40 +9,36 @@ use SilverStripe\ORM\FieldType\DBDatetime;
|
|||||||
use SilverStripe\ORM\PaginatedList;
|
use SilverStripe\ORM\PaginatedList;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
|
||||||
class BlogController extends PageController
|
class BlogController extends PageController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = [
|
||||||
'archive',
|
'archive',
|
||||||
'tag',
|
'tag',
|
||||||
'category',
|
'category',
|
||||||
'rss',
|
'rss',
|
||||||
'profile'
|
'profile'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = [
|
||||||
'tag/$Tag!/$Rss' => 'tag',
|
'tag/$Tag!/$Rss' => 'tag',
|
||||||
'category/$Category!/$Rss' => 'category',
|
'category/$Category!/$Rss' => 'category',
|
||||||
'archive/$Year!/$Month/$Day' => 'archive',
|
'archive/$Year!/$Month/$Day' => 'archive',
|
||||||
'profile/$URLSegment!' => 'profile'
|
'profile/$URLSegment!' => 'profile'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $casting = array(
|
private static $casting = [
|
||||||
'MetaTitle' => 'Text',
|
'MetaTitle' => 'Text',
|
||||||
'FilterDescription' => 'Text'
|
'FilterDescription' => 'Text'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current Blog Post DataList query.
|
* The current Blog Post DataList query.
|
||||||
@ -247,7 +243,7 @@ class BlogController extends PageController
|
|||||||
$tag = $this->request->param('Tag');
|
$tag = $this->request->param('Tag');
|
||||||
if ($tag) {
|
if ($tag) {
|
||||||
return $dataRecord->Tags()
|
return $dataRecord->Tags()
|
||||||
->filter('URLSegment', array($tag, rawurlencode($tag)))
|
->filter('URLSegment', [$tag, rawurlencode($tag)])
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -291,7 +287,7 @@ class BlogController extends PageController
|
|||||||
$category = $this->request->param('Category');
|
$category = $this->request->param('Category');
|
||||||
if ($category) {
|
if ($category) {
|
||||||
return $dataRecord->Categories()
|
return $dataRecord->Categories()
|
||||||
->filter('URLSegment', array($category, rawurlencode($category)))
|
->filter('URLSegment', [$category, rawurlencode($category)])
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -323,52 +319,52 @@ class BlogController extends PageController
|
|||||||
*/
|
*/
|
||||||
public function getFilterDescription()
|
public function getFilterDescription()
|
||||||
{
|
{
|
||||||
$items = array();
|
$items = [];
|
||||||
|
|
||||||
$list = $this->PaginatedList();
|
$list = $this->PaginatedList();
|
||||||
$currentPage = $list->CurrentPage();
|
$currentPage = $list->CurrentPage();
|
||||||
|
|
||||||
if ($currentPage > 1) {
|
if ($currentPage > 1) {
|
||||||
$items[] = _t(
|
$items[] = _t(
|
||||||
'Blog.FILTERDESCRIPTION_PAGE',
|
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_PAGE',
|
||||||
'Page {page}',
|
'Page {page}',
|
||||||
null,
|
null,
|
||||||
array(
|
[
|
||||||
'page' => $currentPage
|
'page' => $currentPage
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($author = $this->getCurrentProfile()) {
|
if ($author = $this->getCurrentProfile()) {
|
||||||
$items[] = _t(
|
$items[] = _t(
|
||||||
'Blog.FILTERDESCRIPTION_AUTHOR',
|
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_AUTHOR',
|
||||||
'By {author}',
|
'By {author}',
|
||||||
null,
|
null,
|
||||||
array(
|
[
|
||||||
'author' => $author->Title
|
'author' => $author->Title
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tag = $this->getCurrentTag()) {
|
if ($tag = $this->getCurrentTag()) {
|
||||||
$items[] = _t(
|
$items[] = _t(
|
||||||
'Blog.FILTERDESCRIPTION_TAG',
|
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_TAG',
|
||||||
'Tagged with {tag}',
|
'Tagged with {tag}',
|
||||||
null,
|
null,
|
||||||
array(
|
[
|
||||||
'tag' => $tag->Title
|
'tag' => $tag->Title
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($category = $this->getCurrentCategory()) {
|
if ($category = $this->getCurrentCategory()) {
|
||||||
$items[] = _t(
|
$items[] = _t(
|
||||||
'Blog.FILTERDESCRIPTION_CATEGORY',
|
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_CATEGORY',
|
||||||
'In category {category}',
|
'In category {category}',
|
||||||
null,
|
null,
|
||||||
array(
|
[
|
||||||
'category' => $category->Title
|
'category' => $category->Title
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,12 +378,12 @@ class BlogController extends PageController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$items[] = _t(
|
$items[] = _t(
|
||||||
'Blog.FILTERDESCRIPTION_DATE',
|
'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_DATE',
|
||||||
'In {date}',
|
'In {date}',
|
||||||
null,
|
null,
|
||||||
array(
|
[
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +492,7 @@ class BlogController extends PageController
|
|||||||
*/
|
*/
|
||||||
protected function rssFeed($blogPosts, $link)
|
protected function rssFeed($blogPosts, $link)
|
||||||
{
|
{
|
||||||
$rss = new RSSFeed($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
|
$rss = RSSFeed::create($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
|
||||||
|
|
||||||
$this->extend('updateRss', $rss);
|
$this->extend('updateRss', $rss);
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@ use SilverStripe\Security\Permission;
|
|||||||
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
|
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
|
||||||
* filtering only published posts.
|
* filtering only published posts.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
*/
|
||||||
class BlogFilter extends Lumberjack
|
class BlogFilter extends Lumberjack
|
||||||
{
|
{
|
||||||
@ -98,10 +96,10 @@ class BlogFilter extends Lumberjack
|
|||||||
$excluded = $this->owner->getExcludedSiteTreeClassNames();
|
$excluded = $this->owner->getExcludedSiteTreeClassNames();
|
||||||
|
|
||||||
if (!empty($excluded)) {
|
if (!empty($excluded)) {
|
||||||
$pages = BlogPost::get()->filter(array(
|
$pages = BlogPost::get()->filter([
|
||||||
'ParentID' => $this->owner->ID,
|
'ParentID' => $this->owner->ID,
|
||||||
'ClassName' => $excluded
|
'ClassName' => $excluded
|
||||||
));
|
]);
|
||||||
|
|
||||||
$gridField = BlogFilterGridField::create(
|
$gridField = BlogFilterGridField::create(
|
||||||
'ChildPages',
|
'ChildPages',
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\Blog\Model;
|
|||||||
use SilverStripe\Assets\Image;
|
use SilverStripe\Assets\Image;
|
||||||
use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost;
|
use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost;
|
||||||
use SilverStripe\Blog\Model\BlogPost;
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use SilverStripe\Forms\Tab;
|
use SilverStripe\Forms\Tab;
|
||||||
@ -16,32 +17,30 @@ use SilverStripe\View\Requirements;
|
|||||||
/**
|
/**
|
||||||
* This class is responsible for add Blog specific behaviour to Members.
|
* This class is responsible for add Blog specific behaviour to Members.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
*/
|
||||||
class BlogMemberExtension extends DataExtension
|
class BlogMemberExtension extends DataExtension
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'URLSegment' => 'Varchar',
|
'URLSegment' => 'Varchar',
|
||||||
'BlogProfileSummary' => 'Text'
|
'BlogProfileSummary' => 'Text'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'BlogProfileImage' => Image::class
|
'BlogProfileImage' => Image::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = [
|
||||||
'BlogPosts' => BlogPost::class
|
'BlogPosts' => BlogPost::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -53,7 +52,7 @@ class BlogMemberExtension extends DataExtension
|
|||||||
if ($this->owner->URLSegment && !$this->owner->isChanged('FirstName') && !$this->owner->isChanged('Surname')) {
|
if ($this->owner->URLSegment && !$this->owner->isChanged('FirstName') && !$this->owner->isChanged('Surname')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->owner->URLSegment = $this->generateURLSegment();
|
$this->owner->URLSegment = $this->generateURLSegment();
|
||||||
|
|
||||||
while (!$this->validURLSegment()) {
|
while (!$this->validURLSegment()) {
|
||||||
@ -109,15 +108,15 @@ class BlogMemberExtension extends DataExtension
|
|||||||
$fields->removeFieldFromTab('Root', 'BlogPosts');
|
$fields->removeFieldFromTab('Root', 'BlogPosts');
|
||||||
|
|
||||||
// Construct a better posts tab.
|
// Construct a better posts tab.
|
||||||
|
$module = ModuleLoader::getModule('silverstripe/blog');
|
||||||
|
Requirements::css($module->getRelativeResourcePath('css/cms.css'));
|
||||||
|
Requirements::javascript($module->getRelativeResourcePath('js/cms.js'));
|
||||||
|
|
||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
$tab = Tab::create('BlogPosts', _t(__CLASS__ . '.TABBLOGPOSTS', 'Blog Posts'));
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
|
||||||
|
|
||||||
$tab = Tab::create('BlogPosts', _t('BlogMemberExtension.TABBLOGPOSTS', 'Blog Posts'));
|
|
||||||
|
|
||||||
$gridField = GridField::create(
|
$gridField = GridField::create(
|
||||||
'BlogPosts',
|
'BlogPosts',
|
||||||
_t('BlogMemberExtension.BLOGPOSTS', 'Blog Posts'),
|
_t(__CLASS__ . '.BLOGPOSTS', 'Blog Posts'),
|
||||||
$this->owner->BlogPosts(),
|
$this->owner->BlogPosts(),
|
||||||
GridFieldConfig_BlogPost::create()
|
GridFieldConfig_BlogPost::create()
|
||||||
);
|
);
|
||||||
|
@ -15,8 +15,6 @@ use SilverStripe\View\Parsers\URLSegmentFilter;
|
|||||||
/**
|
/**
|
||||||
* An object shared by BlogTag and BlogCategory.
|
* An object shared by BlogTag and BlogCategory.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
*/
|
||||||
trait BlogObject
|
trait BlogObject
|
||||||
{
|
{
|
||||||
@ -37,12 +35,11 @@ trait BlogObject
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$shortClass = ClassInfo::shortName(self::class);
|
|
||||||
$fields = TabSet::create(
|
$fields = TabSet::create(
|
||||||
'Root',
|
'Root',
|
||||||
Tab::create(
|
Tab::create(
|
||||||
'Main',
|
'Main',
|
||||||
TextField::create('Title', _t($shortClass . '.Title', 'Title'))
|
TextField::create('Title', _t(__CLASS__ . '.Title', 'Title'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -111,7 +108,7 @@ trait BlogObject
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function canCreate($member = null, $context = array())
|
public function canCreate($member = null, $context = [])
|
||||||
{
|
{
|
||||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ use SilverStripe\Blog\Model\BlogCategory;
|
|||||||
use SilverStripe\Blog\Model\BlogPostFilter;
|
use SilverStripe\Blog\Model\BlogPostFilter;
|
||||||
use SilverStripe\Blog\Model\BlogTag;
|
use SilverStripe\Blog\Model\BlogTag;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use SilverStripe\Forms\DatetimeField;
|
use SilverStripe\Forms\DatetimeField;
|
||||||
use SilverStripe\Forms\HiddenField;
|
use SilverStripe\Forms\HiddenField;
|
||||||
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||||
@ -22,6 +23,7 @@ use SilverStripe\ORM\UnsavedRelationList;
|
|||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\TagField\TagField;
|
use SilverStripe\TagField\TagField;
|
||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\View\ArrayData;
|
||||||
use SilverStripe\View\Requirements;
|
use SilverStripe\View\Requirements;
|
||||||
@ -29,9 +31,6 @@ use SilverStripe\View\Requirements;
|
|||||||
/**
|
/**
|
||||||
* An individual blog post.
|
* An individual blog post.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*
|
|
||||||
* @method ManyManyList Categories()
|
* @method ManyManyList Categories()
|
||||||
* @method ManyManyList Tags()
|
* @method ManyManyList Tags()
|
||||||
* @method ManyManyList Authors()
|
* @method ManyManyList Authors()
|
||||||
@ -59,77 +58,77 @@ class BlogPost extends Page
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'PublishDate' => 'Datetime',
|
'PublishDate' => 'Datetime',
|
||||||
'AuthorNames' => 'Varchar(1024)',
|
'AuthorNames' => 'Varchar(1024)',
|
||||||
'Summary' => 'HTMLText'
|
'Summary' => 'HTMLText'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'FeaturedImage' => Image::class
|
'FeaturedImage' => Image::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $owns = array(
|
private static $owns = [
|
||||||
'FeaturedImage',
|
'FeaturedImage',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $many_many = array(
|
private static $many_many = [
|
||||||
'Categories' => BlogCategory::class,
|
'Categories' => BlogCategory::class,
|
||||||
'Tags' => BlogTag::class,
|
'Tags' => BlogTag::class,
|
||||||
'Authors' => Member::class
|
'Authors' => Member::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $defaults = array(
|
private static $defaults = [
|
||||||
'ShowInMenus' => false,
|
'ShowInMenus' => false,
|
||||||
'InheritSideBar' => true,
|
'InheritSideBar' => true,
|
||||||
'ProvideComments' => true
|
'ProvideComments' => true
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $extensions = array(
|
private static $extensions = [
|
||||||
BlogPostFilter::class
|
BlogPostFilter::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $searchable_fields = array(
|
private static $searchable_fields = [
|
||||||
'Title'
|
'Title'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $summary_fields = array(
|
private static $summary_fields = [
|
||||||
'Title'
|
'Title'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $casting = array(
|
private static $casting = [
|
||||||
'Excerpt' => 'HTMLText',
|
'Excerpt' => 'HTMLText',
|
||||||
'Date' => 'DBDatetime'
|
'Date' => 'DBDatetime'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_children = array();
|
private static $allowed_children = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default sorting lists BlogPosts with an empty PublishDate at the top.
|
* The default sorting lists BlogPosts with an empty PublishDate at the top.
|
||||||
@ -171,7 +170,7 @@ class BlogPost extends Page
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isAuthor($member)) {
|
if ($this->isAuthor($member)) {
|
||||||
return _t('BlogPost.AUTHOR', 'Author');
|
return _t(__CLASS__ . '.AUTHOR', 'Author');
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->Parent();
|
$parent = $this->Parent();
|
||||||
@ -210,12 +209,13 @@ class BlogPost extends Page
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
$module = ModuleLoader::getModule('silverstripe/blog');
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
Requirements::css($module->getRelativeResourcePath('css/cms.css'));
|
||||||
|
Requirements::javascript($module->getRelativeResourcePath('js/cms.js'));
|
||||||
|
|
||||||
$this->beforeUpdateCMSFields(function ($fields) {
|
$this->beforeUpdateCMSFields(function ($fields) {
|
||||||
$uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image'));
|
$uploadField = UploadField::create('FeaturedImage', _t(__CLASS__ . '.FeaturedImage', 'Featured Image'));
|
||||||
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
|
$uploadField->getValidator()->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FieldList $fields
|
* @var FieldList $fields
|
||||||
@ -225,16 +225,16 @@ class BlogPost extends Page
|
|||||||
$summary = HtmlEditorField::create('Summary', false);
|
$summary = HtmlEditorField::create('Summary', false);
|
||||||
$summary->setRows(5);
|
$summary->setRows(5);
|
||||||
$summary->setDescription(_t(
|
$summary->setDescription(_t(
|
||||||
'BlogPost.SUMMARY_DESCRIPTION',
|
__CLASS__ . '.SUMMARY_DESCRIPTION',
|
||||||
'If no summary is specified the first 30 words will be used.'
|
'If no summary is specified the first 30 words will be used.'
|
||||||
));
|
));
|
||||||
|
|
||||||
$summaryHolder = ToggleCompositeField::create(
|
$summaryHolder = ToggleCompositeField::create(
|
||||||
'CustomSummary',
|
'CustomSummary',
|
||||||
_t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'),
|
_t(__CLASS__ . '.CUSTOMSUMMARY', 'Add A Custom Summary'),
|
||||||
array(
|
[
|
||||||
$summary,
|
$summary,
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$summaryHolder->setHeadingLevel(4);
|
$summaryHolder->setHeadingLevel(4);
|
||||||
$summaryHolder->addExtraClass('custom-summary');
|
$summaryHolder->addExtraClass('custom-summary');
|
||||||
@ -244,25 +244,25 @@ class BlogPost extends Page
|
|||||||
$urlSegment = $fields->dataFieldByName('URLSegment');
|
$urlSegment = $fields->dataFieldByName('URLSegment');
|
||||||
$urlSegment->setURLPrefix($this->Parent()->RelativeLink());
|
$urlSegment->setURLPrefix($this->Parent()->RelativeLink());
|
||||||
|
|
||||||
$fields->removeFieldsFromTab('Root.Main', array(
|
$fields->removeFieldsFromTab('Root.Main', [
|
||||||
'MenuTitle',
|
'MenuTitle',
|
||||||
'URLSegment',
|
'URLSegment',
|
||||||
));
|
]);
|
||||||
|
|
||||||
$authorField = ListboxField::create(
|
$authorField = ListboxField::create(
|
||||||
'Authors',
|
'Authors',
|
||||||
_t('BlogPost.Authors', 'Authors'),
|
_t(__CLASS__ . '.Authors', 'Authors'),
|
||||||
$this->getCandidateAuthors()->map()->toArray()
|
$this->getCandidateAuthors()->map()->toArray()
|
||||||
);
|
);
|
||||||
|
|
||||||
$authorNames = TextField::create(
|
$authorNames = TextField::create(
|
||||||
'AuthorNames',
|
'AuthorNames',
|
||||||
_t('BlogPost.AdditionalCredits', 'Additional Credits'),
|
_t(__CLASS__ . '.AdditionalCredits', 'Additional Credits'),
|
||||||
null,
|
null,
|
||||||
1024
|
1024
|
||||||
)->setDescription(
|
)->setDescription(
|
||||||
_t(
|
_t(
|
||||||
'BlogPost.AdditionalCredits_Description',
|
__CLASS__ . '.AdditionalCredits_Description',
|
||||||
'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.'
|
'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -272,12 +272,12 @@ class BlogPost extends Page
|
|||||||
$authorNames = $authorNames->performDisabledTransformation();
|
$authorNames = $authorNames->performDisabledTransformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
$publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date'));
|
$publishDate = DatetimeField::create('PublishDate', _t(__CLASS__ . '.PublishDate', 'Publish Date'));
|
||||||
|
|
||||||
if (!$this->PublishDate) {
|
if (!$this->PublishDate) {
|
||||||
$publishDate->setDescription(
|
$publishDate->setDescription(
|
||||||
_t(
|
_t(
|
||||||
'BlogPost.PublishDate_Description',
|
__CLASS__ . '.PublishDate_Description',
|
||||||
'Will be set to "now" if published without a value.'
|
'Will be set to "now" if published without a value.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -301,7 +301,7 @@ class BlogPost extends Page
|
|||||||
$urlSegment,
|
$urlSegment,
|
||||||
TagField::create(
|
TagField::create(
|
||||||
'Categories',
|
'Categories',
|
||||||
_t('BlogPost.Categories', 'Categories'),
|
_t(__CLASS__ . '.Categories', 'Categories'),
|
||||||
$categories,
|
$categories,
|
||||||
$this->Categories()
|
$this->Categories()
|
||||||
)
|
)
|
||||||
@ -309,7 +309,7 @@ class BlogPost extends Page
|
|||||||
->setShouldLazyLoad(true),
|
->setShouldLazyLoad(true),
|
||||||
TagField::create(
|
TagField::create(
|
||||||
'Tags',
|
'Tags',
|
||||||
_t('BlogPost.Tags', 'Tags'),
|
_t(__CLASS__ . '.Tags', 'Tags'),
|
||||||
$tags,
|
$tags,
|
||||||
$this->Tags()
|
$this->Tags()
|
||||||
)
|
)
|
||||||
@ -338,8 +338,8 @@ class BlogPost extends Page
|
|||||||
*/
|
*/
|
||||||
public function getCandidateAuthors()
|
public function getCandidateAuthors()
|
||||||
{
|
{
|
||||||
if ($this->config()->restrict_authors_to_group) {
|
if ($this->config()->get('restrict_authors_to_group')) {
|
||||||
return Group::get()->filter('Code', $this->config()->restrict_authors_to_group)->first()->Members();
|
return Group::get()->filter('Code', $this->config()->get('restrict_authors_to_group'))->first()->Members();
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = Member::get();
|
$list = Member::get();
|
||||||
@ -387,7 +387,7 @@ class BlogPost extends Page
|
|||||||
protected function getMember($member = null)
|
protected function getMember($member = null)
|
||||||
{
|
{
|
||||||
if (!$member) {
|
if (!$member) {
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($member)) {
|
if (is_numeric($member)) {
|
||||||
@ -674,16 +674,16 @@ class BlogPost extends Page
|
|||||||
// If there is no parent blog, return list undecorated
|
// If there is no parent blog, return list undecorated
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
$items = $this->Authors()->toArray();
|
$items = $this->Authors()->toArray();
|
||||||
return new ArrayList($items);
|
return ArrayList::create($items);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update all authors
|
// Update all authors
|
||||||
$items = new ArrayList();
|
$items = ArrayList::create();
|
||||||
foreach ($this->Authors() as $author) {
|
foreach ($this->Authors() as $author) {
|
||||||
// Add link for each author
|
// Add link for each author
|
||||||
$author = $author->customise(array(
|
$author = $author->customise([
|
||||||
'URL' => $parent->ProfileLink($author->URLSegment),
|
'URL' => $parent->ProfileLink($author->URLSegment),
|
||||||
));
|
]);
|
||||||
$items->push($author);
|
$items->push($author);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,14 +697,14 @@ class BlogPost extends Page
|
|||||||
*/
|
*/
|
||||||
protected function getStaticCredits()
|
protected function getStaticCredits()
|
||||||
{
|
{
|
||||||
$items = new ArrayList();
|
$items = ArrayList::create();
|
||||||
|
|
||||||
$authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames));
|
$authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames));
|
||||||
|
|
||||||
foreach ($authors as $author) {
|
foreach ($authors as $author) {
|
||||||
$item = new ArrayData(array(
|
$item = ArrayData::create([
|
||||||
'Name' => $author,
|
'Name' => $author,
|
||||||
));
|
]);
|
||||||
|
|
||||||
$items->push($item);
|
$items->push($item);
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ class BlogPost extends Page
|
|||||||
{
|
{
|
||||||
$labels = parent::fieldLabels($includeRelations);
|
$labels = parent::fieldLabels($includeRelations);
|
||||||
|
|
||||||
$labels['Title'] = _t('BlogPost.PageTitleLabel', 'Post Title');
|
$labels['Title'] = _t(__CLASS__ . '.PageTitleLabel', 'Post Title');
|
||||||
|
|
||||||
return $labels;
|
return $labels;
|
||||||
}
|
}
|
||||||
@ -746,7 +746,7 @@ class BlogPost extends Page
|
|||||||
{
|
{
|
||||||
parent::onBeforeWrite();
|
parent::onBeforeWrite();
|
||||||
|
|
||||||
if (!$this->exists() && ($member = Member::currentUser())) {
|
if (!$this->exists() && ($member = Security::getCurrentUser())) {
|
||||||
$this->Authors()->add($member);
|
$this->Authors()->add($member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,6 @@ namespace SilverStripe\Blog\Model;
|
|||||||
|
|
||||||
use PageController;
|
use PageController;
|
||||||
|
|
||||||
/**
|
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
|
||||||
class BlogPostController extends PageController
|
class BlogPostController extends PageController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -17,8 +17,6 @@ use SilverStripe\Security\Permission;
|
|||||||
* This is responsible for filtering only published posts to users who do not have permission to
|
* This is responsible for filtering only published posts to users who do not have permission to
|
||||||
* view non-published posts.
|
* view non-published posts.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
*/
|
||||||
class BlogPostFilter extends DataExtension
|
class BlogPostFilter extends DataExtension
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ class BlogPostNotifications extends DataExtension
|
|||||||
|
|
||||||
// If comment is spam and notification are set to not send on spam clear the recipient list
|
// If comment is spam and notification are set to not send on spam clear the recipient list
|
||||||
if (Config::inst()->get(__CLASS__, 'notification_on_spam') == false && $comment->IsSpam) {
|
if (Config::inst()->get(__CLASS__, 'notification_on_spam') == false && $comment->IsSpam) {
|
||||||
$list = array();
|
$list = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ use SilverStripe\Blog\Model\CategorisationObject;
|
|||||||
/**
|
/**
|
||||||
* A blog tag for keyword descriptions of a blog post.
|
* A blog tag for keyword descriptions of a blog post.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*
|
*
|
||||||
* @method Blog Blog()
|
* @method Blog Blog()
|
||||||
*
|
*
|
||||||
@ -42,24 +40,24 @@ class BlogTag extends DataObject implements CategorisationObject
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'Title' => 'Varchar(255)',
|
'Title' => 'Varchar(255)',
|
||||||
'URLSegment' => 'Varchar(255)'
|
'URLSegment' => 'Varchar(255)'
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class
|
'Blog' => Blog::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = [
|
||||||
'BlogPosts' => BlogPost::class
|
'BlogPosts' => BlogPost::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -74,6 +72,6 @@ class BlogTag extends DataObject implements CategorisationObject
|
|||||||
*/
|
*/
|
||||||
protected function getDuplicateError()
|
protected function getDuplicateError()
|
||||||
{
|
{
|
||||||
return _t('BlogTag.Duplicate', 'A blog tag already exists with that name.');
|
return _t(__CLASS__ . '.Duplicate', 'A blog tag already exists with that name.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,24 +38,24 @@ class BlogArchiveWidget extends Widget
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'NumberToDisplay' => 'Int',
|
'NumberToDisplay' => 'Int',
|
||||||
'ArchiveType' => 'Enum(\'Monthly,Yearly\', \'Monthly\')',
|
'ArchiveType' => 'Enum(\'Monthly,Yearly\', \'Monthly\')',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $defaults = array(
|
private static $defaults = [
|
||||||
'NumberOfMonths' => 12,
|
'NumberOfMonths' => 12,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class,
|
'Blog' => Blog::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -71,21 +71,21 @@ class BlogArchiveWidget extends Widget
|
|||||||
$type = $archiveType->enumValues();
|
$type = $archiveType->enumValues();
|
||||||
|
|
||||||
foreach ($type as $k => $v) {
|
foreach ($type as $k => $v) {
|
||||||
$type[$k] = _t('BlogArchiveWidget.' . ucfirst(strtolower($v)), $v);
|
$type[$k] = _t(__CLASS__ .'.' . ucfirst(strtolower($v)), $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FieldList $fields
|
* @var FieldList $fields
|
||||||
*/
|
*/
|
||||||
$fields->merge(array(
|
$fields->merge([
|
||||||
DropdownField::create(
|
DropdownField::create(
|
||||||
'BlogID',
|
'BlogID',
|
||||||
_t('BlogArchiveWidget.Blog', 'Blog'),
|
_t(__CLASS__ . '.Blog', 'Blog'),
|
||||||
Blog::get()->map()
|
Blog::get()->map()
|
||||||
),
|
),
|
||||||
DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type),
|
DropdownField::create('ArchiveType', _t(__CLASS__ . '.ArchiveType', 'ArchiveType'), $type),
|
||||||
NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display'))
|
NumericField::create('NumberToDisplay', _t(__CLASS__ . '.NumberToDisplay', 'No. to Display'))
|
||||||
));
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return parent::getCMSFields();
|
return parent::getCMSFields();
|
||||||
@ -112,7 +112,7 @@ class BlogArchiveWidget extends Widget
|
|||||||
$posts = $posts->limit($this->NumberToDisplay);
|
$posts = $posts->limit($this->NumberToDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
$archive = new ArrayList();
|
$archive = ArrayList::create();
|
||||||
|
|
||||||
if ($posts->count() > 0) {
|
if ($posts->count() > 0) {
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
@ -132,10 +132,10 @@ class BlogArchiveWidget extends Widget
|
|||||||
$title = $date->FormatI18N("%B %Y");
|
$title = $date->FormatI18N("%B %Y");
|
||||||
}
|
}
|
||||||
|
|
||||||
$archive->push(new ArrayData(array(
|
$archive->push(ArrayData::create([
|
||||||
'Title' => $title,
|
'Title' => $title,
|
||||||
'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month)
|
'Link' => Controller::join_links($this->Blog()->Link('archive'), $year, $month)
|
||||||
)));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ use SilverStripe\Core\Convert;
|
|||||||
use SilverStripe\Forms\DropdownField;
|
use SilverStripe\Forms\DropdownField;
|
||||||
use SilverStripe\Forms\FieldList;
|
use SilverStripe\Forms\FieldList;
|
||||||
use SilverStripe\Forms\NumericField;
|
use SilverStripe\Forms\NumericField;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\Widgets\Model\Widget;
|
use SilverStripe\Widgets\Model\Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,18 +37,18 @@ class BlogCategoriesWidget extends Widget
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'Limit' => 'Int',
|
'Limit' => 'Int',
|
||||||
'Order' => 'Varchar',
|
'Order' => 'Varchar',
|
||||||
'Direction' => 'Varchar',
|
'Direction' => 'Varchar',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class,
|
'Blog' => Blog::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -57,18 +58,18 @@ class BlogCategoriesWidget extends Widget
|
|||||||
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'BlogID',
|
'BlogID',
|
||||||
_t('BlogCategoriesWidget.Blog', 'Blog'),
|
_t(__CLASS__ . '.Blog', 'Blog'),
|
||||||
Blog::get()->map()
|
Blog::get()->map()
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields[] = NumericField::create(
|
$fields[] = NumericField::create(
|
||||||
'Limit',
|
'Limit',
|
||||||
_t('BlogCategoriesWidget.Limit', 'Limit'),
|
_t(__CLASS__ . '.Limit', 'Limit'),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
_t(
|
_t(
|
||||||
'BlogCategoriesWidget.Limit_Description',
|
__CLASS__ . '.Limit_Description',
|
||||||
'Limit the number of categories shown by this widget (set to 0 to show all categories).'
|
'Limit the number of categories shown by this widget (set to 0 to show all categories).'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -76,21 +77,21 @@ class BlogCategoriesWidget extends Widget
|
|||||||
|
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'Order',
|
'Order',
|
||||||
_t('BlogCategoriesWidget.Sort', 'Sort'),
|
_t(__CLASS__ . '.Sort', 'Sort'),
|
||||||
array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated')
|
['Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated']
|
||||||
)
|
)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
_t('BlogCategoriesWidget.Sort_Description', 'Change the order of categories shown by this widget.')
|
_t(__CLASS__ . '.Sort_Description', 'Change the order of categories shown by this widget.')
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'Direction',
|
'Direction',
|
||||||
_t('BlogCategoriesWidget.Direction', 'Direction'),
|
_t(__CLASS__ . '.Direction', 'Direction'),
|
||||||
array('ASC' => 'Ascending', 'DESC' => 'Descending')
|
['ASC' => 'Ascending', 'DESC' => 'Descending']
|
||||||
)
|
)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
_t(
|
_t(
|
||||||
'BlogCategoriesWidget.Direction_Description',
|
__CLASS__ . '.Direction_Description',
|
||||||
'Change the direction of ordering of categories shown by this widget.'
|
'Change the direction of ordering of categories shown by this widget.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -107,7 +108,7 @@ class BlogCategoriesWidget extends Widget
|
|||||||
$blog = $this->Blog();
|
$blog = $this->Blog();
|
||||||
|
|
||||||
if (!$blog) {
|
if (!$blog) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $blog->Categories();
|
$query = $blog->Categories();
|
||||||
|
@ -36,16 +36,16 @@ class BlogRecentPostsWidget extends Widget
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'NumberOfPosts' => 'Int',
|
'NumberOfPosts' => 'Int',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class,
|
'Blog' => Blog::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -56,10 +56,10 @@ class BlogRecentPostsWidget extends Widget
|
|||||||
/**
|
/**
|
||||||
* @var FieldList $fields
|
* @var FieldList $fields
|
||||||
*/
|
*/
|
||||||
$fields->merge(array(
|
$fields->merge([
|
||||||
DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()),
|
DropdownField::create('BlogID', _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map()),
|
||||||
NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts'))
|
NumericField::create('NumberOfPosts', _t(__CLASS__ . '.NumberOfPosts', 'Number of Posts'))
|
||||||
));
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return parent::getCMSFields();
|
return parent::getCMSFields();
|
||||||
@ -78,6 +78,6 @@ class BlogRecentPostsWidget extends Widget
|
|||||||
->limit($this->NumberOfPosts);
|
->limit($this->NumberOfPosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,14 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array();
|
private static $db = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class,
|
'Blog' => Blog::class,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -58,7 +58,7 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
$fields->push(
|
$fields->push(
|
||||||
DropdownField::create(
|
DropdownField::create(
|
||||||
'BlogID',
|
'BlogID',
|
||||||
_t('BlogTagsCloudWidget.Blog', 'Blog'),
|
_t(__CLASS__ . '.Blog', 'Blog'),
|
||||||
Blog::get()->map()
|
Blog::get()->map()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -89,9 +89,9 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
$maxTagCount = 0;
|
$maxTagCount = 0;
|
||||||
|
|
||||||
// create DataObjects that can be used to render the tag cloud
|
// create DataObjects that can be used to render the tag cloud
|
||||||
$tags = new ArrayList();
|
$tags = ArrayList::create();
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$tag = new DataObject();
|
$tag = DataObject::create();
|
||||||
$tag->TagName = $record['Title'];
|
$tag->TagName = $record['Title'];
|
||||||
$link = $bloglink.'tag/'.$record['URLSegment'];
|
$link = $bloglink.'tag/'.$record['URLSegment'];
|
||||||
$tag->Link = $link;
|
$tag->Link = $link;
|
||||||
@ -115,6 +115,6 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,18 +36,18 @@ class BlogTagsWidget extends Widget
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
'Limit' => 'Int',
|
'Limit' => 'Int',
|
||||||
'Order' => 'Varchar',
|
'Order' => 'Varchar',
|
||||||
'Direction' => 'Varchar',
|
'Direction' => 'Varchar',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = [
|
||||||
'Blog' => Blog::class
|
'Blog' => Blog::class
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -57,18 +57,18 @@ class BlogTagsWidget extends Widget
|
|||||||
$this->beforeUpdateCMSFields(function (Fieldlist $fields) {
|
$this->beforeUpdateCMSFields(function (Fieldlist $fields) {
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'BlogID',
|
'BlogID',
|
||||||
_t('BlogTagsWidget.Blog', 'Blog'),
|
_t(__CLASS__ . '.Blog', 'Blog'),
|
||||||
Blog::get()->map()
|
Blog::get()->map()
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields[] = NumericField::create(
|
$fields[] = NumericField::create(
|
||||||
'Limit',
|
'Limit',
|
||||||
_t('BlogTagsWidget.Limit', 'Limit'),
|
_t(__CLASS__ . '.Limit', 'Limit'),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
_t(
|
_t(
|
||||||
'BlogTagsWidget.Limit_Description',
|
__CLASS__ . '.Limit_Description',
|
||||||
'Limit the number of tags shown by this widget (set to 0 to show all tags).'
|
'Limit the number of tags shown by this widget (set to 0 to show all tags).'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -76,21 +76,21 @@ class BlogTagsWidget extends Widget
|
|||||||
|
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'Order',
|
'Order',
|
||||||
_t('BlogTagsWidget.Sort', 'Sort'),
|
_t(__CLASS__ . '.Sort', 'Sort'),
|
||||||
array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated')
|
['Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated']
|
||||||
)
|
)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
_t('BlogTagsWidget.Sort_Description', 'Change the order of tags shown by this widget.')
|
_t(__CLASS__ . '.Sort_Description', 'Change the order of tags shown by this widget.')
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'Direction',
|
'Direction',
|
||||||
_t('BlogTagsWidget.Direction', 'Direction'),
|
_t(__CLASS__ . '.Direction', 'Direction'),
|
||||||
array('ASC' => 'Ascending', 'DESC' => 'Descending')
|
['ASC' => 'Ascending', 'DESC' => 'Descending']
|
||||||
)
|
)
|
||||||
->setDescription(
|
->setDescription(
|
||||||
_t(
|
_t(
|
||||||
'BlogTagsWidget.Direction_Description',
|
__CLASS__ . '.Direction_Description',
|
||||||
'Change the direction of ordering of tags shown by this widget.'
|
'Change the direction of ordering of tags shown by this widget.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -107,7 +107,7 @@ class BlogTagsWidget extends Widget
|
|||||||
$blog = $this->Blog();
|
$blog = $this->Blog();
|
||||||
|
|
||||||
if (!$blog) {
|
if (!$blog) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $blog->Tags();
|
$query = $blog->Tags();
|
||||||
|
@ -11,6 +11,7 @@ use SilverStripe\Dev\FunctionalTest;
|
|||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\ORM\ValidationException;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
@ -48,10 +49,10 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
*/
|
*/
|
||||||
public function testBlogPosts()
|
public function testBlogPosts()
|
||||||
{
|
{
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
|
|
||||||
if ($member) {
|
if ($member) {
|
||||||
$member->logout();
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
$this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
||||||
|
@ -6,6 +6,7 @@ use SilverStripe\Blog\Model\Blog;
|
|||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
@ -38,10 +39,10 @@ class BlogPostFilterTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testFilter()
|
public function testFilter()
|
||||||
{
|
{
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
|
|
||||||
if ($member) {
|
if ($member) {
|
||||||
$member->logout();
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,14 +27,14 @@ class BlogPostNotificationsTest extends SapphireTest
|
|||||||
$comment
|
$comment
|
||||||
)->toArray();
|
)->toArray();
|
||||||
|
|
||||||
$segments = array();
|
$segments = [];
|
||||||
foreach ($recipients as $recipient) {
|
foreach ($recipients as $recipient) {
|
||||||
array_push($segments, $recipient->URLSegment);
|
array_push($segments, $recipient->URLSegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
sort($segments);
|
sort($segments);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('blog-contributor', 'blog-editor', 'blog-writer'),
|
['blog-contributor', 'blog-editor', 'blog-writer'],
|
||||||
$segments
|
$segments
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -43,33 +43,33 @@ class BlogPostTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
$someFutureDate = '2013-10-10 20:00:00';
|
$someFutureDate = '2013-10-10 20:00:00';
|
||||||
$somePastDate = '2009-10-10 20:00:00';
|
$somePastDate = '2009-10-10 20:00:00';
|
||||||
return array(
|
return [
|
||||||
// Check this post given the date has passed
|
// Check this post given the date has passed
|
||||||
array($someFutureDate, 'Editor', 'PostA', true),
|
[$someFutureDate, 'Editor', 'PostA', true],
|
||||||
array($someFutureDate, 'Contributor', 'PostA', true),
|
[$someFutureDate, 'Contributor', 'PostA', true],
|
||||||
array($someFutureDate, 'BlogEditor', 'PostA', true),
|
[$someFutureDate, 'BlogEditor', 'PostA', true],
|
||||||
array($someFutureDate, 'Writer', 'PostA', true),
|
[$someFutureDate, 'Writer', 'PostA', true],
|
||||||
|
|
||||||
// Check unpublished pages
|
// Check unpublished pages
|
||||||
array($somePastDate, 'Editor', 'PostA', true),
|
[$somePastDate, 'Editor', 'PostA', true],
|
||||||
array($somePastDate, 'Contributor', 'PostA', true),
|
[$somePastDate, 'Contributor', 'PostA', true],
|
||||||
array($somePastDate, 'BlogEditor', 'PostA', true),
|
[$somePastDate, 'BlogEditor', 'PostA', true],
|
||||||
array($somePastDate, 'Writer', 'PostA', true),
|
[$somePastDate, 'Writer', 'PostA', true],
|
||||||
|
|
||||||
// Test a page that was authored by another user
|
// Test a page that was authored by another user
|
||||||
|
|
||||||
// Check this post given the date has passed
|
// Check this post given the date has passed
|
||||||
array($someFutureDate, 'Editor', 'FirstBlogPost', true),
|
[$someFutureDate, 'Editor', 'FirstBlogPost', true],
|
||||||
array($someFutureDate, 'Contributor', 'FirstBlogPost', true),
|
[$someFutureDate, 'Contributor', 'FirstBlogPost', true],
|
||||||
array($someFutureDate, 'BlogEditor', 'FirstBlogPost', true),
|
[$someFutureDate, 'BlogEditor', 'FirstBlogPost', true],
|
||||||
array($someFutureDate, 'Writer', 'FirstBlogPost', true),
|
[$someFutureDate, 'Writer', 'FirstBlogPost', true],
|
||||||
|
|
||||||
// Check future pages - non-editors shouldn't be able to see this
|
// Check future pages - non-editors shouldn't be able to see this
|
||||||
array($somePastDate, 'Editor', 'FirstBlogPost', true),
|
[$somePastDate, 'Editor', 'FirstBlogPost', true],
|
||||||
array($somePastDate, 'Contributor', 'FirstBlogPost', false),
|
[$somePastDate, 'Contributor', 'FirstBlogPost', false],
|
||||||
array($somePastDate, 'BlogEditor', 'FirstBlogPost', false),
|
[$somePastDate, 'BlogEditor', 'FirstBlogPost', false],
|
||||||
array($somePastDate, 'Writer', 'FirstBlogPost', false),
|
[$somePastDate, 'Writer', 'FirstBlogPost', false],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCandidateAuthors()
|
public function testCandidateAuthors()
|
||||||
|
@ -10,6 +10,7 @@ use SilverStripe\Dev\FunctionalTest;
|
|||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\ValidationException;
|
use SilverStripe\ORM\ValidationException;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
@ -48,10 +49,10 @@ class BlogTagTest extends FunctionalTest
|
|||||||
*/
|
*/
|
||||||
public function testBlogPosts()
|
public function testBlogPosts()
|
||||||
{
|
{
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
|
|
||||||
if ($member) {
|
if ($member) {
|
||||||
$member->logout();
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
$this->objFromFixture(BlogPost::class, 'FirstBlogPost');
|
||||||
|
@ -23,12 +23,12 @@ class BlogTagsCloudWidgetTest extends SapphireTest
|
|||||||
|
|
||||||
$widget = new BlogTagsCloudWidget();
|
$widget = new BlogTagsCloudWidget();
|
||||||
$fields = $widget->getCMSFields();
|
$fields = $widget->getCMSFields();
|
||||||
$names = array();
|
$names = [];
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
array_push($names, $field->getName());
|
array_push($names, $field->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
$expected = array('Title', 'Enabled', 'BlogID');
|
$expected = ['Title', 'Enabled', 'BlogID'];
|
||||||
$this->assertEquals($expected, $names);
|
$this->assertEquals($expected, $names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use SilverStripe\ORM\DataModel;
|
|||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\SS_List;
|
use SilverStripe\ORM\SS_List;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
@ -58,10 +59,10 @@ class BlogTest extends SapphireTest
|
|||||||
|
|
||||||
public function testGetExcludedSiteTreeClassNames()
|
public function testGetExcludedSiteTreeClassNames()
|
||||||
{
|
{
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
|
|
||||||
if ($member) {
|
if ($member) {
|
||||||
$member->logout();
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,10 +83,10 @@ class BlogTest extends SapphireTest
|
|||||||
|
|
||||||
public function testGetArchivedBlogPosts()
|
public function testGetArchivedBlogPosts()
|
||||||
{
|
{
|
||||||
$member = Member::currentUser();
|
$member = Security::getCurrentUser();
|
||||||
|
|
||||||
if ($member) {
|
if ($member) {
|
||||||
$member->logout();
|
Security::setCurrentUser(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,7 +325,7 @@ class BlogTest extends SapphireTest
|
|||||||
// Request first tag
|
// Request first tag
|
||||||
$this->requestURL($controller, 'first-post/tag/first-tag');
|
$this->requestURL($controller, 'first-post/tag/first-tag');
|
||||||
$this->assertIDsEquals(
|
$this->assertIDsEquals(
|
||||||
array($firstPostID, $firstFuturePostID, $secondFuturePostID),
|
[$firstPostID, $firstFuturePostID, $secondFuturePostID],
|
||||||
$controller->PaginatedList()
|
$controller->PaginatedList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -342,7 +343,7 @@ class BlogTest extends SapphireTest
|
|||||||
// Request 2013 posts
|
// Request 2013 posts
|
||||||
$this->requestURL($controller, 'first-post/archive/2013');
|
$this->requestURL($controller, 'first-post/archive/2013');
|
||||||
$this->assertIDsEquals(
|
$this->assertIDsEquals(
|
||||||
array($firstPostID, $secondPostID, $secondFuturePostID),
|
[$firstPostID, $secondPostID, $secondFuturePostID],
|
||||||
$controller->PaginatedList()
|
$controller->PaginatedList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user