add post viewing basis, add insert post and comment queries
This commit is contained in:
@@ -73,4 +73,12 @@ function mansonry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("div.posts div.column").width(100/columnCount + "%");
|
$("div.posts div.column").width(100/columnCount + "%");
|
||||||
|
|
||||||
|
$(".post").click(function () {
|
||||||
|
$(".modal").show();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".modal-close").click(function () {
|
||||||
|
$(".modal").hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
0
website/public/js/profile.js
Normal file
0
website/public/js/profile.js
Normal file
@@ -2,9 +2,10 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<?php include("../views/head.php"); ?>
|
<?php include("../views/head.php"); ?>
|
||||||
<script src="/js/masonry.js"></script>
|
<script src="js/masonry.js"></script>
|
||||||
<style>
|
<style>
|
||||||
@import url("styles/profile.css");
|
@import url("styles/profile.css");
|
||||||
|
@import url("styles/post-popup.css");
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -12,6 +13,7 @@
|
|||||||
include("../queries/user.php");
|
include("../queries/user.php");
|
||||||
include("../queries/friendship.php");
|
include("../queries/friendship.php");
|
||||||
include("../queries/nicetime.php");
|
include("../queries/nicetime.php");
|
||||||
|
include("../queries/post.php");
|
||||||
|
|
||||||
if(empty($_GET["username"])) {
|
if(empty($_GET["username"])) {
|
||||||
$userID = $_SESSION["userID"];
|
$userID = $_SESSION["userID"];
|
||||||
|
|||||||
38
website/public/styles/post-popup.css
Normal file
38
website/public/styles/post-popup.css
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
/*display: none; !* Hidden by default *!*/
|
||||||
|
position: fixed; /* Stay in place */
|
||||||
|
z-index: 1; /* Sit on top */
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: calc(100% - 256px); /* Full width */
|
||||||
|
height: calc(100% - 80px); /* Full height */
|
||||||
|
overflow: visible; /* Enable scroll if needed */
|
||||||
|
background-color: rgb(0,0,0); /* Fallback color */
|
||||||
|
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Modal Content/Box */
|
||||||
|
.modal-content {
|
||||||
|
background-color: #fefefe;
|
||||||
|
margin: 15% auto; /* 15% from the top and centered */
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid #888;
|
||||||
|
width: 80%; /* Could be more or less, depending on screen size */
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
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();
|
||||||
|
}
|
||||||
53
website/views/post-view.php
Normal file
53
website/views/post-view.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
// $postID = $_GET['postID'];
|
||||||
|
$postID = 1;
|
||||||
|
$post = selectPostById($postID)->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="post-header">
|
||||||
|
<h4><?php echo $post['title'];?></h4>
|
||||||
|
<span class="postinfo">
|
||||||
|
gepost door <?php echo $fullname;?>,
|
||||||
|
<span class="posttime" title="<?php echo $post['creationdate']?>">
|
||||||
|
<?php echo nicetime($post['creationdate']); ?>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="post-content">
|
||||||
|
<p><?php echo $post['content']; ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="post-comments">
|
||||||
|
<div class="commentfield">
|
||||||
|
<form name="newcomment" method="post">
|
||||||
|
<textarea>Vul in</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>
|
||||||
@@ -66,4 +66,13 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal content">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-close">
|
||||||
|
×
|
||||||
|
</div>
|
||||||
|
<?php include("../views/post-view.php"); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user