Skip to content

Commit

Permalink
More 3.1 fixes for DataObjects and Forms
Browse files Browse the repository at this point in the history
  • Loading branch information
camfindlay committed Jan 25, 2014
1 parent e790a06 commit f5ec003
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions code/WpImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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);

Expand Down

0 comments on commit f5ec003

Please sign in to comment.