Browse Source

Bugs fixes

pull/189/head
Danang Probo Sayekti 10 years ago
parent
commit
ffc88888dd
3 changed files with 33 additions and 12 deletions
  1. +4
    -4
      system/admin/views/edit-post.html.php
  2. +5
    -6
      system/htmly.php
  3. +24
    -2
      system/includes/functions.php

+ 4
- 4
system/admin/views/edit-post.html.php View File

@ -81,11 +81,11 @@ $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destinat
} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
<?php if ($isdraft[2] == 'draft') { ?>
<input type="submit" name="publishdraft" class="submit" value="Publish draft"/> <input type="submit" name="updatedraft" class="draft" value="Update draft"/> <a href="<?php echo $delete ?>">Delete</a>
<?php } else { ?>
<?php if ($isdraft[2] == 'draft') { ?>
<input type="submit" name="publishdraft" class="submit" value="Publish draft"/> <input type="submit" name="updatedraft" class="draft" value="Update draft"/> <a href="<?php echo $delete ?>">Delete</a>
<?php } else { ?>
<input type="submit" name="updatepost" class="submit" value="Update post"/> <input type="submit" name="revertpost" class="revert" value="Revert to draft"/> <a href="<?php echo $delete ?>">Delete</a>
<?php }?>
<?php }?>
</form>
</div>
<div id="insertImageDialog" title="Insert Image">


+ 5
- 6
system/htmly.php View File

@ -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;
}


+ 24
- 2
system/includes/functions.php View File

@ -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 '</ul>';
} else {
echo '<ul><li>No related post found</li></ul>';
}
}
// 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 .= '<li><a href="' . $post->url . '">' . $post->title . '</a></li>';
}
if (empty($posts)) {
$str .= '<li>No Posts Found</li>';
$str .= '<li>No recent posts found</li>';
}
$str .= '</ul>';
return $str;


Loading…
Cancel
Save