Example #1
0
 public function Publish()
 {
     $file_contents_string = file_get_contents($this->TemplateFolder . $this->TemplateName);
     $file_contents_string = str_replace("<blog-post-title>", $this->Title, $file_contents_string);
     $file_contents_string = str_replace("<blog-post-post>", $this->Blog, $file_contents_string);
     //create the category folder if it doesn't exist
     //so this check is always required - probably not very expensive tho
     //later when we have a manage category UI, where we can create categories, we probably won't need this
     if (!isset($this->SubTitle)) {
         $this->SubTitle = substr(strip_tags($this->Blog), 0, 50);
     }
     Post::setpagename($this);
     $category_dropdown = Category::getcategorydropdown();
     $file_contents_string = str_replace('<category-dropdown>', $category_dropdown, $file_contents_string);
     $file_contents_string = str_replace('<post_id>', $this->ID, $file_contents_string);
     file_put_contents($this->PostFolder . $this->PageName, $file_contents_string);
     //finally set the publish date back to now
     $this->PublishDate = 'now()';
     $this->ReadyForPublish = FALSE;
     $this->Save();
 }