コード例 #1
0
ファイル: index.php プロジェクト: dangerdan/dropplets
 $page = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 1 ? $_GET['page'] : 1;
 $offset = $page == 1 ? 0 : ($page - 1) * $posts_per_page;
 // Index page cache file name, will be used if index_cache = "on"
 $cachefile = $settings->config("cache_dir") . ($category ? $category : "index") . $page . '.html';
 // If index cache file exists, serve it directly wihout getting all posts
 if (file_exists($cachefile) && $index_cache == 'true') {
     // Get the cached post.
     include $cachefile;
     exit;
     // If there is a file for the selected permalink, display and cache the post.
 }
 $postHelper = new PostHelper();
 if ($category) {
     $all_posts = $postHelper->get_posts_for_category($category);
 } else {
     $all_posts = $postHelper->get_all_posts();
 }
 $posts_per_page = $settings->get('posts_per_page') != "" ? $settings->get('posts_per_page') : 0;
 if ($posts_per_page > 0) {
     $pagination = $settings->get('pagination_on_off') != "off" ? get_pagination($page, round(count($all_posts) / $posts_per_page)) : "";
     define('PAGINATION', $pagination);
 }
 $posts = $settings->get('pagination_on_off') != "off" ? array_slice($all_posts, $offset, $posts_per_page > 0 ? $posts_per_page : null) : $all_posts;
 if ($posts) {
     ob_start();
     $content = '';
     foreach ($posts as $post) {
         // Get the post title.
         $post_title = str_replace(array("\n", '<h1>', '</h1>'), '', $post['post_title']);
         // Get the post author.
         $post_author = $post['post_author'];