Draft for pages and subpages

This commit is contained in:
danpros 2024-01-01 11:37:47 +07:00
commit 0ec68537c5
10 changed files with 387 additions and 112 deletions

View file

@ -42,7 +42,7 @@
<br>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
<?php if ($type == 'is_page') :?>
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Publish');?>"/>
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Publish');?>"/> <input type="submit" name="draft" class="btn btn-primary draft" value="<?php echo i18n('Save_as_draft');?>"/>
<?php endif;?>
<?php if ($type == 'is_category') :?>
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Add_category');?>"/>

View file

@ -21,8 +21,9 @@ if (isset($destination)) {
} else {
$back = site_url();
}
$info = $p->title . ' (' . $p->file . ')';
?>
<p><?php echo sprintf(i18n('Are_you_sure_you_want_to_delete_'), $p->title);?></p>
<p><?php echo sprintf(i18n('Are_you_sure_you_want_to_delete_'), $info);?></p>
<form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">

View file

@ -21,8 +21,9 @@ if (isset($destination)) {
} else {
$back = site_url();
}
$info = $p->title . ' (' . $p->file . ')';
?>
<p><?php echo sprintf(i18n('Are_you_sure_you_want_to_delete_'), $p->title);?></p>
<p><?php echo sprintf(i18n('Are_you_sure_you_want_to_delete_'), $info);?></p>
<form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">

View file

@ -28,9 +28,9 @@ if (isset($destination)) {
} else {
$back = site_url();
}
$info = $p->title . ' (' . $p->file . ')';
?>
<p><?php echo sprintf(i18n('Are_you_sure_you_want_to_delete_'), $p->title);?></p>
<p><?php echo sprintf(i18n('Are_you_sure_you_want_to_delete_'), $info);?></p>
<form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">

View file

@ -46,9 +46,9 @@ if ($type == 'is_frontpage') {
} else {
$destination = 'admin';
}
$dir = substr($url, 0, strrpos($url, '/'));
$oldurl = str_replace($dir . '/', '', $url);
$oldmd = str_replace('.md', '', $oldurl);
$dir = pathinfo($url, PATHINFO_DIRNAME);
$oldurl = pathinfo($url, PATHINFO_BASENAME);
$oldmd = pathinfo($url, PATHINFO_FILENAME);
if (isset($p->url)) {
$delete = $p->url . '/delete?destination=' . $destination;
@ -118,7 +118,13 @@ $images = get_gallery();
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Save_category');?>"/>
<?php } else {?>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Save');?>"/> <a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a>
<?php $count = count(get_static_sub_post($oldmd)); ?>
<?php if (stripos($dir . '/', '/draft/') !== false) { ?>
<input type="submit" name="publishdraft" class="btn btn-primary submit" value="<?php echo i18n('Publish_draft');?>"/> <input type="submit" name="updatedraft" class="btn btn-primary draft" value="<?php echo i18n('Update_draft');?>"/> <?php if ($count == 0 && $type != 'is_page'):?><a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a><?php endif;?>
<?php } else { ?>
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Save');?>"/> <input type="submit" name="revertpage" class="btn btn-primary revert" value="<?php echo i18n('Revert_to_draft');?>"/> <?php if ($count == 0 && $type != 'is_page'):?><a class="btn btn-danger" href="<?php echo $delete ?>"><?php echo i18n('Delete');?></a><?php endif;?>
<?php } ?>
<?php } ?>
</div>
<div class="col-sm-6">

View file

