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

@@ -3,22 +3,22 @@ defined('BASEPATH') OR exit('No direct script access allowed');
?>
<li class="blog-post-item">
<div class="well comment-well">
<a href="<?= base_url('blog/post/' . $post['postUrl']) ?>" target="_blank">
<div class="entry-image" style="background-image:url(<?= $post['postImage'] ?>?w=150"></div>
<a href="<?= base_url('blog/post/' . $post['url']) ?>" target="_blank">
<div class="entry-image" style="background-image:url(<?= $post['image'] ?>?w=150"></div>
</a>
<div class="content">
<h3>
<a href="<?= base_url('blog/post/' . $post['postUrl']) ?>" target="_blank">
<?= $post['postTitle'] ?>
<a href="<?= base_url('blog/post/' . $post['url']) ?>" target="_blank">
<?= $post['title'] ?>
</a>
<small><?= lang('person_by') ?> <a
href="<?= base_url('user/' . $data['username']) ?>"
target="_blank"><?= $data['displayname'] ?></a>
/ <?= date(lang('date'), strtotime($post['postPublishDate'])) ?>
/ <?= date(lang('date'), strtotime($post['initialRelease'])) ?>
</small>
</h3>
<p class="comment"><?= $post['postDesc'] ?></p>
<p class="comment"><?= $post['description'] ?></p>
</div>
</div>
</li>

View File

@@ -1,47 +1,64 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Coduo\PHPHumanizer\DateTimeHumanizer;
defined('BASEPATH') OR exit('No direct script access allowed');
use Coduo\PHPHumanizer\DateTimeHumanizer;
?>
<li>
<div class="well comment-well">
<div class="post-non-content">
<a href="<?= base_url('user/' . $data['username']) ?>" target="_blank">
<img src="<?= $data['profile_picture'] ?>?w=100" class="img-fluid">
<li id="comment-<?= $c['ID'] ?>">
<div class="user-post-item">
<a href="<?= base_url('user/' . $data['username']) ?>" class="item-avatar-container">
<img src="<?= $data['profilePicture'] ?>?w=100" alt="<?= $data['username'] ?>" class="item-avatar">
</a>
<h3 class="item-user">
<a href="<?= base_url('user/' . $data['username']) ?>">
<?= $data['displayname'] ?>
</a>
</div>
<div class="content-container">
<div class="content">
<h3>
<a href="<?= base_url('user/' . $data['username']) ?>" target="_blank">
<?= $data['displayname'] ?>
</h3>
<h4 class="item-meta">
<?php
$locale = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'en';
$dateCreated = strtotime($c['date']);
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $locale);
?>
<?php if (isset($c['url'])): ?>
unter
<a href="<?= base_url('blog/post/' . $c['url']) ?>">
<?= $c['title'] ?>
</a>
<?php endif; ?>
</h4>
<p class="item-content">
<?= $c['comment'] ?>
</p>
<?php if(!isset($hideActionBtns) || $hideActionBtns == false): ?>
<div class="item-actions">
<a href="#" class="item-btn" data-toggle="tooltip" data-placement="top" title="Antworten">
<i class="far fa-comment"></i>
<span>0</span>
</a>
<a href="#" class="item-btn" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
<i class="far fa-heart"></i>
<span>0</span>
</a>
<div class="item-btn dropdown">
<a href="#" class="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</a>
<div class="dropdown-menu">
<a onclick="openCommentReportModal(<?= $c['ID'] ?>)" class="dropdown-item">
<i class="fa fa-flag"></i>
Kommentar melden
</a>
<small>
<?php
$locale = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'en';
$date_created = strtotime($c['date_created']);
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $locale);
?>
unter
<a href="<?= base_url('blog/post/' . $c['postUrl']) ?>">
<?= $c['postTitle'] ?>
<?php if(isset($_SESSION['user']) && $_SESSION['user']['username'] == $data['username']): ?>
<div class="dropdown-divider"></div>
<a onclick="openCommentDeleteModal(<?= $c['ID'] ?>)" class="dropdown-item text-danger">
<i class="fa fa-trash"></i>
Kommentar löschen
</a>
</small>
</h3>
<p class="comment"><?= $c['comment'] ?></p>
<?php endif; ?>
</div>
</div>
</div>
<div class="action-btns">
<a href="#" class="action-btn" data-toggle="tooltip" data-placement="top" title="Antworten">
<i class="far fa-comment"></i>
</a>
<a href="#" class="action-btn" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
<i class="far fa-heart"></i>
</a>
<a href="#" class="action-btn" data-toggle="tooltip" data-placement="top" title="Mehr Optionen">
<i class="fa fa-ellipsis-h"></i>
</a>
</div>
<?php endif; ?>
</div>
</li>
</li>

View File

@@ -15,7 +15,7 @@
<button type="reset" class="btn btn-sm btn-primary round float-right" data-dismiss="modal">
Nein, Post behalten
</button>
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deletePost('<?= $post['uuid'] ?>')">
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deletePost('<?= $post['hashID'] ?>')">
Ja, endgültig löschen
</button>
</form>

View File

