Improve pages/subpages

Allow to reorder the pages and subpages position. Added doks theme
This commit is contained in:
danpros 2024-01-26 08:06:12 +07:00
commit 8d142b7f37
46 changed files with 4860 additions and 94 deletions

View file

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

View file

@ -7,20 +7,24 @@ $desc = get_category_info(null);
<a class="btn btn-primary " href="<?php echo site_url();?>add/category"><?php echo i18n('Add_category');?></a>
<br><br>
<table class="table category-list">
<thead>
<tr class="head">
<th><?php echo i18n('Name');?></th>
<th><?php echo i18n('Description');?></th>
<th><?php echo i18n('Contents');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?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><a href="<?php echo site_url();?>admin/categories/<?php echo $d->slug;?>"><?php echo $d->title;?></a></td>
<td><?php echo $d->body;?></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;?>
<td><?php $total = get_draftcount($d->slug) + $d->count + get_scheduledcount($d->slug); echo $total?></td>
<?php if($d->slug !== '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->slug) == 0 && get_scheduledcount($d->slug) == 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;?>
</tbody>
</table>

View file

@ -6,18 +6,21 @@
<br><br>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Published');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p): ?>
<tr>
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
<td><?php echo format_date($p->date) ?></td>
<?php if ($category->url !== site_url() . 'category/uncategorized') {?>
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/categories/<?php echo $category->md;?>"><?php echo i18n('Edit');?></a> <a
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/categories/<?php echo $category->md;?>"><?php echo i18n('Delete');?></a></td>
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/categories/<?php echo $category->slug;?>"><?php echo i18n('Edit');?></a> <a
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/categories/<?php echo $category->slug;?>"><?php echo i18n('Delete');?></a></td>
<?php } else {?>
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/categories/uncategorized"><?php echo i18n('Edit');?></a> <a
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/categories/uncategorized"><?php echo i18n('Delete');?></a></td>
@ -25,6 +28,7 @@
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
<br>

View file

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

View file

@ -34,8 +34,8 @@ if ($type == 'is_frontpage') {
$oldtitle = $p->title;
$olddescription = $p->description;
$oldcontent = $p->body;
$oldmd = $p->md;
$url = 'content/data/category/'. $p->md . '.md';
$oldmd = $p->slug;
$url = 'content/data/category/'. $p->slug . '.md';
} else {
if (isset($p->file)) {
@ -55,7 +55,13 @@ if ($type == 'is_frontpage') {
}
$dir = pathinfo($url, PATHINFO_DIRNAME);
$oldurl = pathinfo($url, PATHINFO_BASENAME);
$oldmd = pathinfo($url, PATHINFO_FILENAME);
$fn = explode('.', pathinfo($url, PATHINFO_FILENAME));
if (isset($fn[1])) {
$oldmd = $fn[1];
} else {
$oldmd = pathinfo($url, PATHINFO_FILENAME);
}
if (isset($p->url)) {
$delete = $p->url . '/delete?destination=' . $destination;

View file

@ -10,6 +10,7 @@
<link href="<?php echo site_url() ?>system/resources/css/adminlte.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
<script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
<script src="<?php echo site_url() ?>system/resources/js/jquery-ui.min.js"></script>
</head>
<?php if (login()) { ?>
<body class="hold-transition sidebar-mini">

View file

@ -107,6 +107,7 @@ function parseMenu($menu) {
data: {'json': js},
success: function (response) {
alert(response.message);
location.reload();
},
});
});

View file

@ -5,6 +5,7 @@
<br><br>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Published');?></th><?php if (config("views.counter") == "true"): ?>
@ -14,6 +15,8 @@
<th><?php echo i18n('Tags');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p): ?>
<?php if (strpos($p->file, '/scheduled/') == false && strpos($p->file, '/draft/') == false) { ?>
<tr>
@ -29,6 +32,7 @@
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>
<?php } else {
echo i18n('No_posts_found') . '!';

View file

@ -5,6 +5,7 @@
<br><br>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Published');?></th><?php if (config("views.counter") == "true"): ?>
@ -14,6 +15,8 @@
<th><?php echo i18n('Tags');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p): ?>
<tr>
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
@ -27,6 +30,7 @@
class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/posts"><?php echo i18n('Delete');?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
<br>

View file

@ -5,6 +5,7 @@
<br><br>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Publish');?></th>
@ -12,6 +13,8 @@
<th><?php echo i18n('Tags');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p): ?>
<tr>
<td><?php echo $p->title ?></td>
@ -21,6 +24,7 @@
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/scheduled"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/scheduled"><?php echo i18n('Delete');?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
<br>

View file

@ -3,52 +3,68 @@
<br>
<a class="btn btn-primary right" href="<?php echo site_url();?>add/page"><?php echo i18n('Add_new_page');?></a>
<br><br>
<script>
$(function() {
var order;
$( "tbody" ).sortable({update: function(e, ui) {
order = $(this).sortable('toArray');
$("#saveButton").css({"display": "block"});
}});
$("#saveButton").click(function(){
$.ajax({
type: 'POST',
url: '<?php echo site_url();?>admin/pages',
dataType: 'json',
data: {'json': order},
success: function (response) {
alert(response.message);
location.reload();
},
});
});
});
</script>
<?php if (isset($_SESSION[site_url()]['user'])):?>
<?php $posts = find_page();
if (!empty($posts)): ?>
<table class="table post-list">
<tr class="head">
<table class="table post-list" id="sortable">
<thead>
<tr class="head" id="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('Description');?></th>
<th><?php echo i18n('Operations');?></th>
<th>Subpages</th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p):?>
<?php $dd = find_subpage($p->md); ?>
<?php $dr = find_draft_subpage($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><i class="nav-icon fa fa-line-chart"></i> <?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 (empty($dd) && empty($dr)):?><a class="btn btn-danger btn-xs" href="<?php echo $p->url;?>/delete?destination=admin/pages"><?php echo i18n('Delete');?></a><?php endif;?></td>
<?php $dd = find_subpage($p->slug); ?>
<?php $dr = find_draft_subpage($p->slug);?>
<tr id="<?php echo $p->md;?>" class="sort-item" style="cursor:move;">
<td><a href="<?php echo site_url();?>admin/pages/<?php echo $p->slug;?>"><?php echo $p->title;?></a></td>
<td><?php echo shorten($p->description, '50');?>...</td>
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url;?>/add?destination=admin/pages/<?php echo $p->slug;?>"><?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 (empty($dd) && empty($dr)):?><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 = find_subpage($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>
<div><a class="btn btn-primary btn-xs" href="<?php echo site_url();?>admin/pages/<?php echo $p->slug;?>">Manage subpages</a></div><hr>
<?php foreach ($dd as $sp):?>
<div class="row">
<div class="col-sm">
<span><a target="_blank" href="<?php echo $sp->url;?>"><?php echo $sp->title;?></a></span>
</div>
<div class="col-sm">
<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;?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<br>
<button class="btn btn-primary" style="display:none" id="saveButton">Save page order</button>
<?php endif;?>
<?php endif;?>

View file

@ -0,0 +1,57 @@
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
<a href="<?php echo $static->url;?>/edit?destination=admin/pages"><?php echo i18n('Edit');?></a>
<h2 class="post-index"><?php echo $static->title ?></h2>
<div><?php echo $static->description;?></div>
<br>
<a class="btn btn-primary right" href="<?php echo $static->url;?>/add?destination=admin/pages/<?php echo $static->slug;?>"><?php echo i18n('Add_sub');?></a>
<br><br>
<script>
$(function() {
var order;
$( "tbody" ).sortable({update: function(e, ui) {
order = $(this).sortable('toArray');
$("#saveButton").css({"display": "block"});
}});
$("#saveButton").click(function(){
$.ajax({
type: 'POST',
url: '<?php echo site_url();?>admin/pages/<?php echo $static->slug;?>',
dataType: 'json',
data: {'json': order},
success: function (response) {
alert(response.message);
location.reload();
},
});
});
});
</script>
<?php $posts = find_subpage($p->slug);?>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Description');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $sp): ?>
<tr id="<?php echo $sp->parent;?>/<?php echo $sp->md;?>" style="cursor:move;">
<td><a href="<?php echo $sp->url ?>"><?php echo $sp->title ?></a></td>
<td><?php echo $sp->description;?></td>
<td> <span><a class="btn btn-primary btn-xs" href="<?php echo $sp->url;?>/edit?destination=admin/pages/<?php echo $static->slug;?>"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $sp->url;?>/delete?destination=admin/pages/<?php echo $static->slug;?>"><?php echo i18n('Delete');?></a></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<br>
<button class="btn btn-primary" style="display:none" id="saveButton">Save page order</button>
<?php } else {
echo i18n('No_posts_found') . '!';
} ?>

