mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Update BlogHolder.php
fixed whitespace back - amended DB alteration message to match split
This commit is contained in:
parent
d1ccbc583a
commit
ba28711d4b
@ -14,16 +14,16 @@
|
|||||||
class BlogHolder extends BlogTree implements PermissionProvider {
|
class BlogHolder extends BlogTree implements PermissionProvider {
|
||||||
|
|
||||||
private static $icon = "blog/images/blogholder-file.png";
|
private static $icon = "blog/images/blogholder-file.png";
|
||||||
|
|
||||||
private static $description = "Displays listings of blog entries";
|
private static $description = "Displays listings of blog entries";
|
||||||
|
|
||||||
private static $singular_name = 'Blog Holder Page';
|
private static $singular_name = 'Blog Holder Page';
|
||||||
|
|
||||||
private static $plural_name = 'Blog Holder Pages';
|
private static $plural_name = 'Blog Holder Pages';
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'AllowCustomAuthors' => 'Boolean',
|
'AllowCustomAuthors' => 'Boolean',
|
||||||
'ShowFullEntry' => 'Boolean',
|
'ShowFullEntry' => 'Boolean',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
@ -35,14 +35,14 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$blogOwners = $this->blogOwners();
|
$blogOwners = $this->blogOwners();
|
||||||
|
|
||||||
SiteTree::disableCMSFieldsExtensions();
|
SiteTree::disableCMSFieldsExtensions();
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
SiteTree::enableCMSFieldsExtensions();
|
SiteTree::enableCMSFieldsExtensions();
|
||||||
|
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
DropdownField::create('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')->toArray())
|
DropdownField::create('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')->toArray())
|
||||||
->setEmptyString('(None)')
|
->setEmptyString('(None)')
|
||||||
->setHasEmptyDefault(true),
|
->setHasEmptyDefault(true),
|
||||||
@ -50,9 +50,9 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
);
|
);
|
||||||
$fields->addFieldToTab('Root.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'), "Content");
|
$fields->addFieldToTab('Root.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'), "Content");
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
"Root.Main",
|
"Root.Main",
|
||||||
CheckboxField::create("ShowFullEntry", "Show Full Entry")
|
CheckboxField::create("ShowFullEntry", "Show Full Entry")
|
||||||
->setDescription('Show full content in overviews rather than summary'),
|
->setDescription('Show full content in overviews rather than summary'),
|
||||||
"Content"
|
"Content"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -60,18 +60,18 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get members who have BLOGMANAGEMENT and ADMIN permission
|
* Get members who have BLOGMANAGEMENT and ADMIN permission
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function blogOwners($sort = array('FirstName'=>'ASC','Surname'=>'ASC'), $direction = null) {
|
function blogOwners($sort = array('FirstName'=>'ASC','Surname'=>'ASC'), $direction = null) {
|
||||||
|
|
||||||
$members = Permission::get_members_by_permission(array('ADMIN','BLOGMANAGEMENT'));
|
$members = Permission::get_members_by_permission(array('ADMIN','BLOGMANAGEMENT'));
|
||||||
$members->sort($sort);
|
$members->sort($sort);
|
||||||
|
|
||||||
$this->extend('extendBlogOwners', $members);
|
$this->extend('extendBlogOwners', $members);
|
||||||
|
|
||||||
return $members;
|
return $members;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,11 +120,11 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
*/
|
*/
|
||||||
function requireDefaultRecords() {
|
function requireDefaultRecords() {
|
||||||
parent::requireDefaultRecords();
|
parent::requireDefaultRecords();
|
||||||
|
|
||||||
// Skip creation of default records
|
// Skip creation of default records
|
||||||
if(!self::config()->create_default_pages) return;
|
if(!self::config()->create_default_pages) return;
|
||||||
|
|
||||||
if(!BlogHolder::get()->exists()) {
|
if(!$BlogHolder::get()->exists()) {
|
||||||
$blogholder = new BlogHolder();
|
$blogholder = new BlogHolder();
|
||||||
$blogholder->Title = "Blog";
|
$blogholder->Title = "Blog";
|
||||||
$blogholder->URLSegment = "blog";
|
$blogholder->URLSegment = "blog";
|
||||||
@ -156,14 +156,15 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
$archivewidget->ParentID = $widgetarea->ID;
|
$archivewidget->ParentID = $widgetarea->ID;
|
||||||
$archivewidget->write();
|
$archivewidget->write();
|
||||||
|
|
||||||
$widgetarea->write();
|
$widgetarea->write();
|
||||||
|
|
||||||
break; // only apply to one
|
break; // only apply to one
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DB::alteration_message("Blog holder created","created");
|
||||||
}
|
}
|
||||||
if(!BlogEntry::get()->exists()) {
|
if(!$BlogEntry::get()->exists()) {
|
||||||
$blog = new BlogEntry();
|
$blog = new BlogEntry();
|
||||||
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
|
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
|
||||||
$blog->URLSegment = 'sample-blog-entry';
|
$blog->URLSegment = 'sample-blog-entry';
|
||||||
@ -174,7 +175,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
$blog->write();
|
$blog->write();
|
||||||
$blog->publish("Stage", "Live");
|
$blog->publish("Stage", "Live");
|
||||||
|
|
||||||
DB::alteration_message("Blog page created","created");
|
DB::alteration_message("Blog entry created","created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
'post',
|
'post',
|
||||||
'BlogEntryForm' => 'BLOGMANAGEMENT',
|
'BlogEntryForm' => 'BLOGMANAGEMENT',
|
||||||
);
|
);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
parent::init();
|
parent::init();
|
||||||
Requirements::themedCSS("bbcodehelp");
|
Requirements::themedCSS("bbcodehelp");
|
||||||
@ -223,9 +224,9 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
/**
|
/**
|
||||||
* A simple form for creating blog entries
|
* A simple form for creating blog entries
|
||||||
*/
|
*/
|
||||||
function BlogEntryForm() {
|
function BlogEntryForm() {
|
||||||
if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
|
if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
|
||||||
|
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
if($this->request->latestParam('ID')) {
|
if($this->request->latestParam('ID')) {
|
||||||
@ -250,7 +251,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
} else {
|
} else {
|
||||||
$tagfield = new TextField('Tags');
|
$tagfield = new TextField('Tags');
|
||||||
}
|
}
|
||||||
|
|
||||||
$field = 'TextField';
|
$field = 'TextField';
|
||||||
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
|
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
|
||||||
$field = 'ReadonlyField';
|
$field = 'ReadonlyField';
|
||||||
@ -264,7 +265,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
new LiteralField("Tagsnote"," <label id='tagsnote'>"._t('BlogHolder.TE', "For example: sport, personal, science fiction")."<br/>" .
|
new LiteralField("Tagsnote"," <label id='tagsnote'>"._t('BlogHolder.TE', "For example: sport, personal, science fiction")."<br/>" .
|
||||||
_t('BlogHolder.SPUC', "Please separate tags using commas.")."</label>")
|
_t('BlogHolder.SPUC', "Please separate tags using commas.")."</label>")
|
||||||
);
|
);
|
||||||
|
|
||||||
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
|
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
|
||||||
|
|
||||||
$actions = new FieldList($submitAction);
|
$actions = new FieldList($submitAction);
|
||||||
@ -309,7 +310,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
$blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->fieldByName('BlogPost')->dataValue());
|
$blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->fieldByName('BlogPost')->dataValue());
|
||||||
|
|
||||||
if(Object::has_extension($this->ClassName, 'Translatable')) {
|
if(Object::has_extension($this->ClassName, 'Translatable')) {
|
||||||
$blogentry->Locale = $this->Locale;
|
$blogentry->Locale = $this->Locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldMode = Versioned::get_reading_mode();
|
$oldMode = Versioned::get_reading_mode();
|
||||||
|
Loading…
Reference in New Issue
Block a user