diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-14 03:10:19 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-14 03:10:19 +0200 |
| commit | 51b3554ff2988ac61ba3f604431e09941cd95545 (patch) | |
| tree | 6e2331212ed6f0556e420450deb93e6822e846cd /html/app/views/simple/category.php | |
| parent | 8b928471412bbf9016df9b01b2308f003e455d7d (diff) | |
| download | classroom-51b3554ff2988ac61ba3f604431e09941cd95545.tar.gz classroom-51b3554ff2988ac61ba3f604431e09941cd95545.tar.bz2 classroom-51b3554ff2988ac61ba3f604431e09941cd95545.zip | |
main css classes for front/back-end
Diffstat (limited to 'html/app/views/simple/category.php')
| -rw-r--r-- | html/app/views/simple/category.php | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/html/app/views/simple/category.php b/html/app/views/simple/category.php new file mode 100644 index 0000000..15d8b5e --- /dev/null +++ b/html/app/views/simple/category.php @@ -0,0 +1,156 @@ +<?php +// init app +// ----------------------------------------------------------------------------- +include 'pythia.php'; + + +// read request parameters +// ----------------------------------------------------------------------------- +$category_id = intval($_GET['id']); + + +// Get all data needed +// (so you don't have to make multiple requests to the wiki-database) +// ----------------------------------------------------------------------------- + +$categories = $wiki->category_tree(); +$breadcrumbs = Render::all_breadcrumbs($categories); + +// get ALL posts of category +$posts = $wiki->latest_published_posts($category_id, 0); + + +// special case: +// ----------------------------------------------------------------------------- +// ONE post + NO subcaegories ..then redirect to the only post +if (($breadcrumbs[ $category_id ]['childs'] == []) && (count($posts) == 1)) { + header('Location: /wiki/post?id='. $posts[0]['id'], true, 302); + die(); +} + + +// find parent_ids of current category (to open the menu tree) +$category_path = []; +foreach($breadcrumbs[$category_id]['parents'] as $parent) { + $category_path[] = intval($parent['id']); +} +$category_path[] = intval($category_id); + + +// format $posts array +// --- +$posts_formated = []; +foreach($posts as $post) { + $date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $post['creation_date']); + $posts_formated[] = [ + 'id' => $post['id'], + 'title' => $post['title'], + 'intro' => $post['intro'] ?? false, + 'date' => Render::date_box($post['creation_date']) + ]; +} + + +// then render the page ... +// ----------------------------------------------------------------------------- +?><!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>Wiki</title> + + <?php Render::template("sections/common_libs.php", [ 'admin' => false ]); ?> + +</head> +<body> + <?php include HEAD; ?> + + <div class="container-fluid main-content wiki"> + + <div class="top-bar"> + <div class="breadcrumb"> + <?php // breadcrumbs + //////////////////////////////////////////////////////////// + Render::template("sections/breadcrumbs.php", [ + 'id' => $category_id, + 'title' => $breadcrumbs[ $category_id ]['rec']['title'], + 'parents' => $breadcrumbs[ $category_id ]['parents'] + ]); //////////////////////////////////////////////////// + ?> + </div> + + <div class="admin"> + <?php include "sections/admin-dropdown.php"; ?> + </div> + + </div><!-- /top-bar --> + + <div class="row"> + <div class="col-xl-2 col-lg-3 col-sm-4 side-bar"> + + <!-- <h3>Κατηγορίες</h3> --> + <?php // categories hierarchical menu + //////////////////////////////////////////////////////////// + Render::template("sections/categories_menu.php", [ + 'categories' => $categories, + 'open_path' => $category_path + ]); //////////////////////////////////////////////////// + ?> + + </div> + <div class="col-xl-10 col-lg-9 col-sm-8 content"> + + <div class="content--wrapper"> + + <!-- Category Title --> + <h2> + <?=$breadcrumbs[ $category_id ]['rec']['title']?> + </h2> + + + <!-- Sub-Categories --> + + <?php if ($breadcrumbs[ $category_id ]['childs'] != []) : ?> + + <h3>Υποκατηγορίες</h3> + <div class="category-childs"> + + <?php foreach($breadcrumbs[ $category_id ]['childs'] as $key => $child) : ?> + + <a href="/wiki/category?id=<?=$child['id']?>"> + <?=$child['title']?> + </a> + + <?php endforeach; ?> + + </div> + + <?php endif; ?> + + + <!-- Articles List --> + + <?php if ($posts) : ?> + + <h3>Άρθρα / Δημοσιεύσεις</h3> + + <?php // list of posts/articles + //////////////////////////////////////////////////// + Render::template("sections/articles_list.php", [ + 'articles' => $posts_formated, + 'fieldset' => ['intro', 'date'] + ]); + //////////////////////////////////////////////////// + ?> + <?php endif; ?> + + + </div> + + </div> + </div> + </div> + + <script src="/wiki/js/wiki.js"></script> +</body> +</html> |
