mirror of
https://github.com/danpros/htmly.git
synced 2026-04-22 21:46:22 +05:30
Category page in admin
This commit is contained in:
parent
5a75046a2f
commit
02f84d81eb
3 changed files with 123 additions and 2 deletions
|
|
@ -11,14 +11,14 @@
|
|||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="<?php echo site_url();?>category/uncategorized" target="_blank"><?php echo i18n("Uncategorized");?></a></td>
|
||||
<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'); echo $total?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach ($desc as $d):?>
|
||||
<tr>
|
||||
<td><a href="<?php echo $d->url;?>" target="_blank"><?php echo $d->title;?></a></td>
|
||||
<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); 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>
|
||||
|
|
|
|||
60
system/admin/views/category-list.html.php
Normal file
60
system/admin/views/category-list.html.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<h2 class="post-index"><?php echo $category->title ?></h2>
|
||||
<div><?php echo $category->body;?></div>
|
||||
<br>
|
||||
<?php if ($category->url !== site_url() . 'category/uncategorized'):?><a class="btn btn-primary right" href="<?php echo $category->url;?>/edit">Edit category</a><?php endif;?>
|
||||
<br><br>
|
||||
<?php if (!empty($posts)) { ?>
|
||||
<table class="table post-list">
|
||||
<tr class="head">
|
||||
<th><?php echo i18n('Title');?></th>
|
||||
<th><?php echo i18n('Published');?></th>
|
||||
<th><?php echo i18n('Operations');?></th>
|
||||
</tr>
|
||||
<?php $i = 0;
|
||||
$len = count($posts); ?>
|
||||
<?php foreach ($posts as $p): ?>
|
||||
<?php
|
||||
if ($i == 0) {
|
||||
$class = 'item first';
|
||||
} elseif ($i == $len - 1) {
|
||||
$class = 'item last';
|
||||
} else {
|
||||
$class = 'item';
|
||||
}
|
||||
$i++;
|
||||
?>
|
||||
<tr class="<?php echo $class ?>">
|
||||
<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>
|
||||
<?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>
|
||||
<?php } ?>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
|
||||
<br>
|
||||
<div class="pager">
|
||||
<ul class="pagination">
|
||||
<?php if (!empty($pagination['prev'])) { ?>
|
||||
<li class="newer page-item"><a class="page-link" href="?page=<?php echo $page - 1 ?>" rel="prev">← Newer</a></li>
|
||||
<?php } else { ?>
|
||||
<li class="page-item disabled" ><span class="page-link">← Newer</span></li>
|
||||
<?php } ?>
|
||||
<li class="page-number page-item disabled"><span class="page-link"><?php echo $pagination['pagenum'];?></span></li>
|
||||
<?php if (!empty($pagination['next'])) { ?>
|
||||
<li class="older page-item" ><a class="page-link" href="?page=<?php echo $page + 1 ?>" rel="next">Older →</a></li>
|
||||
<?php } else { ?>
|
||||
<li class="page-item disabled" ><span class="page-link">Older →</span></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } else {
|
||||
echo i18n('No_posts_found') . '!';
|
||||
} ?>
|
||||
|
|
@ -1450,6 +1450,67 @@ get('/admin/categories', function () {
|
|||
die;
|
||||
});
|
||||
|
||||
// Show the category page
|
||||
get('/admin/categories/:category', function ($category) {
|
||||
|
||||
$user = $_SESSION[config("site.url")]['user'];
|
||||
$role = user('role', $user);
|
||||
if (login()) {
|
||||
|
||||
config('views.root', 'system/admin/views');
|
||||
if ($role === 'admin') {
|
||||
|
||||
$page = from($_GET, 'page');
|
||||
$page = $page ? (int)$page : 1;
|
||||
$perpage = config('category.perpage');
|
||||
|
||||
if (empty($perpage)) {
|
||||
$perpage = 10;
|
||||
}
|
||||
|
||||
$posts = get_category($category, $page, $perpage);
|
||||
|
||||
$desc = get_category_info($category);
|
||||
|
||||
if(strtolower($category) !== 'uncategorized') {
|
||||
$desc = $desc[0];
|
||||
}
|
||||
|
||||
$total = get_categorycount($category);
|
||||
|
||||
if (empty($posts) || $page < 1) {
|
||||
// a non-existing page
|
||||
not_found();
|
||||
}
|
||||
|
||||
render('category-list', array(
|
||||
'title' => $desc->title . ' - ' . blog_title(),
|
||||
'description' => $desc->description,
|
||||
'canonical' => $desc->url,
|
||||
'page' => $page,
|
||||
'posts' => $posts,
|
||||
'category' => $desc,
|
||||
'bodyclass' => 'in-category category-' . strtolower($category),
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/categories">Categories</a> » ' . $desc->title,
|
||||
'pagination' => has_pagination($total, $perpage, $page),
|
||||
'is_category' => true,
|
||||
));
|
||||
} else {
|
||||
render('denied', array(
|
||||
'title' => 'Categories - ' . blog_title(),
|
||||
'description' => strip_tags(blog_description()),
|
||||
'canonical' => site_url(),
|
||||
'type' => 'is_admin-categories',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'denied',
|
||||
'breadcrumb' => '',
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
}
|
||||
});
|
||||
|
||||
// Show the category page
|
||||
get('/category/:category', function ($category) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue