getAllPosts() public method

public getAllPosts ( $orderBy = "desc" )
示例#1
0
/////////////////////////////////////////////////////////////////////////////////////
session_start();
// Load the require PHP classes.
require_once '../../classes/common.class.php';
require_once '../../classes/account.class.php';
require_once '../../classes/blog.class.php';
$common = new common();
$account = new account();
$blog = new blog();
// Check if the user is logged in.
if (!$account->isAuthenticated()) {
    // The user is not logged in so forward them to the login page.
    header("Location: login.php");
}
// Get titles and dates for all blog posts.
$allPosts = $blog->getAllPosts();
// Pagination.
$itemsPerPage = 10;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$posts = $common->paginateArray($allPosts, $page, $itemsPerPage - 1);
////////////////
// BEGIN HTML
require_once '../includes/header.inc.php';
?>

            <h1>Blog Management</h1>
            <hr />
            <h2>Blog Posts</h2>
            <a href="/admin/blog/add.php" class="btn btn-info" style="margin-bottom:  10px;" role="button">Add Post</a>
            <div class="table-responsive">
                <table class="table table-striped table-condensed">