function show_posts_page($index = 0) { global $blogSettings; $Blog = new Blog(); $posts = $Blog->listPosts(true, true); if ($blogSettings["allpostsadtop"] == 'Y') { ?> <div class="blog_all_posts_ad"> <?php echo $blogSettings["addata"]; ?> </div> <?php } if (!empty($posts)) { $pages = array_chunk($posts, intval($blogSettings["postperpage"]), TRUE); if (is_numeric($index) && $index >= 0 && $index < sizeof($pages)) { $posts = $pages[$index]; } else { $posts = array(); } $count = 0; $lastPostOfPage = false; foreach ($posts as $file) { $count++; show_blog_post($file['filename'], true); if ($count == sizeof($posts) && sizeof($posts) > 0) { $lastPostOfPage = true; } if (sizeof($pages) > 1) { // We know here that we have more than one page. $maxPageIndex = sizeof($pages) - 1; show_blog_navigation($index, $maxPageIndex, $count, $lastPostOfPage); if ($count == $blogSettings["postperpage"]) { $count = 0; } } } } else { echo '<p>' . i18n(BLOGFILE . '/NO_POSTS') . '</p>'; } if ($blogSettings["allpostsadbottom"] == 'Y') { ?> <div class="blog_all_posts_ad"> <?php echo $blogSettings["addata"]; ?> </div> <?php } }
function show_posts_page($index = 0) { global $blogSettings; // Declare GLOBAL variables $Blog = new Blog(); // Create a new instance of the Blog class $posts = $Blog->listPosts(true, true); // Get the list of posts. if (!empty($posts)) { // If we have posts to display... $pages = array_chunk($posts, intval($blogSettings["postperpage"]), TRUE); // Split posts onto multiple pages if (is_numeric($index) && $index >= 0 && $index < sizeof($pages)) { // What page should we show? $posts = $pages[$index]; // Show specified page number } else { // Page index not given or 0 $posts = array(); // Show first page } $count = 0; // Create a counter for X $lastPostOfPage = false; // We're not on the last post of the page yet foreach ($posts as $file) { // For each post on the page... $count++; // Increment the counter show_blog_post($file['filename'], true); // Show the blog post if ($count == sizeof($posts) && sizeof($posts) > 0) { // Is this the last post on the page? $lastPostOfPage = true; // Yes, it is. } if (sizeof($pages) > 1) { // If there is more than one page... $maxPageIndex = sizeof($pages) - 1; // Total number of pages show_blog_navigation($index, $maxPageIndex, $count, $lastPostOfPage); // Show the pagination if ($count == $blogSettings["postperpage"]) { // If we are on the last post, $count = 0; // Reset the counter for the next page } } } } else { // We have no posts to display. Let the user know. echo '<p>' . i18n(BLOGFILE . '/NO_POSTS') . '</p>'; } }
/** * Conditionals to display posts/search/archive/tags/category/importer on front end of website * * @return void */ function blog_display_posts() { global $content, $blogSettings; $Blog = new Blog(); $slug = base64_encode(return_page_slug()); $blogSettings = $Blog->getSettingsData(); $blog_slug = base64_encode($blogSettings["blogurl"]); if ($slug == $blog_slug) { $content = ''; ob_start(); if ($blogSettings["displaycss"] == 'Y') { echo "<style>\n"; echo $blogSettings["csscode"]; echo "\n</style>"; } switch (true) { case isset($_GET['post']) == true: $post_file = BLOGPOSTSFOLDER . $_GET['post'] . '.xml'; show_blog_post($post_file); break; case isset($_POST['search_blog']) == true: search_posts($_POST['keyphrase']); break; case isset($_GET['archive']) == true: $archive = $_GET['archive']; show_blog_archive($archive); break; case isset($_GET['tag']) == true: $tag = $_GET['tag']; show_blog_tag($tag); break; case isset($_GET['category']) == true: $category = $_GET['category']; show_blog_category($category); break; case isset($_GET['import']): auto_import(); break; default: show_all_blog_posts(); break; } $content = ob_get_contents(); ob_end_clean(); } return $content; // legacy support for non filter hook calls to this function }