View file

@ -5,6 +5,7 @@
<br><br>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Created');?></th>
@ -12,6 +13,8 @@
<th><?php echo i18n('Tags');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p): ?>
<tr>
<td><?php echo $p->title ?></td>
@ -21,6 +24,7 @@
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/draft"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/draft"><?php echo i18n('Delete');?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
<br>
@ -55,7 +59,7 @@
<th><?php echo i18n('Operations');?></th>
</tr>
<?php foreach ($draftPages as $d): ?>
<?php $count = count(find_subpage($d->md)); ?>
<?php $count = count(find_subpage($d->md)); ?>
<tr>
<td><?php echo $d->title ?></td>
<td><?php echo format_date($d->lastMod) ?></td>
@ -74,15 +78,15 @@
<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>
<th><?php echo i18n('Static_pages');?></th>
</tr>
<?php foreach ($draftSubpages as $sp): ?>
<?php $parent = find_page($sp->parent);?>
<?php $parent = find_page($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>
<td><a href="<?php echo $parent['current']->url;?>"><?php echo $parent['current']->title;?></a></td>
</tr>
<?php endforeach; ?>
</table>

View file

@ -5,6 +5,7 @@
<br><br>
<?php if (!empty($posts)) { ?>
<table class="table post-list">
<thead>
<tr class="head">
<th><?php echo i18n('Title');?></th>
<th><?php echo i18n('Published');?></th>
@ -15,6 +16,8 @@
<th><?php echo i18n('Tags');?></th>
<th><?php echo i18n('Operations');?></th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $p): ?>
<tr>
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
@ -27,6 +30,7 @@
<td><a class="btn btn-primary btn-xs" href="<?php echo $p->url ?>/edit?destination=admin/mine"><?php echo i18n('Edit');?></a> <a class="btn btn-danger btn-xs" href="<?php echo $p->url ?>/delete?destination=admin/mine"><?php echo i18n('Delete');?></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
<br>