Archived
1
0

Database refactoring and improving blog comments, blog post history and more

This commit is contained in:
Marcel
2019-01-08 22:42:54 +01:00
parent 56aed78b00
commit 7f887a99b0
67 changed files with 3076 additions and 1755 deletions

View File

@@ -5,7 +5,7 @@
<div class="well comment-well">
<div class="d-inline-block mr-2">
<a href="<?= base_url('user/' . $author['username']) ?>" target="_blank">
<img src="<?= $author['profile_picture'] ?>" alt="">
<img src="<?= $author['profilePicture'] ?>" alt="">
</a>
</div>
<div class="d-inline-block mr-2">
@@ -16,7 +16,7 @@
<?= $author['displayname'] ?>
</a>
/
<?= date('d.m.Y H:i \\U\\h\\r', strtotime($date_created)) ?></small>
<?= date('d.m.Y H:i \\U\\h\\r', strtotime($date)) ?></small>
</h3>
<p class="comment">
<?= $comment ?>

View File

@@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<form id="postDeleteForm">
<div class="alert alert-danger" role="alert">
<p>
<b>Bist du dir wirklich sicher, dass du deinen Kommentar löschen willst?</b>
</p>
<p>
<i>Diese Aktion kann nicht rückgängig gemacht werden!</i>
</p>
<ul class="comment-list" style="pointer-events: none">
<?php
$this->load->view('network/blog/comment_item', ['data' => $author, 'c' => $comment, 'hideActionBtns' => true]) ?>
</ul>
<!-- --><?php //var_dump($post) ?>
</div>
<button type="reset" class="btn btn-sm btn-primary round float-right" data-dismiss="modal">
Nein, Kommentar behalten
</button>
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deleteComment(<?= $comment['ID'] ?>)">
Ja, endgültig löschen
</button>
</form>

View File

