protected function getOrCreatePost($wordpressID) { if ($wordpressID && ($post = BlogEntry::get()->filter(array('WordpressID' => $wordpressID))->first())) { return $post; } return BlogEntry::create(); }
public function processform(SS_HTTPRequest $r) { $entry = BlogEntry::create(); if ($this->request->postVar('Title') != null) { $entry->Title = $this->request->postVar('Title'); $entry->Content = $this->request->postVar('Content'); $entry->Tags = $this->request->postVar('Tags'); $entry->Date = $this->request->postVar('Date'); $entry->ParentID = $this->request->postVar('ParentID'); $entry->write(); $entry->publish('Stage', 'Live'); $response = new SS_HTTPResponse(_t('Dashboard.Success', 'Successfully Published'), '200'); $response->setStatusCode(200, _t('Dashboard.Posted', 'Blog Post Published')); return $response; } else { user_error('Blog Title and Content must be present', E_USER_ERROR); } }