diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-17 12:12:22 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-17 12:12:22 +0300 |
| commit | 68fc9e55e538e03f94509731ab41a0c8cf96710f (patch) | |
| tree | 3edb1e81864ac3eb35ba0fe8087ed24da1b812bf /public/app/views/simple/post.php | |
| parent | 84b2da85a1b452922dadb6a609533b9945afe51d (diff) | |
| download | classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.tar.gz classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.tar.bz2 classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.zip | |
setup a real server environment (apache DocumentRoot=/var/www/public)
Diffstat (limited to 'public/app/views/simple/post.php')
| -rw-r--r-- | public/app/views/simple/post.php | 236 |
1 files changed, 236 insertions, 0 deletions
diff --git a/public/app/views/simple/post.php b/public/app/views/simple/post.php new file mode 100644 index 0000000..9e37cd9 --- /dev/null +++ b/public/app/views/simple/post.php @@ -0,0 +1,236 @@ +<?php +// init app +// ----------------------------------------------------------------------------- +include 'pythia.php'; + +// read request parameters +// ----------------------------------------------------------------------------- +$post_id = intval($_GET['id']); + + +// Get all data needed +// (so you don't have to make multiple requests to the wiki-database) +// ----------------------------------------------------------------------------- + +$post = $wiki->get_post($post_id); +$categories = $wiki->category_tree(); +$breadcrumbs = Render::all_breadcrumbs($categories); + +if ($post == false) { // when post not found + $post = [ // create a virtual record with error messages + 'id' => 0, + 'title' => 'Το άρθρο που αναζητήσατε δεν υπάρχει', + 'category_id' => 0, + 'intro' => 'Για να βρειτε το άρθρο που ψάχνετε χρησιμοποιήστε την αναζήτηση + του wiki ή πλοηγηθείτε στο δέντρο των κατηγοριών.', + 'body' => "" + ]; + +} else { // post found; prepare article's data to render + + $category_id = $post['category_id']; + + // 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 special parts of post +$parsedown = new Parsedown(); +$body_html = $parsedown->text($post['body']); // body: markdown to html + +// decode json output (tags + medias) +if ($post['tags_json'] != null) { $tags = json_decode($post['tags_json']); } +if ($post['medias_json'] != null) { $medias = json_decode($post['medias_json']); } + + +// 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 ]); ?> + +<body> + <?php include HEAD; ?> + + <div class="container-fluid main-content wiki"> + + <div class="top-bar"> + <div class="breadcrumb"> + + <?php if($post['id'] != 0) : ?> + <?php // breadcrumbs + //////////////////////////////////////////////////////////// + Render::template("sections/breadcrumbs.php", [ + 'id' => $post['category_id'], + 'title' => $breadcrumbs[ $post['category_id'] ]['rec']['title'], + 'parents' => $breadcrumbs[ $post['category_id'] ]['parents'] + ]); //////////////////////////////////////////////////// + ?> + <?php endif ?> + + </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' => (($post['id'] == 0) + ? [1,2,3] // post not exist; open main categories + : $category_path) // post exists: open category path + ]); //////////////////////////////////////////////////// + ?> + + </div> + + <div class="col-xl-10 col-lg-9 col-sm-8 content"> + + <!-- THE POST --> + <div class="content--wrapper post"> + + <!-- title --> + <h2> + <?=$post['title']?> + <?php if (UGMC(array(61,63), $user_id)) : ?> + <span> + <a href="/wiki/admin?action=editpost&id=<?=$post_id?>" class="btn btn-xs btn-warning"> + <i class="fas fa-pencil-alt"></i> + </a> + </span> + <?php endif; ?> + </h2> + + <!-- date --> + <p class="post--date"> + Δημοσίευση: <?=Render::date_friendly($post['creation_date'])?> + <?php if ($post['update_date'] != $post['creation_date']) : ?> + — Τελευταία Ενημέρωση: <?=Render::date_friendly($post['update_date'])?> + <?php endif; ?> + </p> + + <!-- intro --> + <?php if ($post['intro'] != "") : ?> + <p class="intro"><?=$post['intro']?></p> + <?php endif; ?> + + <!-- body --> + <div class="article-body"> + <?=$body_html?> + </div> + + <?php if(isset($medias)) : ?> + <!-- medias / attachments --> + <div class="medias"> + <h4>Συνημμένα:</h4> + <ol> + <?php foreach($medias as $file) : ?> + <?php if ($file->reference == 1) : ?> + <li> + <a href="<?=CDN?><?=$file->path?>" + data-type="<?=$file->type?>" + target="_blank"> + <?=$file->title?> + </a> + </li> + <?php endif; ?> + <?php endforeach; ?> + </ol> + </div> + <?php endif; ?> + + <?php if(isset($tags)) : ?> + <!-- tags --> + <div class="tags"> + Επικέτες: + <?php foreach($tags as $tag) : ?> + <a href="/wiki/tag?id=<?=$tag->id?>"><?=$tag->name?></a> + <?php endforeach; ?> + </div> + <?php endif; ?> + + </div> + + </div><!-- /content (post) --> + + </div> + </div><!-- /main-content --> + + + <!-- MODALS --> + + <!-- product-modal --> + <div id="view-product" class="modal" tabindex="-1" > + <div class="modal-dialog modal-lg"> + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title"> + <i class="glyphicon glyphicon-tag"></i> Στοιχεία Προϊόντος + </h4> + </div> + <div class="modal-body"> + + <div id="modal-loader" style="display: none; text-align: center;"> + <img src="<?php echo RP ?>img/ajax-loader.gif"> + </div> + + <div id="dynamic-product"></div> + + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Κλείσιμο</button> + </div> + + </div> + </div> + </div><!-- /product-modal --> + + <!-- store-modal --> + <div id="view-store" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="store-title" aria-hidden="true" style="display: none; z-index: 2000;"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h4 class="modal-title"> + <i class="glyphicon glyphicon-shopping-cart"></i> Πληροφορίες Καταστήματος + </h4> + </div> + <div class="modal-body"> + <div id="mapCanvas" style="height: 300px"></div> + <div id="modal-loader-store" style="display: none; text-align: center;"> + <img src="<?php echo RP ?>img/ajax-loader.gif"> + </div> + <div id="dynamic-content"></div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Κλείσιμο</button> + </div> + </div> + </div> + </div><!-- /store-modal --> + + <script src="/wiki/js/wiki.js"></script> + <script src="/wiki/js/post-features.js"></script> +</body> +</html> |
