Database refactoring and improving blog comments, blog post history and more
This commit is contained in:
@@ -5,41 +5,44 @@
|
||||
|
||||
?>
|
||||
|
||||
<div class="col-sm-8 col-sm-pull-4">
|
||||
<div class="col-lg-8 order-lg-first">
|
||||
<div class="like-toggle-icon-container floating">
|
||||
<button class="like-toggle-icon <?= $hasLiked ? '-checked' : '' ?>" title="❤ Toggle Like!" onclick="likeDislike(<?= $postID ?>)"></button>
|
||||
<button class="like-toggle-icon <?= $hasLiked ? '-checked' : '' ?>" title="❤ Toggle Like!" onclick="likeDislike(<?= $ID ?>)"></button>
|
||||
<span class="like-count"><?= $likeCount ?></span>
|
||||
</div>
|
||||
|
||||
<div class="blog">
|
||||
<div class="blog-item">
|
||||
<?php if ($postIsDeleted): ?>
|
||||
<?php // TODO: Add notice if post was deleted
|
||||
if (false): ?>
|
||||
<h2 class="text-error">
|
||||
<i class="fa fa-warning"></i>
|
||||
</h2>
|
||||
<?php else: ?>
|
||||
<?php if ($postImage != '') { ?>
|
||||
<img class="img-fluid img-blog" src="<?= $postImage; ?>?w=800" width="100%" alt="" />
|
||||
<?php if ($image != '') { ?>
|
||||
<img class="img-fluid img-blog" src="<?= $image; ?>?w=800" width="100%" alt="" />
|
||||
<?php } ?>
|
||||
<div class="blog-content">
|
||||
<div class="entry-meta">
|
||||
<span>
|
||||
<a href="<?= base_url('user/' . $postAuthorUsername) ?>">
|
||||
<a href="<?= base_url('user/' . $author['username']) ?>">
|
||||
<i class="far fa-user"></i>
|
||||
<?= $postAuthorDisplayname ?>
|
||||
<?= $author['displayname'] ?>
|
||||
</a>
|
||||
</span>
|
||||
<?php
|
||||
$publishDate = strtotime($postPublishDate);
|
||||
$lastEdit = strtotime($postLastEdit);
|
||||
$initialRelease = strtotime($initialRelease);
|
||||
if (isset($lastEdit)) {
|
||||
$lastEdit = strtotime($lastEdit);
|
||||
}
|
||||
?>
|
||||
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?= strftime("%d. %B %Y", $publishDate) ?>">
|
||||
title="<?= strftime("%d. %B %Y", $initialRelease) ?>">
|
||||
<i class="far fa-calendar"></i>
|
||||
<?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$publishDate"), $_SESSION['site_lang']) ?>
|
||||
<?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$initialRelease"), $_SESSION['site_lang']) ?>
|
||||
</span>
|
||||
|
||||
<?php if (isset($postLastEdit) && $postLastEdit !== null): ?>
|
||||
<?php if (isset($lastEdit) && $lastEdit !== null): ?>
|
||||
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom"
|
||||
title="<?= strftime("%d. %B %Y", $lastEdit) ?>">
|
||||
<i class="far fa-edit"></i>
|
||||
@@ -47,16 +50,9 @@
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<span>
|
||||
<a href="<?= base_url('blog/category/' . $categoryName) ?>">
|
||||
<i class="far fa-folder-open"></i>
|
||||
<?= lang('blog_category_' . $categoryName) != '' ? lang('blog_category_' . $categoryName) : $categoryDisplayName ?>
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom" title="<?= lang('blog_approximate_reading_time') ?>">
|
||||
<i class="far fa-clock"></i>
|
||||
<?= $this->BlogModel->getReadingTime($postID) ?> min
|
||||
<?= $this->BlogModel->getReadingTime($wordCount) ?> min
|
||||
</span>
|
||||
|
||||
<span>
|
||||
@@ -67,40 +63,60 @@
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<a href="#" style="cursor:pointer" onclick="likeDislike(<?= $postID ?>)">
|
||||
<a href="#" style="cursor:pointer" onclick="likeDislike(<?= $ID ?>)">
|
||||
<i class="far fa-heart"></i>
|
||||
<span class="like-count"><?= $likeCount ?></span>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
<h1 class="post-title"><?= $postTitle ?></h1>
|
||||
<h2 class="post-subtitle"><?= $postDesc ?></h2>
|
||||
<h1 class="post-title"><?= $title ?></h1>
|
||||
<h2 class="post-subtitle"><?= $description ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<div class="blog-post">
|
||||
<?= isset($postContent) ? $postContent : "" ?>
|
||||
<?= isset($content) ? $content : "" ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<h3>
|
||||
<i class="far fa-folder-open"></i>
|
||||
Kategorien
|
||||
</h3>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<a href="<?= base_url('blog/category/' . $category['name']) ?>">
|
||||
<span class="badge badge-primary">
|
||||
<?= lang('blog_category_' . $category['name']) != '' ? lang('blog_category_' . $category['name']) : $category['displayname'] ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<h3>
|
||||
<i class="fa fa-tags"></i>
|
||||
Tags
|
||||
</h3>
|
||||
<div class="tags">
|
||||
<?php foreach ($tags as $tag) { ?>
|
||||
<a href="<?= base_url('blog/tag/' . $tag['name']) ?>"><span
|
||||
class="label label-primary"><?= $tag['display_name'] ?></span>
|
||||
<a href="<?= base_url('blog/tag/' . $tag['name']) ?>">
|
||||
<span class="badge badge-primary"><?= $tag['displayname'] ?></span>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<h3>
|
||||
<i class="far fa-user"></i> <?= lang('blog_about') ?>
|
||||
</h3>
|
||||
@@ -108,11 +124,11 @@
|
||||
<?php
|
||||
$this->load->view('network/user/user_overview_card', [
|
||||
'noContainer' => true,
|
||||
'username' => $postAuthorUsername,
|
||||
'displayname' => $postAuthorDisplayname,
|
||||
'profile_picture' => $postAuthorProfilePicture,
|
||||
'header_image' => $postAuthorHeaderImage,
|
||||
'about' => $postAuthorAbout])
|
||||
'username' => $author['username'],
|
||||
'displayname' => $author['displayname'],
|
||||
'profilePicture' => $author['profilePicture'],
|
||||
'headerImage' => $author['headerImage'],
|
||||
'about' => $author['about']])
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -128,19 +144,19 @@
|
||||
<?php foreach ($randomPosts as $item) { ?>
|
||||
<div class="col-sm-4">
|
||||
<div class="card">
|
||||
<?php if ($item['postImage'] != ''): ?>
|
||||
<a href="<?= base_url('blog/post/' . $item['postUrl']) ?>">
|
||||
<img src="<?= $item['postImage'] ?>?w=200" alt="<?= $item['postTitle'] ?>" class="card-img-top">
|
||||
<?php if ($item['image'] != ''): ?>
|
||||
<a href="<?= base_url('blog/post/' . $item['url']) ?>">
|
||||
<img src="<?= $item['image'] ?>?w=200" alt="<?= $item['title'] ?>" class="card-img-top">
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<div class="card-body">
|
||||
<a href="<?= base_url('blog/post/' . $item['postUrl']) ?>">
|
||||
<h5 class="card-title"><?= $item['postTitle'] ?></h5>
|
||||
<a href="<?= base_url('blog/post/' . $item['url']) ?>">
|
||||
<h5 class="card-title"><?= $item['title'] ?></h5>
|
||||
</a>
|
||||
<small class="card-text">
|
||||
<i class="far fa-user"></i>
|
||||
<a href="<?= base_url('user/' . $item['postAuthorUsername']) ?>">
|
||||
<?= $item['postAuthorDisplayname'] ?>
|
||||
<a href="<?= base_url('user/' . $item['author']['username']) ?>">
|
||||
<?= $item['author']['displayname'] ?>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
@@ -152,20 +168,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<div class="container">
|
||||
<div id="comments">
|
||||
<h3>
|
||||
<i class="far fa-comments"></i> <?= lang('blog_comments') ?> (<span class="comment-count"><?= $commentCount; ?></span>)
|
||||
</h3>
|
||||
<ul class="comment-list" id="comment-list">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<div id="comment-form">
|
||||
@@ -196,35 +198,57 @@
|
||||
</div>
|
||||
<!--/#comments-->
|
||||
</div>
|
||||
<?php if (!empty($prevPost)):
|
||||
$prevPost = $prevPost[0]; ?>
|
||||
<div class="blog-item col-xs-6" style="width:calc(50% - 5px);">
|
||||
<a href="<?= base_url('blog/post/' . $prevPost['postUrl']) ?>">
|
||||
<div class="pull-left"
|
||||
style="background: url(<?= $prevPost['postImage'] ?>?w=150) center;background-size:cover;width:100px;height:100px;border-radius: 4px;margin:10px 0;"></div>
|
||||
<div class="float-right" style="width: calc(100% - 110px)">
|
||||
<h5>
|
||||
<i class="fa fa-arrow-left"></i> <?= lang('blog_previous_article') ?></h5>
|
||||
<h4 style="font-size:20px"><?= $prevPost['postTitle'] ?></h4>
|
||||
|
||||
<div class="blog-item">
|
||||
<div class="blog-content">
|
||||
<div class="container">
|
||||
<div id="comments">
|
||||
<h3>
|
||||
<i class="far fa-comments"></i> <?= lang('blog_comments') ?> (
|
||||
<span class="comment-count"><?= $commentCount; ?></span>
|
||||
)
|
||||
</h3>
|
||||
<ul class="comment-list" id="comment-list">
|
||||
</ul>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($nextPost)):
|
||||
$nextPost = $nextPost[0]; ?>
|
||||
<div class="blog-item col-xs-6 float-right" style="width:calc(50% - 5px);">
|
||||
<a href="<?= base_url('blog/post/' . $nextPost['postUrl']) ?>">
|
||||
<div class="float-right"
|
||||
style="background: url(<?= $nextPost['postImage'] ?>?w=150) center;background-size:cover;width:100px;height:100px;border-radius: 4px;margin:10px 0;"></div>
|
||||
<div class="pull-left" style="width: calc(100% - 110px);text-align:right;">
|
||||
<h5><?= lang('blog_next_article') ?>
|
||||
<i class="fa fa-arrow-right"></i>
|
||||
</h5>
|
||||
<h4 style="font-size:20px"><?= $nextPost['postTitle'] ?></h4>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php if (!empty($prevPost)):
|
||||
$prevPost = $prevPost[0]; ?>
|
||||
<div class="col-6">
|
||||
<div class="blog-item following-post left">
|
||||
<a href="<?= base_url('blog/post/' . $prevPost['url']) ?>">
|
||||
<div class="following-post-image"
|
||||
style="background-image: url(<?= $prevPost['image'] ?>?w=150)"></div>
|
||||
<div style="width: calc(100% - 110px);display: inline-block;margin:10px 0;">
|
||||
<h5>
|
||||
<i class="fa fa-arrow-left"></i> <?= lang('blog_previous_article') ?></h5>
|
||||
<h4 style="font-size:20px"><?= $prevPost['title'] ?></h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($nextPost)):
|
||||
$nextPost = $nextPost[0]; ?>
|
||||
<div class="col-6">
|
||||
<div class="blog-item following-post right">
|
||||
<a href="<?= base_url('blog/post/' . $nextPost['url']) ?>">
|
||||
<div class="following-post-image" style="background-image: url(<?= $nextPost['image'] ?>?w=150)"></div>
|
||||
<div style="width: calc(100% - 110px);text-align:right;display: inline-block;margin:10px 0;">
|
||||
<h5><?= lang('blog_next_article') ?>
|
||||
<i class="fa fa-arrow-right"></i>
|
||||
</h5>
|
||||
<h4 style="font-size:20px"><?= $nextPost['title'] ?></h4>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<!--/.blog-item-->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user