From 02f84d81ebf36e055700d9f5851f3c67c9dd8f92 Mon Sep 17 00:00:00 2001 From: danpros Date: Fri, 19 Feb 2021 18:56:43 +0700 Subject: [PATCH] Category page in admin --- system/admin/views/categories.html.php | 4 +- system/admin/views/category-list.html.php | 60 ++++++++++++++++++++++++++++++ system/htmly.php | 61 +++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 system/admin/views/category-list.html.php diff --git a/system/admin/views/categories.html.php b/system/admin/views/categories.html.php index 0eccea7..c0741b8 100644 --- a/system/admin/views/categories.html.php +++ b/system/admin/views/categories.html.php @@ -11,14 +11,14 @@ - +

.

- title;?> + title;?> body;?> md) + get_categorycount($d->md); echo $total?> md) == 0 && get_draftcount($d->md) == 0 ){echo '' . i18n('Delete') . '';}?> diff --git a/system/admin/views/category-list.html.php b/system/admin/views/category-list.html.php new file mode 100644 index 0000000..fc7afb8 --- /dev/null +++ b/system/admin/views/category-list.html.php @@ -0,0 +1,60 @@ +

title ?>

+
body;?>
+
+url !== site_url() . 'category/uncategorized'):?>Edit category +

+ + + + + + + + + + + + + + url !== site_url() . 'category/uncategorized') {?> + + + + + + + +
title ?>date) ?>
+ +
+
+ +
+ + \ No newline at end of file diff --git a/system/htmly.php b/system/htmly.php index 049e5db..f484613 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -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' => '' . config('breadcrumb.home') . ' » Categories » ' . $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) {