Browse Source

Merge branch 'viewCount+subPages' into viewCount

Conflicts:
	system/admin/admin.php
	system/htmly.php
pull/74/head
Kanti 11 years ago
parent
commit
f7502b95b5
5 changed files with 55 additions and 18 deletions
  1. +3
    -0
      config/config.ini.example
  2. +10
    -4
      system/admin/admin.php
  3. +2
    -2
      system/admin/views/posts-list.html.php
  4. +31
    -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
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"

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

@ -321,7 +321,10 @@ function get_recent_posts() {
$posts = get_profile($_SESSION[config("site.url")]['user'], 1, 5);
if (!empty($posts)) {
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);
foreach ($posts as $p) {
@ -336,7 +339,8 @@ function get_recent_posts() {
echo '<tr class="' . $class . '">';
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></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><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>';
@ -368,7 +372,8 @@ function get_recent_pages() {
echo '<tr class="' . $class . '">';
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 '</tr>';
@ -379,7 +384,8 @@ function get_recent_pages() {
{
echo '<tr class="' . $class . '">';
echo '<td> &raquo;<a target="_blank" href="' . $sp->url . '">' . $sp->title . '</a></td>';
echo '<td>' . $sp->views . '</td>';
if (config("views.counter") == "true")
echo '<td>' . $sp->views . '</td>';
echo '<td><a href="' . $sp->url . '/edit?destination=admin">Edit</a> <a href="' . $sp->url . '/delete?destination=admin">Delete</a></td>';
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>
<?php if(!empty($posts)) {?>
<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 foreach($posts as $p):?>
<?php
@ -19,7 +19,7 @@
<tr class="<?php echo $class ?>">
<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 $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><?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>


+ 31
- 9
system/htmly.php View File

@ -111,6 +111,12 @@ 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);
@ -120,10 +126,13 @@ get('/:year/:month/:name', function($year, $month, $name) {
not_found();
}
add_view($current->file);
if (!login()) {
file_cache($_SERVER['REQUEST_URI']);
if(config("views.counter") == "true")
{
add_view($current->file);
if (!login()) {
file_cache($_SERVER['REQUEST_URI']);
}
}
$bio = get_bio($current->author);
@ -568,6 +577,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) {
@ -575,11 +592,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(
@ -1092,7 +1111,10 @@ get('/:static/:sub', function($static,$sub) {
}
$post = $post[0];
add_view($post->file);
if(config("views.counter") == "true")
{
add_view($post->file);
}
if (!login()) {
file_cache($_SERVER['REQUEST_URI']);


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

@ -256,7 +256,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;
}
@ -490,8 +493,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;
}
}


Loading…
Cancel
Save