From ffc88888ddd140727fcd9877f8023d2cab91fc08 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Tue, 14 Jul 2015 16:09:39 +0700 Subject: [PATCH] Bugs fixes --- system/admin/views/edit-post.html.php | 8 ++++---- system/htmly.php | 11 +++++------ system/includes/functions.php | 26 ++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/system/admin/views/edit-post.html.php b/system/admin/views/edit-post.html.php index 3ec8da4..74af48a 100644 --- a/system/admin/views/edit-post.html.php +++ b/system/admin/views/edit-post.html.php @@ -81,11 +81,11 @@ $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destinat } ?>" name="content" cols="20" rows="10">
- - Delete - + + Delete + Delete - +
diff --git a/system/htmly.php b/system/htmly.php index 298f2da..e26ac64 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -255,7 +255,7 @@ post('/add/post', function () { $content = from($_REQUEST, 'content'); $description = from($_REQUEST, 'description'); $user = $_SESSION[config("site.url")]['user']; - $draft = from($_REQUEST, 'draft'); + $draft = from($_REQUEST, 'draft'); if ($proper && !empty($title) && !empty($tag) && !empty($content)) { if (!empty($url)) { add_post($title, $tag, $url, $content, $user, $description, $img, $vid, $draft); @@ -768,13 +768,12 @@ get('/tag/:tag', function ($tag) { $posts = get_tag($tag, $page, $perpage, false); - $total = get_count($tag, 'filename'); + $total = get_tagcount($tag, 'filename'); if (empty($posts) || $page < 1) { // a non-existing page not_found(); } - render('main', array( 'title' => 'Posts tagged: ' . $tag . ' - ' . blog_title(), 'description' => 'All posts tagged: ' . $tag . ' on ' . blog_title() . '.', @@ -1429,7 +1428,7 @@ get('/:year/:month/:name/edit', function ($year, $month, $name) { if (!$post) { $post = find_draft($year, $month, $name); if (!$post) { - not_found(); + not_found(); } } @@ -1477,8 +1476,8 @@ post('/:year/:month/:name/edit', function () { $date = from($_REQUEST, 'date'); $time = from($_REQUEST, 'time'); $dateTime = null; - $revertPost = from($_REQUEST, 'revertpost'); - $publishDraft = from($_REQUEST, 'publishdraft'); + $revertPost = from($_REQUEST, 'revertpost'); + $publishDraft = from($_REQUEST, 'publishdraft'); if ($date !== null && $time !== null) { $dateTime = $date . ' ' . $time; } diff --git a/system/includes/functions.php b/system/includes/functions.php index b80f27f..3bae210 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -395,7 +395,7 @@ function get_tag($tag, $page, $perpage, $random) if (empty($tmp)) { not_found(); } - + $tmp = array_unique($tmp, SORT_REGULAR); return $tmp = get_posts($tmp, $page, $perpage); @@ -669,7 +669,11 @@ function get_related($tag) break; } echo ''; + + } else { + echo ''; } + } // Return post count. Matching $var and $str provided. @@ -690,6 +694,24 @@ function get_count($var, $str) return count($tmp); } +// Return post count. Matching $var and $str provided. +function get_tagcount($var, $str) +{ + $posts = get_post_sorted(); + + $tmp = array(); + + foreach ($posts as $index => $v) { + $arr = explode('_', $v[$str]); + $url = $arr[1]; + if (strpos($url, "$var") !== false) { + $tmp[] = $v; + } + } + + return count($tmp); +} + // Return seaarch result count function keyword_count($keyword) { @@ -729,7 +751,7 @@ function recent() $str .= '
  • ' . $post->title . '
  • '; } if (empty($posts)) { - $str .= '
  • No Posts Found
  • '; + $str .= '
  • No recent posts found
  • '; } $str .= ''; return $str;