summaryrefslogtreecommitdiff
path: root/public/app/views/simple/category.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 03:47:30 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 03:47:30 +0300
commit059e0d95d0c28bc5060e87e146eaf7411f51bf90 (patch)
tree7c21ac432f16dde2329a0d5954d70711eceb48e6 /public/app/views/simple/category.php
parent26cd8ee99659ef1926c96a049c93645ffc9b169d (diff)
downloadgyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.gz
gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.bz2
gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.zip
skeleton commit; based on an anom project
Diffstat (limited to 'public/app/views/simple/category.php')
-rw-r--r--public/app/views/simple/category.php156
1 files changed, 156 insertions, 0 deletions
diff --git a/public/app/views/simple/category.php b/public/app/views/simple/category.php
new file mode 100644
index 0000000..15d8b5e
--- /dev/null
+++ b/public/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>