@ -3,48 +3,51 @@
<br>
<a class="btn btn-primary right" href="<?php echo site_url();?>add/page"><?php echo i18n('Add_new_page');?></a>
<br><br>
<?php
<?php if (isset($_SESSION[config("site.url")]['user'])):?>
<?php $posts = get_static_post();
if (!empty($posts)): ?>
<table class="table post-list">
<tr class="head">
<th><?php echo i18n('Title');?> </th>
<?php if (config("views.counter") == "true"):?>
<th><?php echo i18n('Views');?></th>
<?php endif;?>
<th><?php echo i18n('Operations');?></th>
<th>Sub Pages</th>
</tr>
<?php foreach ($posts as $p):?>
<?php $count = count(get_static_sub_post($p->md)); ?>
<tr>
<td><a target="_blank" href="<?php echo $p->url;?>"><?php echo $p->title;?></a></td>
<?php if (config("views.counter") == "true"):?>
<td><?php echo $p->views;?></td>
<?php endif;?>
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/add?destination=admin/pages"><?php echo i18n('Add_sub');?></a> <a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a> <?php if ($count == 0):?><a class="btn btn-danger btn-xs" href="<?php echo $p->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a><?php endif;?></td>
<td>
<table>
<?php $subPages = get_static_sub_post($p->md);
foreach ($subPages as $sp):?>
<div class="row">
<div class="col-6 col-md-4">
<span><a target="_blank" href="<?php echo $sp->url;?>"><?php echo $sp->title;?></a></span>
</div>
<div class="col-6 col-md-4">
<?php if (config("views.counter") == "true"):?>
<span><i class="nav-icon fa fa-line-chart"></i> <?php echo $sp->views;?></span>
<?php endif;?></div>
<div class="col-6 col-md-4">
<span><a class="btn btn-primary btn-xs" href="<?php echo $sp->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a></span>
</div>
</div>
<?php endforeach;?>
</table>
</td>
</tr>
if (isset($_SESSION[config("site.url")]['user'])) {
$posts = get_static_post(null);
if (!empty($posts)) {
echo '<table class="table post-list">';
echo '<tr class="head"><th>' . i18n('Title') . '</th>';
if (config("views.counter") == "true")
echo '<th>'.i18n('Views').'</th>';
echo '<th>' . i18n('Operations') . '</th></tr>';
$i = 0;
$len = count($posts);
foreach ($posts as $p) {
if ($i == 0) {
$class = 'item first';
} elseif ($i == $len - 1) {
$class = 'item last';
} else {
$class = 'item';
}
$i++;
echo '<tr class="' . $class . '">';
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
if (config("views.counter") == "true")
echo '<td>' . $p->views . '</td>';
echo '<td><a class="btn btn-primary btn-xs" href="' . $p->url . '/add?destination=admin/pages">' . i18n('Add_sub') . '</a> <a class="btn btn-primary btn-xs" href="' . $p->url . '/edit?destination=admin/pages">' . i18n('Edit') . '</a> <a class="btn btn-danger btn-xs" href="' . $p->url . '/delete?destination=admin/pages">' . i18n('Delete') . '</a></td>';
echo '</tr>';
$subPages = get_static_sub_post($p->md);
foreach ($subPages as $sp) {
echo '<tr class="' . $class . '">';
echo '<td> <span style="margin-left:30px;">&raquo; <a target="_blank" href="' . $sp->url . '">' . $sp->title . '</a></span></td>';
if (config("views.counter") == "true")
echo '<td>' . $sp->views . '</td>';
echo '<td><a class="btn btn-primary btn-xs" href="' . $sp->url . '/edit?destination=admin/pages">' . i18n('Edit') . '</a> <a class="btn btn-danger btn-xs" href="' . $sp->url . '/delete?destination=admin/pages">' . i18n('Delete') . '</a></td>';
echo '</tr>';
}
}
echo '</table>';
}
}
?>
<?php endforeach;?>
</table>
<?php endif;?>
<?php endif;?>

View file

@ -43,3 +43,47 @@
<?php } else {
echo i18n('No_draft_found') . '!';
} ?>
<?php if (!empty($draftPages)):?>
<br><br>
<hr>
<h2 class="post-index"><?php echo i18n('Draft');?>: <?php echo i18n('Static_pages');?></h2>
<table class="table post-list">
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Created');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
<?php foreach ($draftPages as $d): ?>
<?php $count = count(get_static_sub_post($d->md)); ?>
<tr>
<td><?php echo $d->title ?></td>
<td><?php echo format_date($d->lastMod) ?></td>
<td><a class="btn btn-primary btn-xs" href="<?php echo $d->url ?>/edit?destination=admin/draft"><?php echo i18n('Edit');?></a> <?php if ($count == 0):?><a class="btn btn-danger btn-xs" href="<?php echo $d->url ?>/delete?destination=admin/draft"><?php echo i18n('Delete');?></a><?php endif;?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif;?>
<?php if (!empty($draftSubpages)):?>
<br><br>
<hr>
<h2 class="post-index"><?php echo i18n('Draft');?>: Sub</h2>
<table class="table post-list">
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Created');?></th>
<th><?php echo i18n('Operations');?></th>
<th><?php echo i18n('Static_pages');?></th>
</tr>
<?php foreach ($draftSubpages as $sp): ?>
<?php $parent = get_static_post($sp->parent);?>
<tr>
<td><?php echo $sp->title ?></td>
<td><?php echo format_date($sp->lastMod) ?></td>
<td><a class="btn btn-primary btn-xs" href="<?php echo $sp->url ?>/edit?destination=admin/draft"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url ?>/delete?destination=admin/draft"><?php echo i18n('Delete');?></a></td>
<td><a href="<?php echo $parent['current']->url;?>"><?php echo $parent['current']->title;?></a></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif;?>