Пример #1
0
 public function Publish()
 {
     $publishedBlogs = PostFactory::GetPublishedBlogs();
     //but only if there is at least one post in the category
     $numofblogs = sizeof($publishedBlogs);
     $post_rows = '';
     for ($x = 0; $x < $numofblogs; $x++) {
         $post_row = '<div class=row>';
         $blogPost = $publishedBlogs[$x++];
         $post_row .= Post::blog_snippet($blogPost);
         if ($x < $numofblogs) {
             $blogPost = $publishedBlogs[$x++];
             $post_row .= Post::blog_snippet($blogPost);
             if ($x < $numofblogs) {
                 $blogPost = $publishedBlogs[$x];
                 $post_row .= Post::blog_snippet($blogPost);
             }
         }
         $post_row .= '</div>' . "\n";
         $post_rows .= $post_row;
     }
     $file_contents_string = file_get_contents($this->TemplateFolder . $this->IndexTemplateName);
     $file_contents_string = str_replace('{{post_rows}}', $post_rows, $file_contents_string);
     file_put_contents($this->IndexFolder . $this->IndexFileName, $file_contents_string);
 }