@@ -4,11 +4,11 @@
use Coduo\PHPHumanizer\DateTimeHumanizer;
?>
<li class="post-item is-reply% my-2" data-uuid="<?= $uuid ?>" data-username="<?= $username ?>">
<li class="post-item is-reply% my-2" data-uuid="<?= $hashID ?>" data-username="<?= $username ?>">
<div class="comment-well" <?= isset($hideShadows) && $hideShadows ? 'style="box-shadow: none;padding:0"' : '' ?>>
<div class="post-non-content">
<a href="<?= base_url('user/' . $username) ?>" target="_blank">
<img src="<?= $profile_picture ?>?w=100" class="img-fluid">
<img src="<?= $profilePicture ?>?w=100" class="img-fluid">
</a>
</div>
<div class="content-container">
@@ -18,13 +18,13 @@
<?= $displayname ?>
</a>
<small><?php
$date_created = strtotime($date);
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']); ?></small>
<?php if ($reply_to != NULL): ?>
$dateCreated = strtotime($date);
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']); ?></small>
<?php if ($replyToPostID != NULL): ?>
<small>
<i class="fa fa-reply"></i>
<?= lang('post_reply_to') ?>
<a href="#" onclick="showFullPost('<?= $replyToPost['uuid'] ?>', '<?= $replyToPost['username'] ?>')">@<?= $replyToPost['displayname'] ?></a>
<a href="#" onclick="showFullPost('<?= $replyToPost['hashID'] ?>', '<?= $replyToPost['username'] ?>')">@<?= $replyToPost['displayname'] ?></a>
</small>
<?php endif; ?>
</h3>
@@ -80,31 +80,31 @@
</div>
<?php if (!isset($hideActionBtns) || !$hideActionBtns): ?>
<div class="action-btns">
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="<?= lang('post_reply') ?>">
<a href="#" data-uuid="<?= $hashID ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="<?= lang('post_reply') ?>">
<i class="far fa-comment"></i>
<span><?= $replyCount ?></span>
</a>
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn like-button <?= isset($userHasLiked) && $userHasLiked ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="<?= lang('post_like') ?>">
<a href="#" data-uuid="<?= $hashID ?>" class="action-btn like-button <?= isset($userHasLiked) && $userHasLiked ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="<?= lang('post_like') ?>">
<i class="<?= isset($userHasLiked) && $userHasLiked ? 'fas' : 'far' ?> fa-heart"></i>
<span><?= $likeCount ?></span>
</a>
<div class="action-btn dropdown">
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $uuid ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $hashID ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</a>
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $uuid ?>">
<a href="#" onclick="copyToClipboard('<?= base_url('user/' . $username . '/post/' . $uuid) ?>')" class="dropdown-item">
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $hashID ?>">
<a href="#" onclick="copyToClipboard('<?= base_url('user/' . $username . '/post/' . $hashID) ?>')" class="dropdown-item">
<i class="fa fa-copy"></i>
<?= lang('post_copy_link') ?>
</a>
<a href="#" onclick="openPostReportModal('<?= $uuid ?>')" class="dropdown-item">
<a href="#" onclick="openPostReportModal('<?= $hashID ?>')" class="dropdown-item">
<i class="fa fa-flag"></i>
<?= lang('post_report') ?>
</a>
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $username): ?>
<div class="dropdown-divider"></div>
<a href="#" onclick="openDeletePostModal('<?= $uuid ?>')" class="dropdown-item text-danger">
<a href="#" onclick="openDeletePostModal('<?= $hashID ?>')" class="dropdown-item text-danger">
<i class="fa fa-trash"></i>
<?= lang('post_delete') ?>
</a>

View File

@@ -5,21 +5,21 @@
?>
<?= $message; ?>
<div class="row justify-content-center">
<ul class="comment-list">
<?php
$post['replyToPost']['hideShadows'] = true;
$this->load->view('network/posts/post_item', $post['replyToPost'])
?>
</ul>
</div>
<?php if (isset($post['replyToPost'])): ?>
<div class="row justify-content-center">
<ul class="comment-list">
<?php
$post['replyToPost']['hideShadows'] = true;
$this->load->view('network/posts/post_item', $post['replyToPost'])
?>
</ul>
</div>
<?php endif; ?>
<div class="row">
<div class="post-non-content">
<a href="<?= base_url('user/' . $post['username']) ?>">
<img src="<?= $post['profile_picture'] ?>?w=75" alt="" class="img-fluid rounded-circle">
<img src="<?= $post['profilePicture'] ?>?w=75" alt="" class="img-fluid rounded-circle">
</a>
</div>
@@ -29,8 +29,8 @@
<?= $post['displayname'] ?>
</a>
<?php
$date_created = strtotime($post['date']);
$time_passed = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
$dateCreated = strtotime($post['date']);
$time_passed = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
?>
<small>
<?= $time_passed ?>
@@ -51,20 +51,20 @@
<?php endif; ?>
<div class="action-btns">
<a href="#" data-uuid="<?= $post['uuid'] ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="Antworten">
<a href="#" data-uuid="<?= $post['hashID'] ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="Antworten">
<span><i class="far fa-comment"></i></span>
<?= $post['replyCount'] ?>
</a>
<a href="#" data-uuid="<?= $post['uuid'] ?>" class="action-btn like-button <?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
<a href="#" data-uuid="<?= $post['hashID'] ?>" class="action-btn like-button <?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
<i class="<?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'fas' : 'far' ?> fa-heart"></i>
<span><?= $post['likeCount'] ?></span>
</a>
<div class="dropdown d-inline-block">
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $post['uuid'] ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $post['hashID'] ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-h"></i>
</a>
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $post['uuid'] ?>">
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $post['hashID'] ?>">
<a href="#" class="dropdown-item">
<i class="fa fa-copy"></i>
Link zum Post kopieren

