From 452cf9212d155948cf4704c0a2fbb78b6f29ecde Mon Sep 17 00:00:00 2001 From: Kanti Date: Thu, 31 Jul 2014 16:45:20 +0200 Subject: [PATCH] Added views.counter in the Config File --- config/config.ini.example | 3 +++ system/admin/admin.php | 12 +++++++---- system/admin/views/posts-list.html.php | 4 ++-- system/htmly.php | 39 ++++++++++++++++++++++++++-------- system/includes/functions.php | 12 ++++++++--- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/config/config.ini.example b/config/config.ini.example index 41edb78..ccef248 100644 --- a/config/config.ini.example +++ b/config/config.ini.example @@ -80,5 +80,8 @@ lightbox = "off" ; Set the theme here views.root = "themes/logs" + ;Enable view Counter, the options is "true" and "false". If set to "true", you can see the Counts in Admin page. +views.counter = "true" + ; Framework config. No need to edit. views.layout = "layout" \ No newline at end of file diff --git a/system/admin/admin.php b/system/admin/admin.php index 12f4ac1..35777c6 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -347,7 +347,9 @@ function get_recent_posts() { $posts = get_profile($_SESSION[config("site.url")]['user'], 1, 5); if(!empty($posts)) { echo ''; - echo ''; + echo ''; + if(config("views.counter") == "true") echo ''; + echo ''; $i = 0; $len = count($posts); foreach($posts as $p) { if ($i == 0) { @@ -363,7 +365,7 @@ function get_recent_posts() { echo ''; echo ''; echo ''; - echo ''; + if(config("views.counter") == "true") echo ''; echo ''; echo ''; echo ''; @@ -380,7 +382,9 @@ function get_recent_pages() { if(!empty($posts)) { krsort($posts); echo '
TitlePublishedViewsTagOperations
TitlePublishedViewsTagOperations
' . $p->title . '' . date('d F Y', $p->date) . '' . $p->views . '' . $p->views . '' . $p->tag . 'Edit Delete
'; - echo ''; + echo ''; + if(config("views.counter") == "true") echo ''; + echo ''; $i = 0; $len = count($posts); foreach($posts as $p) { if ($i == 0) { @@ -395,7 +399,7 @@ function get_recent_pages() { $i++; echo ''; echo ''; - echo ''; + if(config("views.counter") == "true") echo ''; echo ''; echo ''; } diff --git a/system/admin/views/posts-list.html.php b/system/admin/views/posts-list.html.php index b3bbc93..9457c3e 100644 --- a/system/admin/views/posts-list.html.php +++ b/system/admin/views/posts-list.html.php @@ -1,7 +1,7 @@

TitleViewsOperations
TitleViewsOperations
' . $p->title . '' . $p->views . '' . $p->views . 'Edit Delete
- + "> - + diff --git a/system/htmly.php b/system/htmly.php index dc41f02..0fd5586 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -111,19 +111,30 @@ post('/login', function() { // The blog post page get('/:year/:month/:name', function($year, $month, $name) { + if(config("views.counter") != "true") + { + if (!login()) { + file_cache($_SERVER['REQUEST_URI']); + } + } $post = find_post($year, $month, $name); $current = $post['current']; - add_view($current->file); - - if (!login()) { - file_cache($_SERVER['REQUEST_URI']); - } if (!$current) { not_found(); } + + if(config("views.counter") == "true") + { + add_view($current->file); + + if (!login()) { + file_cache($_SERVER['REQUEST_URI']); + } + } + $bio = get_bio($current->author); @@ -567,6 +578,14 @@ get('/:static', function($static) { } die; } else { + + if( config("views.counter") != "true") + { + if (!login()) { + file_cache($_SERVER['REQUEST_URI']); + } + } + $post = get_static_post($static); if (!$post) { @@ -574,11 +593,13 @@ get('/:static', function($static) { } $post = $post[0]; - - add_view($post->file); - if (!login()) { - file_cache($_SERVER['REQUEST_URI']); + if(config("views.counter") == "true") + { + add_view($post->file); + if (!login()) { + file_cache($_SERVER['REQUEST_URI']); + } } render('static', array( diff --git a/system/includes/functions.php b/system/includes/functions.php index ae46284..716c6e6 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -223,7 +223,10 @@ function get_posts($posts, $page = 1, $perpage = 0) { $post->body = $arr[0]; } - $post->views = get_views($post->file); + if(config("views.counter")) + { + $post->views = get_views($post->file); + } $tmp[] = $post; } @@ -457,8 +460,11 @@ function get_static_post($static) { $post->body = $arr[0]; } - $post->views = get_views($post->file); - + if(config("views.counter")) + { + $post->views = get_views($post->file); + } + $tmp[] = $post; } }
TitlePublishedViewsAuthorTagOperations
TitlePublishedViewsAuthorTagOperations
title ?> date) ?>views ?>views ?> author ?> tag ?> Edit Delete