From f5ec0036fe7fa6db1dee2ce834c56d751d680dde Mon Sep 17 00:00:00 2001 From: Cam Findlay Date: Sat, 25 Jan 2014 17:51:09 +1300 Subject: [PATCH] More 3.1 fixes for DataObjects and Forms --- code/WpImporter.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/code/WpImporter.php b/code/WpImporter.php index 483525a..a4c8766 100644 --- a/code/WpImporter.php +++ b/code/WpImporter.php @@ -51,19 +51,19 @@ protected function getBlogHolderID() { */ public function UploadForm() { - return new Form($this, "UploadForm", - new FieldList( - new FileField("XMLFile", 'Wordpress XML file'), - new HiddenField("BlogHolderID", '', $this->getBlogHolderID()) + return Form::create($this, "UploadForm", + FieldList::create( + FileField::create("XMLFile", 'Wordpress XML file'), + HiddenField::create("BlogHolderID", '', $this->getBlogHolderID()) ), - new FieldList( - new FormAction('doUpload', 'Import Wordpress XML file') + FieldList::create( + FormAction::create('doUpload', 'Import Wordpress XML file') ) ); } protected function getOrCreateComment($wordpressID) { - if ($wordpressID && $comment = DataObject::get('Comment')->filter(array('WordpressID' => $wordpressID))->first()) + if ($wordpressID && $comment = Comment::get()->filter(array('WordpressID' => $wordpressID))->first()) return $comment; return Comment::create(); @@ -84,7 +84,7 @@ protected function importComments($post, $entry) { } protected function getOrCreatePost($wordpressID) { - if ($wordpressID && $post = DataObject::get('BlogEntry')->filter(array('WordpressID' => $wordpressID))->first()) + if ($wordpressID && $post = BlogEntry::get()->filter(array('WordpressID' => $wordpressID))->first()) return $post; return BlogEntry::create(); @@ -101,8 +101,10 @@ protected function importPost($post) { $entry->update($post); $entry->write(); - if ($post['IsPublished']) + + if ($post['IsPublished']){ $entry->publish("Stage", "Live"); + } $this->importComments($post, $entry);