Browse Source

Added views.counter in the Config File

pull/69/head
Kanti 11 years ago
parent
commit
452cf9212d
5 changed files with 52 additions and 18 deletions
  1. +3
    -0
      config/config.ini.example
  2. +8
    -4
      system/admin/admin.php
  3. +2
    -2
      system/admin/views/posts-list.html.php
  4. +30
    -9
      system/htmly.php
  5. +9
    -3
      system/includes/functions.php

+ 3
- 0
config/config.ini.example View File

@ -80,5 +80,8 @@ lightbox = "off"
; Set the theme here ; Set the theme here
views.root = "themes/logs" 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. ; Framework config. No need to edit.
views.layout = "layout" views.layout = "layout"

+ 8
- 4
system/admin/admin.php View File

@ -347,7 +347,9 @@ function get_recent_posts() {
$posts = get_profile($_SESSION[config("site.url")]['user'], 1, 5); $posts = get_profile($_SESSION[config("site.url")]['user'], 1, 5);
if(!empty($posts)) { if(!empty($posts)) {
echo '<table class="post-list">'; echo '<table class="post-list">';
echo '<tr class="head"><th>Title</th><th>Published</th><th>Views</th><th>Tag</th><th>Operations</th></tr>';
echo '<tr class="head"><th>Title</th><th>Published</th>';
if(config("views.counter") == "true") echo '<th>Views</th>';
echo '<th>Tag</th><th>Operations</th></tr>';
$i = 0; $len = count($posts); $i = 0; $len = count($posts);
foreach($posts as $p) { foreach($posts as $p) {
if ($i == 0) { if ($i == 0) {
@ -363,7 +365,7 @@ function get_recent_posts() {
echo '<tr class="' . $class . '">'; echo '<tr class="' . $class . '">';
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>'; echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
echo '<td>' . date('d F Y', $p->date) . '</td>'; echo '<td>' . date('d F Y', $p->date) . '</td>';
echo '<td>' . $p->views . '</td>';
if(config("views.counter") == "true") echo '<td>' . $p->views . '</td>';
echo '<td>' . $p->tag . '</td>'; echo '<td>' . $p->tag . '</td>';
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>'; echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>'; echo '</tr>';
@ -380,7 +382,9 @@ function get_recent_pages() {
if(!empty($posts)) { if(!empty($posts)) {
krsort($posts); krsort($posts);
echo '<table class="post-list">'; echo '<table class="post-list">';
echo '<tr class="head"><th>Title</th><th>Views</th><th>Operations</th></tr>';
echo '<tr class="head"><th>Title</th>';
if(config("views.counter") == "true") echo '<th>Views</th>';
echo '<th>Operations</th></tr>';
$i = 0; $len = count($posts); $i = 0; $len = count($posts);
foreach($posts as $p) { foreach($posts as $p) {
if ($i == 0) { if ($i == 0) {
@ -395,7 +399,7 @@ function get_recent_pages() {
$i++; $i++;
echo '<tr class="' . $class . '">'; echo '<tr class="' . $class . '">';
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>'; echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
echo '<td>' . $p->views . '</td>';
if(config("views.counter") == "true") echo '<td>' . $p->views . '</td>';
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>'; echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>'; echo '</tr>';
} }


+ 2
- 2
system/admin/views/posts-list.html.php View File

@ -1,7 +1,7 @@
<h2 class="post-index"><?php echo $heading?></h2> <h2 class="post-index"><?php echo $heading?></h2>
<?php if(!empty($posts)) {?> <?php if(!empty($posts)) {?>
<table class="post-list"> <table class="post-list">
<tr class="head"><th>Title</th><th>Published</th><th>Views</th><th>Author</th><th>Tag</th><th>Operations</th></tr>
<tr class="head"><th>Title</th><th>Published</th><?php if(config("views.counter") == "true"):?><th>Views</th><?php endif;?><th>Author</th><th>Tag</th><th>Operations</th></tr>
<?php $i = 0; $len = count($posts);?> <?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?> <?php foreach($posts as $p):?>
<?php <?php
@ -19,7 +19,7 @@
<tr class="<?php echo $class ?>"> <tr class="<?php echo $class ?>">
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td> <td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
<td><?php echo date('d F Y', $p->date) ?></td> <td><?php echo date('d F Y', $p->date) ?></td>
<td><?php echo $p->views ?></td>
<?php if(config("views.counter") == "true"):?><td><?php echo $p->views ?></td><?php endif;?>
<td><a target="_blank" href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></td> <td><a target="_blank" href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></td>
<td><?php echo $p->tag ?></td> <td><?php echo $p->tag ?></td>
<td><a href="<?php echo $p->url ?>/edit?destination=admin/posts">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/posts">Delete</a></td> <td><a href="<?php echo $p->url ?>/edit?destination=admin/posts">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/posts">Delete</a></td>


+ 30
- 9
system/htmly.php View File

@ -111,19 +111,30 @@ post('/login', function() {
// The blog post page // The blog post page
get('/:year/:month/:name', function($year, $month, $name) { 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); $post = find_post($year, $month, $name);
$current = $post['current']; $current = $post['current'];
add_view($current->file);
if (!login()) {
file_cache($_SERVER['REQUEST_URI']);
}
if (!$current) { if (!$current) {
not_found(); not_found();
} }
if(config("views.counter") == "true")
{
add_view($current->file);
if (!login()) {
file_cache($_SERVER['REQUEST_URI']);
}
}
$bio = get_bio($current->author); $bio = get_bio($current->author);
@ -567,6 +578,14 @@ get('/:static', function($static) {
} }
die; die;
} else { } else {
if( config("views.counter") != "true")
{
if (!login()) {
file_cache($_SERVER['REQUEST_URI']);
}
}
$post = get_static_post($static); $post = get_static_post($static);
if (!$post) { if (!$post) {
@ -574,11 +593,13 @@ get('/:static', function($static) {
} }
$post = $post[0]; $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( render('static', array(


+ 9
- 3
system/includes/functions.php View File

@ -223,7 +223,10 @@ function get_posts($posts, $page = 1, $perpage = 0) {
$post->body = $arr[0]; $post->body = $arr[0];
} }
$post->views = get_views($post->file);
if(config("views.counter"))
{
$post->views = get_views($post->file);
}
$tmp[] = $post; $tmp[] = $post;
} }
@ -457,8 +460,11 @@ function get_static_post($static) {
$post->body = $arr[0]; $post->body = $arr[0];
} }
$post->views = get_views($post->file);
if(config("views.counter"))
{
$post->views = get_views($post->file);
}
$tmp[] = $post; $tmp[] = $post;
} }
} }


Loading…
Cancel
Save