diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index a17acd8..736c4cd 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -61,22 +61,22 @@ class BlogEntry extends Page {
SiteTree::enableCMSFieldsExtensions();
if(!self::$allow_wysiwyg_editing) {
- $fields->removeFieldFromTab("Root.Content.Main","Content");
- $fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));
+ $fields->removeFieldFromTab("Root.Main","Content");
+ $fields->addFieldToTab("Root.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));
}
- $fields->addFieldToTab("Root.Content.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
+ $fields->addFieldToTab("Root.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
$dateField->getDateField()->setConfig('showcalendar', true);
$dateField->getTimeField()->setConfig('showdropdown', true);
- $fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
+ $fields->addFieldToTab("Root.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
if(!self::$allow_wysiwyg_editing) {
- $fields->addFieldToTab("Root.Content.Main", new LiteralField("BBCodeHelper", "
" .
+ $fields->addFieldToTab("Root.Main", new LiteralField("BBCodeHelper", "
"));
}
- $fields->addFieldToTab("Root.Content.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content");
+ $fields->addFieldToTab("Root.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content");
$this->extend('updateCMSFields', $fields);
@@ -87,8 +87,8 @@ class BlogEntry extends Page {
* Returns the tags added to this blog entry
*/
function TagsCollection() {
- $tags = split(" *, *", trim($this->Tags));
- $output = new DataObjectSet();
+ $tags = preg_split(" *, *", trim($this->Tags));
+ $output = new ArrayList();
$link = $this->getParent() ? $this->getParent()->Link('tag') : '';
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 025dc17..04a74c3 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -46,19 +46,14 @@ class BlogHolder extends BlogTree implements PermissionProvider {
/**
* Get members who have BLOGMANAGEMENT and ADMIN permission
*/
- function blogOwners($sort = 'Name', $direction = "ASC") {
- $adminMembers = Permission::get_members_by_permission('ADMIN');
- $blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
+ function blogOwners($sort = array('FirstName'=>'ASC','Surname'=>'ASC'), $direction = null) {
- if(!$adminMembers) $adminMembers = new DataObjectSet();
- if(!$blogOwners) $blogOwners = new DataObjectSet();
+ $members = Permission::get_members_by_permission(array('ADMIN','BLOGMANAGEMENT'));
+ $members->sort($sort);
- $blogOwners->merge($adminMembers);
- $blogOwners->sort($sort, $direction);
+ $this->extend('extendBlogOwners', $members);
- $this->extend('extendBlogOwners', $blogOwners);
-
- return $blogOwners;
+ return $members;
}
public function BlogHolderIDs() {
@@ -204,7 +199,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$codeparser = new BBCodeParser();
- $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
+ $membername = Member::currentUser() ? Member::currentUser()->getName() : "";
if(BlogEntry::$allow_wysiwyg_editing) {
$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
@@ -226,7 +221,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
$field = 'ReadonlyField';
}
- $fields = new FieldSet(
+ $fields = new FieldList(
new HiddenField("ID", "ID"),
new TextField("Title", _t('BlogHolder.SJ', "Subject")),
new $field("Author", _t('BlogEntry.AU'), $membername),
@@ -237,7 +232,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
);
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
- $actions = new FieldSet($submitAction);
+ $actions = new FieldList($submitAction);
$validator = new RequiredFields('Title','BlogPost');
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
@@ -274,7 +269,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
$form->saveInto($blogentry);
$blogentry->ParentID = $this->ID;
- $blogentry->Content = str_replace("\r\n", "\n", $form->datafieldByName('BlogPost')->dataValue());
+
+ $blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->fieldByName('BlogPost')->dataValue());
if(Object::has_extension($this->ClassName, 'Translatable')) {
$blogentry->Locale = $this->Locale;
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 5356fd9..5d9e05c 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -2,40 +2,45 @@
/**
* Add trackback (receive and send) feature blog entry
*/
-class TrackBackDecorator extends DataObjectDecorator {
+class TrackBackDecorator extends DataExtension {
static $trackback_server_class = 'TrackbackHTTPServer';
- function extraStatics() {
- return array(
- 'has_many' => array(
- 'TrackBackURLs' => 'TrackBackURL',
- 'TrackBacks' => 'TrackBackPing'
- )
- );
- }
+ // function extraStatics() {
+ // return array(
+ // 'has_many' => array(
+ // 'TrackBackURLs' => 'TrackBackURL',
+ // 'TrackBacks' => 'TrackBackPing'
+ // )
+ // );
+ // }
+
+ static $has_many = array(
+ 'TrackBackURLs' => 'TrackBackURL',
+ 'TrackBacks' => 'TrackBackPing'
+ );
- function updateCMSFields($fields) {
- // Trackback URL field
- if($this->owner->TrackBacksEnabled()) {
- $trackbackURLTable = new ComplexTableField(
- $this,
- 'TrackBackURLs',
- 'TrackBackURL',
- array(
- 'URL' => 'URL',
- 'IsPung' => 'Pung?'
- ),
- 'getCMSFields_forPopup',
- '',
- 'ID'
- );
- $fields->addFieldToTab("Root.Content.Main", $trackbackURLTable);
- }
- else {
- $fields->addFieldToTab("Root.Content.Main", new ReadonlyField("TrackBackURLsReadOnly", _t("BlogEntry.TrackbackURLs", "Trackback URLs"), _t("BlogEntry.TrackbackURLs_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")));
- }
- }
+ // function updateCMSFields($fields) {
+ // // Trackback URL field
+ // if($this->owner->TrackBacksEnabled()) {
+ // $trackbackURLTable = new ComplexTableField(
+ // $this,
+ // 'TrackBackURLs',
+ // 'TrackBackURL',
+ // array(
+ // 'URL' => 'URL',
+ // 'IsPung' => 'Pung?'
+ // ),
+ // 'getCMSFields_forPopup',
+ // '',
+ // 'ID'
+ // );
+ // $fields->addFieldToTab("Root.Content.Main", $trackbackURLTable);
+ // }
+ // else {
+ // $fields->addFieldToTab("Root.Content.Main", new ReadonlyField("TrackBackURLsReadOnly", _t("BlogEntry.TrackbackURLs", "Trackback URLs"), _t("BlogEntry.TrackbackURLs_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")));
+ // }
+ // }
function onBeforePublish() {
if(!$this->owner->TrackBacksEnabled() && !$this->owner->TrackBackURLs()) return;
diff --git a/code/TrackBackURL.php b/code/TrackBackURL.php
index 7cf0903..951ae78 100644
--- a/code/TrackBackURL.php
+++ b/code/TrackBackURL.php
@@ -11,7 +11,7 @@ class TrackBackURL extends DataObject {
);
function getCMSFields_forPopup() {
- return new FieldSet(
+ return new FieldList(
new TextField('URL'),
new ReadonlyField('Pung', 'Pung?')
);
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index 77b2c7b..c98a177 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -32,7 +32,7 @@ class ArchiveWidget extends Widget {
$fields = parent::getCMSFields();
$fields->merge(
- new FieldSet(
+ new FieldList(
new OptionsetField(
'DisplayMode',
_t('ArchiveWidget.DispBY', 'Display by'),
diff --git a/code/widgets/BlogManagementWidget.php b/code/widgets/BlogManagementWidget.php
index 964d7bc..da31435 100644
--- a/code/widgets/BlogManagementWidget.php
+++ b/code/widgets/BlogManagementWidget.php
@@ -21,6 +21,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
function CommentText() {
+ if(!class_exists('Comment')) return false;
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
if($unmoderatedcount == 1) {
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
@@ -32,7 +33,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
}
function CommentLink() {
- if(!Permission::check('BLOGMANAGEMENT')) {
+ if(!Permission::check('BLOGMANAGEMENT') || !class_exists('Comment')) {
return false;
}
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
diff --git a/code/widgets/RSSWidget.php b/code/widgets/RSSWidget.php
index 17f8bc9..b6bfa65 100644
--- a/code/widgets/RSSWidget.php
+++ b/code/widgets/RSSWidget.php
@@ -43,7 +43,7 @@ class RSSWidget extends Widget {
$fields = parent::getCMSFields();
$fields->merge(
- new FieldSet(
+ new FieldList(
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")),
new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show"))
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index ed1bbe0..4832b1f 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -30,7 +30,7 @@ class TagCloudWidget extends Widget {
$fields = parent::getCMSFields();
$fields->merge(
- new FieldSet(
+ new FieldList(
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")),
new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency")))
@@ -57,7 +57,7 @@ class TagCloudWidget extends Widget {
if($entries) {
foreach($entries as $entry) {
- $theseTags = split(" *, *", mb_strtolower(trim($entry->Tags)));
+ $theseTags = preg_split(" *, *", mb_strtolower(trim($entry->Tags)));
foreach($theseTags as $tag) {
if($tag != "") {
$allTags[$tag] = isset($allTags[$tag]) ? $allTags[$tag] + 1 : 1; //getting the count into key => value map
@@ -105,7 +105,7 @@ class TagCloudWidget extends Widget {
}
}
- $output = new DataObjectSet();
+ $output = new ArrayList();
foreach($allTags as $tag => $fields) {
$output->push(new ArrayData($fields));
}
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index 2367074..e4a7f1d 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -46,6 +46,6 @@ class BlogHolderFunctionalTest extends FunctionalTest {
);
$response = $this->post('blog/BlogEntryForm', $data);
- $this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
+ $this->assertInstanceOf('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
}
}
diff --git a/tests/BlogHolderTest.php b/tests/BlogHolderTest.php
index 05938a6..3c2eee7 100644
--- a/tests/BlogHolderTest.php
+++ b/tests/BlogHolderTest.php
@@ -56,11 +56,12 @@ class BlogHolderTest extends SapphireTest {
function testBlogOwners() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
- $actualMembers = array_values($mainblog->blogOwners()->toDropDownMap('ID', 'Name'));
+
+ $actualMembers = array_values($mainblog->blogOwners()->map('ID', 'Name')->toArray());
$expectedMembers = array(
- 'ADMIN User', // test default admin
'Admin One',
'Admin Two',
+ 'ADMIN User', // test default admin
'Blog Owner One',
'Blog Owner Three',
'Blog Owner Two',
diff --git a/tests/BlogTrackbackTest.php b/tests/BlogTrackbackTest.php
index cf9550e..274707c 100644
--- a/tests/BlogTrackbackTest.php
+++ b/tests/BlogTrackbackTest.php
@@ -60,12 +60,13 @@ class BlogTrackbackTest extends SapphireTest {
$entry1 = $this->objFromFixture('BlogEntry', 'testpost');
$entry1->doPublish();
$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->doPublish();
$this->assertEquals(4, $entry2->TrackBackURLs()->Count());
- $this->assertEquals(array('testBadTrackbackURL' => 0, 'testGoodTrackbackURL2' => 1, 'noneExistingURL' => 0, 'testGoodTrackbackURL3' => 1), $entry2->TrackBackURLs()->map('URL', 'Pung'));
+ $this->assertEquals(array('testBadTrackbackURL' => 0, 'testGoodTrackbackURL2' => 1, 'noneExistingURL' => 0, 'testGoodTrackbackURL3' => 1), $entry2->TrackBackURLs()->map('URL', 'Pung')->toArray());
TrackBackDecorator::$trackback_server_class = $tmpServerClass;
}
diff --git a/tests/BlogTreeTest.php b/tests/BlogTreeTest.php
index cdf1485..7ba88a5 100644
--- a/tests/BlogTreeTest.php
+++ b/tests/BlogTreeTest.php
@@ -14,7 +14,7 @@ class BlogTreeTest extends SapphireTest {
$this->assertEquals($node->Entries()->Count(), 2);
$node = $this->objFromFixture('BlogTree', 'levelab');
- $this->assertNull($node->Entries());
+ $this->assertEquals($node->Entries()->Count(), 0); // this is not null anymore, it returns a DataList with no elements
$node = $this->objFromFixture('BlogTree', 'levelb');
$this->assertEquals($node->Entries()->Count(), 1);
@@ -22,7 +22,7 @@ class BlogTreeTest extends SapphireTest {
$node = $this->objFromFixture('BlogTree', 'levelba');
$this->assertEquals($node->Entries()->Count(), 1);
- $this->assertTrue($node->getCMSFields() instanceof FieldSet);
+ $this->assertTrue($node->getCMSFields() instanceof FieldList);
}
function testEntriesByMonth() {