Cleaning up

This commit is contained in:
danpros 2023-12-17 12:16:00 +07:00
commit 98d5a4a650
6 changed files with 138 additions and 128 deletions

View file

@ -402,8 +402,8 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
$time = new DateTime($t);
$timestamp = $time->format("Y-m-d");
} else {
$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/';
$dt = str_replace($replaced, '', $oldurl[0]);
$dirname = dirname($oldurl[0]) . '/';
$dt = str_replace($dirname, '', $oldurl[0]);
$t = str_replace('-', '', $dt);
$time = new DateTime($t);
$timestamp = $time->format("Y-m-d");
@ -593,14 +593,14 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr
rebuilt_cache('all');
clear_page_cache($post_url);
if ($oldfile != $newfile) {
if (file_exists($viewsFile)) {
$views = json_decode(file_get_contents($viewsFile), true);
$arr = replace_key($views, $oldfile, $newfile);
file_put_contents($viewsFile, json_encode($arr, JSON_UNESCAPED_UNICODE));
}
}
}
if ($destination == 'post') {
header("Location: $posturl");

View file

@ -98,7 +98,6 @@ $( function() {
<br>
<label for="pCategory"><?php echo i18n('Category');?> <span class="required">*</span></label>
<select id="pCategory" class="form-control" name="category">
<option value="uncategorized"><?php echo i18n("Uncategorized");?></option>
<?php foreach ($desc as $d):?>
<option value="<?php echo $d->md;?>"><?php echo $d->title;?></option>
<?php endforeach;?>

View file

@ -2,6 +2,7 @@
<?php
$desc = get_category_info(null);
asort($desc);
?>
<h2><?php echo i18n("Categories");?></h2>
<br>
@ -14,18 +15,14 @@ asort($desc);
<th><?php echo i18n('Contents');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
<tr>
<td><a href="<?php echo site_url();?>admin/categories/uncategorized"><?php echo i18n("Uncategorized");?></a></td>
<td><p><?php echo i18n('Uncategorized_comment');?>.</p></td>
<td><?php $total = get_draftcount('uncategorized') + get_categorycount('uncategorized') + get_scheduledcount('uncategorized'); echo $total?></td>
<td></td>
</tr>
<?php foreach ($desc as $d):?>
<tr>
<td><a href="<?php echo site_url();?>admin/categories/<?php echo $d->md;?>"><?php echo $d->title;?></a></td>
<td><?php echo $d->body;?></td>
<td><?php $total = get_draftcount($d->md) + get_categorycount($d->md) + get_scheduledcount($d->md); echo $total?></td>
<td><a class="btn btn-primary btn-xs" href="<?php echo $d->url;?>/edit?destination=admin/categories"><?php echo i18n('Edit');?></a> <?php if (get_categorycount($d->md) == 0 && get_draftcount($d->md) == 0 ){echo '<a class="btn btn-danger btn-xs" href="' . $d->url . '/delete?destination=admin/categories">' . i18n('Delete') . '</a>';}?></td>
<td><?php $total = get_draftcount($d->md) + $d->count + get_scheduledcount($d->md); echo $total?></td>
<?php if($d->md !== 'uncategorized'):?>
<td><a class="btn btn-primary btn-xs" href="<?php echo $d->url;?>/edit?destination=admin/categories"><?php echo i18n('Edit');?></a> <?php if ($d->count == 0 && get_draftcount($d->md) == 0 && get_scheduledcount($d->md) == 0){echo '<a class="btn btn-danger btn-xs" href="' . $d->url . '/delete?destination=admin/categories">' . i18n('Delete') . '</a>';}?></td>
<?php endif;?>
</tr>
<?php endforeach;?>
</table>

View file

@ -147,7 +147,6 @@ $( function() {
<br>
<label for="pCategory"><?php echo i18n('Category');?> <span class="required">*</span></label>
<select id="pCategory" class="form-control" name="category">
<option value="uncategorized"><?php echo i18n("Uncategorized");?></option>
<?php foreach ($desc as $d):?>
<option value="<?php echo $d->md;?>" <?php if($category === $d->md) { echo 'selected="selected"';} ?>><?php echo $d->title;?></option>
<?php endforeach;?>