Beispiel #1
0
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>';
    }
}
Beispiel #2
0
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 
    }
}