Merge branch 'hendrik-post' into 'master'
Hendrik post See merge request !122
This commit was merged in pull request #126.
This commit is contained in:
12
website/public/API/loadPost.php
Normal file
12
website/public/API/loadPost.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/post.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/nicetime.php");
|
||||
|
||||
if(isset($_GET['postID'])) {
|
||||
include("../../views/post-view.php");
|
||||
} else {
|
||||
echo "Failed to load";
|
||||
}
|
||||
@@ -1,5 +1,30 @@
|
||||
margin = 20;
|
||||
|
||||
// scrolling modal taken from http://stackoverflow.com/questions/10476632/how-to-scroll-the-page-when-a-modal-dialog-is-longer-than-the-screen
|
||||
function scrollbarMargin(width, overflow) {
|
||||
$('body').css({
|
||||
marginRight: width,
|
||||
overflow: overflow
|
||||
});
|
||||
$('.profile-menu').css({
|
||||
marginRight: width
|
||||
});
|
||||
}
|
||||
|
||||
function requestPost(post) {
|
||||
$(".modal").show();
|
||||
$.get(
|
||||
"API/loadPost.php",
|
||||
$(post).children("form").serialize()
|
||||
).done(function (data) {
|
||||
$('.modal-default').hide();
|
||||
var scrollBarWidth = window.innerWidth - document.body.offsetWidth;
|
||||
scrollbarMargin(scrollBarWidth, 'hidden');
|
||||
$('#modal-response').show();
|
||||
$('#modal-response').html(data);
|
||||
});
|
||||
}
|
||||
|
||||
$(window).on("load", function() {
|
||||
console.log("LOADED");
|
||||
container = $("div.posts");
|
||||
@@ -69,8 +94,14 @@ function mansonry() {
|
||||
column = $('<div class="column"></div>').append(columns[i][1]);
|
||||
console.log(column);
|
||||
container.append(column);
|
||||
|
||||
}
|
||||
|
||||
$("div.posts div.column").width(100/columnCount + "%");
|
||||
|
||||
$(".modal-close").click(function () {
|
||||
$(".modal").hide();
|
||||
scrollbarMargin(0, 'auto');
|
||||
$('#modal-response').hide();
|
||||
$('.modal-default').show();
|
||||
});
|
||||
}
|
||||
8
website/public/js/profile.js
Normal file
8
website/public/js/profile.js
Normal file
@@ -0,0 +1,8 @@
|
||||
function loadPost(postID) {
|
||||
$.get(
|
||||
"API/loadPost.php",
|
||||
$(postID).serialize()
|
||||
).done(function (data) {
|
||||
$('#modal-response').innerHTML= JSON.parse(data);
|
||||
});
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<script src="/js/masonry.js"></script>
|
||||
<script src="js/masonry.js"></script>
|
||||
<!-- <script src="js/profile.js"></script>-->
|
||||
<style>
|
||||
@import url("styles/profile.css");
|
||||
@import url("styles/post-popup.css");
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -12,6 +14,7 @@
|
||||
include("../queries/user.php");
|
||||
include("../queries/friendship.php");
|
||||
include("../queries/nicetime.php");
|
||||
include("../queries/post.php");
|
||||
|
||||
if(empty($_GET["username"])) {
|
||||
$userID = $_SESSION["userID"];
|
||||
|
||||
72
website/public/styles/post-popup.css
Normal file
72
website/public/styles/post-popup.css
Normal file
@@ -0,0 +1,72 @@
|
||||
/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 80px;
|
||||
left: 256px;
|
||||
width: calc(100% - 256px); /* Full width */
|
||||
height: calc(100% - 80px); /* Full height */
|
||||
background-color: rgb(0,0,0); /* Fallback color */
|
||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Modal Content/Box */
|
||||
.modal-content {
|
||||
margin: 5% auto;
|
||||
width: 70%; /* Could be more or less, depending on screen size */
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.modal-close:hover,
|
||||
.modal-close:focus {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-content img {
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.post-header h4 {
|
||||
font-size: 20pt;
|
||||
}
|
||||
|
||||
.post-content {
|
||||
margin: 30px auto;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.commentfield {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.commentfield textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.comment {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-top: 1px solid #4CAF50;
|
||||
}
|
||||
|
||||
.commentinfo {
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
.commentcontent {
|
||||
margin: 5px auto;
|
||||
width: 95%;
|
||||
}
|
||||
@@ -25,5 +25,5 @@
|
||||
}
|
||||
|
||||
li.search-item:hover{
|
||||
background-color: #EEE;
|
||||
background-color: #FBC02D;
|
||||
}
|
||||
97
website/queries/post.php
Normal file
97
website/queries/post.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
function selectPostById($postID) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`user`.`fname`,
|
||||
`user`.`lname`,
|
||||
`user`.`username`,
|
||||
`post`.`groupID`,
|
||||
`post`.`title`,
|
||||
`post`.`content`,
|
||||
`post`.`creationdate`
|
||||
FROM
|
||||
`post`
|
||||
INNER JOIN
|
||||
`user`
|
||||
ON
|
||||
`post`.`author` = `user`. `userID`
|
||||
WHERE
|
||||
`post`.`postID` = :postID
|
||||
");
|
||||
|
||||
$stmt->bindParam(':postID', $postID);
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function selectCommentsByPostId($postID) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`comment`.`commentID`,
|
||||
`comment`.`postID`,
|
||||
`comment`.`author`,
|
||||
`comment`.`content`,
|
||||
`comment`.`creationdate`,
|
||||
`user`.`fname`,
|
||||
`user`.`lname`,
|
||||
`user`.`username`
|
||||
FROM
|
||||
`comment`
|
||||
INNER JOIN
|
||||
`user`
|
||||
ON
|
||||
`comment`.`author` = `user`.`userID`
|
||||
WHERE
|
||||
`comment`.`postID` = :postID
|
||||
");
|
||||
|
||||
$stmt->bindParam(':postID', $postID);
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function makePost($userID, $groupID, $title, $content) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
INSERT INTO
|
||||
`post` (
|
||||
`author`,
|
||||
`groupID`,
|
||||
`title`,
|
||||
`content`
|
||||
)
|
||||
VALUES (
|
||||
:userID,
|
||||
:groupID,
|
||||
:title,
|
||||
:content
|
||||
)
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID);
|
||||
$stmt->bindParam(':groupID', $groupID);
|
||||
$stmt->bindParam(':title', $title);
|
||||
$stmt->bindParam(':content', $content);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function makeComment($postID, $userID, $content) {
|
||||
$stmt = $_GLOBAL["db"]->prepare("
|
||||
INSERT INTO
|
||||
`comment` (
|
||||
`postID`,
|
||||
`author`,
|
||||
`content`
|
||||
)
|
||||
VALUES (
|
||||
:postID,
|
||||
:userID,
|
||||
:content
|
||||
)
|
||||
");
|
||||
|
||||
$stmt->bindParam(':postID', $postID);
|
||||
$stmt->bindParam(':userID', $userID);
|
||||
$stmt->bindParam(':content', $content);
|
||||
$stmt->execute();
|
||||
}
|
||||
@@ -321,7 +321,10 @@ function searchSomeUsers($n, $m, $search)
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`username`,
|
||||
`profilepicture`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/notbad.jpg'
|
||||
) AS profilepicture,
|
||||
`fname`,
|
||||
`lname`
|
||||
FROM
|
||||
|
||||
52
website/views/post-view.php
Normal file
52
website/views/post-view.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$postID = $_GET['postID'];
|
||||
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
|
||||
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
|
||||
|
||||
echo("
|
||||
<div class='post-header header'>
|
||||
<h4>" . $post['title'] . "</h4>
|
||||
<span class='postinfo'>
|
||||
gepost door $fullname,
|
||||
<span class='posttime' title='" . $post['creationdate'] . "'>
|
||||
" . nicetime($post['creationdate']) . "
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class='post-content'>
|
||||
<p>" . $post['content'] . "</p>
|
||||
</div>
|
||||
"); ?>
|
||||
|
||||
<div class='post-comments'>
|
||||
<div class="commentfield">
|
||||
<form name="newcomment" method="post">
|
||||
<textarea placeholder="Laat een reactie achter..."></textarea> <br>
|
||||
<input type="submit" value="Reageer!">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$q = selectCommentsByPostId($postID);
|
||||
while($comment = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
$commentauthor = $comment['fname'] . " " . $comment['lname'] . " (" . $comment['username'] . ")";
|
||||
$commentdate = $comment['creationdate'];
|
||||
$commentnicetime = nicetime($commentdate);
|
||||
$commentcontent = $comment['content'];
|
||||
|
||||
echo("
|
||||
<div class='comment'>
|
||||
<div class='commentinfo'>
|
||||
$commentauthor
|
||||
<span class='commentdate', title='$commentdate'>
|
||||
$commentnicetime
|
||||
</span>
|
||||
</div>
|
||||
<div class='commentcontent'>
|
||||
$commentcontent
|
||||
</div>
|
||||
</div>
|
||||
");
|
||||
} ?>
|
||||
</div>
|
||||
@@ -58,14 +58,32 @@
|
||||
|
||||
while($post = $posts->fetch()) {
|
||||
$nicetime = nicetime($post["creationdate"]);
|
||||
$postID = $post["postID"];
|
||||
echo "
|
||||
<div class='post platform'>
|
||||
<div class='post platform' onclick='requestPost(this)'>
|
||||
<h2>${post["title"]}</h2>
|
||||
<p>${post["content"]}</p>
|
||||
<p class=\"subscript\">${nicetime} geplaatst.</p>
|
||||
<p class=\"subscript\" title='" . $post["creationdate"] ."'>${nicetime} geplaatst.</p>
|
||||
<form>
|
||||
<input type='hidden'
|
||||
name='postID'
|
||||
value='$postID'
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="modal">
|
||||
<div class="modal-content platform">
|
||||
<div class="modal-close">
|
||||
×
|
||||
</div>
|
||||
<div class="modal-response" id="modal-response">
|
||||
<span class="modal-default">Aan het laden...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -38,7 +38,7 @@ $group_count = countSomeGroups($search)->fetchColumn();
|
||||
</label>
|
||||
<input type="text"
|
||||
name="search"
|
||||
placeholder="zoek"
|
||||
placeholder="Zoek"
|
||||
value=<?php echo "$search";?>
|
||||
>
|
||||
<label for="filter">
|
||||
|
||||
Reference in New Issue
Block a user