@@ -5,7 +5,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<div class="container">
<div class="notice-container navbar-fixed-bottom"></div>
<div class="row">
<aside class="col-sm-4 col-sm-push-8">
<aside class="col-lg-4 order-lg-last">
<div class="widget search">
<form role="form" action="/blog/search">
<div class="input-group">
@@ -35,15 +35,15 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<?php foreach ($categoryPosts as $post) { ?>
<div class="media">
<div class="media-body">
<?php if (!empty($post['postImage'])): ?>
<a href="<?= base_url('blog/post/' . $post['postUrl']); ?>">
<img src="<?= $post['postImage']; ?>?w=300" class="img-fluid rounded post-image">
<?php if (!empty($post['image'])): ?>
<a href="<?= base_url('blog/post/' . $post['url']); ?>">
<img src="<?= $post['image']; ?>?w=300" class="img-fluid rounded post-image">
</a>
<?php endif; ?>
<div class="overlay">
<div class="media-heading">
<a href="<?= base_url('blog/post/' . $post['postUrl']); ?>">
<strong><?= $post['postTitle']; ?></strong>
<a href="<?= base_url('blog/post/' . $post['url']); ?>">
<strong><?= $post['title']; ?></strong>
</a>
</div>
</div>
@@ -58,7 +58,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<?php foreach ($categories as $category) { ?>
<li>
<a href="<?= base_url('blog/category/' . $category['name']) ?>">
<?= lang('blog_category_' . $category['name']) != '' ? lang('blog_category_' . $category['name']) : $category['display_name'] ?>
<?= lang('blog_category_' . $category['name']) != '' ? lang('blog_category_' . $category['name']) : $category['displayname'] ?>
</a>
</li>
<?php } ?>

View File

@@ -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>

View File

@@ -3,35 +3,40 @@
use Coduo\PHPHumanizer\DateTimeHumanizer;
$postPublishDate = strtotime($postPublishDate);
$initialRelease = strtotime($initialRelease);
?>
<div class="blog-item">
<?php if ($postImage != NULL && $postImage != ''): ?>
<a href="<?= base_url('blog/post/' . $postUrl) ?>">
<div class="img-blog-entry" style="background-image: url('<?= $postImage ?>?w=750');"></div>
<?php if ($image != NULL && $image != ''): ?>
<a href="<?= base_url('blog/post/' . $url) ?>">
<div class="img-blog-entry" style="background-image: url('<?= $image ?>?w=750');"></div>
</a>
<?php endif; ?>
<div class="blog-content">
<div class="entry-meta">
<span><a target="_blank" href="<?= base_url('user/' . $postAuthorUsername) ?>"><i class="fa fa-user"></i> <?= $postAuthorDisplayname ?></a></span>
<span><i class="fa fa-calendar"></i> <?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$postPublishDate"), $_SESSION['site_lang']) ?></span>
<span><a href="<?= base_url("blog/category/" . $categoryName) ?>"><i class="fa fa-folder-open"></i> <?= $categoryDisplayName ?></a></span>
<span><a target="_blank" href="<?= base_url('user/' . $author['username']) ?>"><i class="fa fa-user"></i> <?= $author['displayname'] ?></a></span>
<span><i class="fa fa-calendar"></i> <?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$initialRelease"), $_SESSION['site_lang']) ?></span>
<span>
<i class="fa fa-folder-open"></i>
<?php foreach ($categories as $category) { ?>
<a href="<?= base_url('blog/category/' . $category['name']) ?>"><?= $category['displayname'] ?></a>
<?php } ?>
</span>
<span style="cursor: pointer;" data-toggle="tooltip" data-placement="left" title="Geschätzte Lesedauer">
<i class="fa fa-clock"></i>
<?= $this->BlogModel->getReadingTime($postID) ?> min
<?= $this->BlogModel->getReadingTime($wordCount) ?> min
</span>
<span><a href="<?= base_url('blog/post/' . $postUrl . '#comments') ?>"><i class="fa fa-comment"></i> <?= $commentCount ?></a></span>
<span><a href="<?= base_url('blog/post/' . $url . '#comments') ?>"><i class="fa fa-comment"></i> <?= $commentCount ?></a></span>
<span><i class="fa fa-heart"></i> <?= $likeCount ?></span>
</div>
<a href="<?= base_url('blog/post/' . $postUrl) ?>">
<h3><?= $postTitle ?></h3>
<a href="<?= base_url('blog/post/' . $url) ?>">
<h3><?= $title ?></h3>
</a>
<div class="row">
<div class="col-md-9">
<p><?= $postDesc ?></p>
<p><?= $description ?></p>
</div>
<div class="col-md-3" style="padding:0">
<a class="btn btn-primary outline" href="<?= base_url('blog/post/' . $postUrl) ?>"><?= lang('blog_read') ?>
<a class="btn btn-primary outline" href="<?= base_url('blog/post/' . $url) ?>"><?= lang('blog_read') ?>
<i class="fa fa-angle-right"></i>
</a>
</div>

View File

@@ -2,7 +2,7 @@
?>
<div class="col-sm-8 col-sm-pull-4">
<div class="col-lg-8 order-lg-first">
<div class="blog">
<ul class="page-selection pagination-lg blog-pagination"></ul>
<div id="content">

View File

@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<form id="commentReportForm">
<div class="form-group">
<label for="commentReportReason">Grund für deine Meldung</label>
<select name="reason" id="commentReportReason" class="form-control" required>
<option value="">Bitte auswählen</option>
<option value="hatespeech">Hasserfüllte Inhalte</option>
<option value="racism">Rassistische, diskriminierende oder bewusst ausgrenzende Inhalte</option>
<option value="terrorism">Unterstützung von Terrorismus</option>
<option value="abuse">(Kindes-)Missbrauch</option>
<option value="violence">Gewaltverherrlichende Inhalte</option>
<option value="copyright">Verletzung meiner (Urheber-)Rechte</option>
<option value="spam">Spam oder irreführende Inhalte</option>
<option value="technical-issue">Technische Fehler</option>
</select>
</div>
<div class="form-group">
<label for="commentReportText">Weitere Anmerkungen (optional)</label>
<textarea name="reportText" id="commentReportText" class="form-control"></textarea>
</div>
<button type="submit" class="btn btn-primary float-right">
Absenden
</button>
</form>