mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUGFIX Initial fixes to support at least building the blog module on SS3
This commit is contained in:
parent
b91fdd0443
commit
8b58156211
@ -49,7 +49,7 @@ class BlogEntry extends Page {
|
|||||||
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
|
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
||||||
Requirements::themedCSS('bbcodehelp');
|
Requirements::themedCSS('bbcodehelp');
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class BlogEntry extends Page {
|
|||||||
$codeparser = new BBCodeParser();
|
$codeparser = new BBCodeParser();
|
||||||
|
|
||||||
SiteTree::disableCMSFieldsExtensions();
|
SiteTree::disableCMSFieldsExtensions();
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
SiteTree::enableCMSFieldsExtensions();
|
SiteTree::enableCMSFieldsExtensions();
|
||||||
|
|
||||||
if(!self::$allow_wysiwyg_editing) {
|
if(!self::$allow_wysiwyg_editing) {
|
||||||
@ -87,8 +87,8 @@ class BlogEntry extends Page {
|
|||||||
* Returns the tags added to this blog entry
|
* Returns the tags added to this blog entry
|
||||||
*/
|
*/
|
||||||
function TagsCollection() {
|
function TagsCollection() {
|
||||||
$tags = split(" *, *", trim($this->Tags));
|
$tags = preg_split('/ *, */', trim($this->Tags));
|
||||||
$output = new DataObjectSet();
|
$output = new ArrayList();
|
||||||
|
|
||||||
$link = $this->getParent() ? $this->getParent()->Link('tag') : '';
|
$link = $this->getParent() ? $this->getParent()->Link('tag') : '';
|
||||||
|
|
||||||
@ -270,7 +270,6 @@ class BlogEntry_Controller extends Page_Controller {
|
|||||||
*/
|
*/
|
||||||
function PageComments() {
|
function PageComments() {
|
||||||
if($this->hasMethod('CommentsForm')) return $this->CommentsForm();
|
if($this->hasMethod('CommentsForm')) return $this->CommentsForm();
|
||||||
else return parent::PageComments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,15 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
'BlogEntry'
|
'BlogEntry'
|
||||||
);
|
);
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$blogOwners = $this->blogOwners();
|
$blogOwners = $this->blogOwners();
|
||||||
|
|
||||||
SiteTree::disableCMSFieldsExtensions();
|
SiteTree::disableCMSFieldsExtensions();
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
SiteTree::enableCMSFieldsExtensions();
|
SiteTree::enableCMSFieldsExtensions();
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
|
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
|
||||||
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->toDropDownMap('ID', 'Name', 'None')));
|
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')));
|
||||||
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
|
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
|
||||||
|
|
||||||
$this->extend('updateCMSFields', $fields);
|
$this->extend('updateCMSFields', $fields);
|
||||||
@ -50,8 +50,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||||||
$adminMembers = Permission::get_members_by_permission('ADMIN');
|
$adminMembers = Permission::get_members_by_permission('ADMIN');
|
||||||
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
|
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
|
||||||
|
|
||||||
if(!$adminMembers) $adminMembers = new DataObjectSet();
|
if(!$adminMembers) $adminMembers = new ArrayList();
|
||||||
if(!$blogOwners) $blogOwners = new DataObjectSet();
|
if(!$blogOwners) $blogOwners = new ArrayList();
|
||||||
|
|
||||||
$blogOwners->merge($adminMembers);
|
$blogOwners->merge($adminMembers);
|
||||||
$blogOwners->sort($sort, $direction);
|
$blogOwners->sort($sort, $direction);
|
||||||
@ -204,7 +204,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$codeparser = new BBCodeParser();
|
$codeparser = new BBCodeParser();
|
||||||
$membername = Member::currentMember() ? Member::currentMember()->getName() : "";
|
$membername = Member::currentUser() ? Member::currentUser()->getName() : "";
|
||||||
|
|
||||||
if(BlogEntry::$allow_wysiwyg_editing) {
|
if(BlogEntry::$allow_wysiwyg_editing) {
|
||||||
$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
|
$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
|
||||||
@ -226,7 +226,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
|
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
|
||||||
$field = 'ReadonlyField';
|
$field = 'ReadonlyField';
|
||||||
}
|
}
|
||||||
$fields = new FieldSet(
|
$fields = new FieldList(
|
||||||
new HiddenField("ID", "ID"),
|
new HiddenField("ID", "ID"),
|
||||||
new TextField("Title", _t('BlogHolder.SJ', "Subject")),
|
new TextField("Title", _t('BlogHolder.SJ', "Subject")),
|
||||||
new $field("Author", _t('BlogEntry.AU'), $membername),
|
new $field("Author", _t('BlogEntry.AU'), $membername),
|
||||||
@ -237,7 +237,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
|
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
|
||||||
$actions = new FieldSet($submitAction);
|
$actions = new FieldList($submitAction);
|
||||||
$validator = new RequiredFields('Title','BlogPost');
|
$validator = new RequiredFields('Title','BlogPost');
|
||||||
|
|
||||||
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
|
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
|
||||||
@ -246,7 +246,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
$entry = DataObject::get_by_id('BlogEntry', $id);
|
$entry = DataObject::get_by_id('BlogEntry', $id);
|
||||||
if($entry->IsOwner()) {
|
if($entry->IsOwner()) {
|
||||||
$form->loadDataFrom($entry);
|
$form->loadDataFrom($entry);
|
||||||
$form->datafieldByName('BlogPost')->setValue($entry->Content);
|
$form->Fields()->dataFieldByName('BlogPost')->setValue($entry->Content);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
|
$form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
|
||||||
@ -274,7 +274,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
|
|
||||||
$form->saveInto($blogentry);
|
$form->saveInto($blogentry);
|
||||||
$blogentry->ParentID = $this->ID;
|
$blogentry->ParentID = $this->ID;
|
||||||
$blogentry->Content = str_replace("\r\n", "\n", $form->datafieldByName('BlogPost')->dataValue());
|
$blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->dataFieldByName('BlogPost')->dataValue());
|
||||||
|
|
||||||
if(Object::has_extension($this->ClassName, 'Translatable')) {
|
if(Object::has_extension($this->ClassName, 'Translatable')) {
|
||||||
$blogentry->Locale = $this->Locale;
|
$blogentry->Locale = $this->Locale;
|
||||||
@ -288,5 +288,3 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -93,8 +93,8 @@ class BlogTree extends Page {
|
|||||||
|
|
||||||
/* ----------- CMS CONTROL -------------- */
|
/* ----------- CMS CONTROL -------------- */
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
$fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
|
$fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
|
||||||
$fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
|
$fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
|
||||||
"" => "All entries",
|
"" => "All entries",
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
/**
|
/**
|
||||||
* Add trackback (receive and send) feature blog entry
|
* Add trackback (receive and send) feature blog entry
|
||||||
*/
|
*/
|
||||||
class TrackBackDecorator extends DataObjectDecorator {
|
class TrackBackDecorator extends DataExtension {
|
||||||
|
|
||||||
static $trackback_server_class = 'TrackbackHTTPServer';
|
static $trackback_server_class = 'TrackbackHTTPServer';
|
||||||
|
|
||||||
function extraStatics() {
|
function extraStatics($class = null, $extension = null) {
|
||||||
return array(
|
return array(
|
||||||
'has_many' => array(
|
'has_many' => array(
|
||||||
'TrackBackURLs' => 'TrackBackURL',
|
'TrackBackURLs' => 'TrackBackURL',
|
||||||
@ -15,7 +15,7 @@ class TrackBackDecorator extends DataObjectDecorator {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCMSFields($fields) {
|
function updateCMSFields(FieldList $fields) {
|
||||||
// Trackback URL field
|
// Trackback URL field
|
||||||
if($this->owner->TrackBacksEnabled()) {
|
if($this->owner->TrackBacksEnabled()) {
|
||||||
$trackbackURLTable = new ComplexTableField(
|
$trackbackURLTable = new ComplexTableField(
|
||||||
|
@ -28,8 +28,8 @@ class ArchiveWidget extends Widget {
|
|||||||
|
|
||||||
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
|
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
|
|
||||||
$fields->merge(
|
$fields->merge(
|
||||||
new FieldSet(
|
new FieldSet(
|
||||||
|
@ -39,8 +39,8 @@ class RSSWidget extends Widget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
|
|
||||||
$fields->merge(
|
$fields->merge(
|
||||||
new FieldSet(
|
new FieldSet(
|
||||||
|
@ -26,8 +26,8 @@ class TagCloudWidget extends Widget {
|
|||||||
|
|
||||||
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
|
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields($params = null) {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields($params);
|
||||||
|
|
||||||
$fields->merge(
|
$fields->merge(
|
||||||
new FieldSet(
|
new FieldSet(
|
||||||
|
@ -60,7 +60,7 @@ class BlogTrackbackTest extends SapphireTest {
|
|||||||
$entry1 = $this->objFromFixture('BlogEntry', 'testpost');
|
$entry1 = $this->objFromFixture('BlogEntry', 'testpost');
|
||||||
$entry1->doPublish();
|
$entry1->doPublish();
|
||||||
$this->assertEquals(2, $entry1->TrackBackURLs()->Count());
|
$this->assertEquals(2, $entry1->TrackBackURLs()->Count());
|
||||||
$this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung'));
|
$this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung')->toArray());
|
||||||
|
|
||||||
$entry2 = $this->objFromFixture('BlogEntry', 'testpost2');
|
$entry2 = $this->objFromFixture('BlogEntry', 'testpost2');
|
||||||
$entry2->doPublish();
|
$entry2->doPublish();
|
||||||
|
Loading…
Reference in New Issue
Block a user