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

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