From 785f07c9079e80f8a118c158da5e0ac3b9727f5e Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Tue, 7 Jan 2014 09:09:17 +0700 Subject: [PATCH] Fix RSS bugs. Fix RSS bugs due to code changes. --- system/htmly.php | 5 +---- system/includes/functions.php | 9 +++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/system/htmly.php b/system/htmly.php index 5ba0e98..08d6c2a 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -19,10 +19,7 @@ get('/index', function () { $page = $page ? (int)$page : 1; $perpage = config('posts.perpage'); - $posts = get_posts($page); - - // Extract a specific page with results - $posts = array_slice($posts, ($page-1) * $perpage, $perpage); + $posts = get_posts($page, $perpage); $total = ''; diff --git a/system/includes/functions.php b/system/includes/functions.php index 68a0873..664266f 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -18,7 +18,7 @@ function get_post_names(){ // Get the names of all the // posts (newest first): - $_cache = array_reverse(glob('content/*/blog/*.md', GLOB_NOSORT)); + $_cache = glob('content/*/blog/*.md', GLOB_NOSORT); } return $_cache; @@ -56,6 +56,7 @@ function get_author_names(){ return $_cache; } +// usort function. Sort by date. function cmp($a, $b) { return $a->date == $b->date ? 0 : ( $a->date < $b->date ) ? 1 : -1; } @@ -115,6 +116,10 @@ function get_posts($page = 1, $perpage = 0){ } usort($tmp,'cmp'); + + // Extract a specific page with results + $tmp = array_slice($tmp, ($page-1) * $perpage, $perpage); + return $tmp; } @@ -372,7 +377,7 @@ function tag_cloud() { echo '

Tags

'; echo '';