View File

@@ -49,8 +49,8 @@
<form method="post" enctype="multipart/form-data">
<!-- Username -->
<div class="form-group">
<label for="username">Nutzername</label>
<input name="username" id="username" class="form-control"
<label for="displayname">Nutzername</label>
<input name="displayname" id="displayname" class="form-control"
value="<?= isset($data['displayname']) ? $data['displayname'] : '' ?>">
<span class="error-message" id="usernameErrorLength">
<b>Dein Nutzername ist zu kurz!</b> Er muss mindestens 4 Zeichen lang sein
@@ -1093,26 +1093,24 @@
</div>
<!-- Bio -->
<div class="form-group">
<label for="biography">Profilbeschreibung/Biographie</label>
<textarea class="form-control" name="biography" id="biography">
<?= isset($data['about']) ? $data['about'] : "" ?>
</textarea>
<label for="about">Profilbeschreibung/Biographie</label>
<textarea class="form-control" name="about" id="about"><?= isset($data['about']) ? $data['about'] : "" ?></textarea>
</div>
<!-- Avatar -->
<div class="form-group">
<label for="avatar">Avatar</label>
<?php if (isset($data['profile_picture']) || $data['profile_picture'] != ""): ?>
<?php if (isset($data['profilePicture']) || $data['profilePicture'] != ""): ?>
<img class="img-fluid img-thumbnail picture-preview d-block"
src="<?= $data['profile_picture'] ?>">
src="<?= $data['profilePicture'] ?>">
<?php endif; ?>
<input type="file" name="avatar" id="avatar">
</div>
<!-- Header -->
<div class="form-group">
<label for="header">Header</label>
<?php if (isset($data['header_image']) || $data['header_image'] != ""): ?>
<?php if (isset($data['headerImage']) || $data['headerImage'] != ""): ?>
<img class="img-fluid img-thumbnail picture-preview d-block"
src="<?= $data['header_image'] ?>">
src="<?= $data['headerImage'] ?>">
<?php endif; ?>
<input type="file" name="header" id="header">
</div>

View File

@@ -2,14 +2,14 @@
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<section id="profile-header" class="container-fluid" data-type="background" data-speed="2.14"
style="background-image: url('<?= $data['header_image'] ?>?w=1920')">
style="background-image: url('<?= $data['headerImage'] ?>?w=1920')">
</section>
<div id="scroll-trigger"></div>
<section id="profile-sub-header" data-type="foreground" data-speed="10">
<div class="container">
<div class="row">
<div class="col-xs-3 col-sm-2 col-md-4 col-lg-4 profile-card profile-picture-container">
<img src="<?= $data['profile_picture'] ?>?w=300" class="img-fluid rounded-circle profile-picture">
<img src="<?= $data['profilePicture'] ?>?w=300" class="img-fluid rounded-circle profile-picture">
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $data['username']): ?>
<div class="avatar-upload-overlay">
<i class="fa fa-upload"></i>

View File

@@ -7,8 +7,8 @@ $dateFollowing = strtotime($data['followedSince']);
?>
<li>
<a href="<?= base_url('user/' . $data['username']) ?>">
<div style="background-image: url(<?= $data['header_image'] ?>)" class="header-image"></div>
<img src="<?= $data['profile_picture'] ?>" alt="" class="img-fluid rounded-circle profile-picture">
<div style="background-image: url(<?= $data['headerImage'] ?>)" class="header-image"></div>
<img src="<?= $data['profilePicture'] ?>" alt="" class="img-fluid rounded-circle profile-picture">
<div class="user-card-content">
<h3><?= $data['displayname'] ?></h3>
<small><?= $data['followerCount'] ?> Follower | folgt

View File

@@ -6,10 +6,10 @@
<?php endif; ?>
<div class="card">
<a href="<?= base_url('user/' . $username) ?>">
<img src="<?= $header_image ?>?w=350" class="card-img-top" alt="Header Image">
<img src="<?= $headerImage ?>?w=350" class="card-img-top" alt="Header Image">
</a>
<a href="<?= base_url('user/' . $username) ?>">
<img src="<?= $profile_picture ?>?w=100" class="img-fluid rounded-circle card-profile-picture" alt="Profile Picture">
<img src="<?= $profilePicture ?>?w=100" class="img-fluid rounded-circle card-profile-picture" alt="Profile Picture">
</a>
<div class="card-body">
<a href="<?= base_url('user/' . $username) ?>">