-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPost.php
More file actions
55 lines (48 loc) · 1.81 KB
/
Post.php
File metadata and controls
55 lines (48 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
//importing
require_once ("Models/PostGetter.php");
require_once ("Models/CommentGetter.php");
require_once ("Models/CommentHTMLGenerator.php");
require_once ("Models/CommentMaker.php");
session_start(); //makes session usable
//initialisation
$view = new stdClass(); //used to pass information between various pages and classes glued together
$view->pageTitle = 'Homepage';
$postGetter = new PostGetter();
$commentGetter = new CommentGetter();
//stops page forgetting post ID when page reloaded
if(isset($_GET["postID"]))
{
$_SESSION["postID"] = $_GET["postID"];
}
if(isset($_SESSION["postID"]))
{
$_GET["postID"] = $_SESSION["postID"];
}
//user submitting comment
if(isset($_POST["commentSubmit"])) //if user has submitted a comment
{
$commentMaker = new CommentMaker();
$parentID = $_POST["parentID"];
$commentorID = $_SESSION["userID"];
$content = $_POST["commentContent"];
if($_POST["commentType"] == "subComment") //comment is a reply to another comment
{
$commentMaker->commitCommentReply($parentID,$commentorID,$content);
}
elseif($_POST["commentType"] == "topLevel") //comment made directly under post
{
$commentMaker->commitPostComment($parentID,$commentorID,$content);
}
}
//page content
$post = $postGetter->getPost($_GET["postID"]); //gets Array of posts (only has one) and takes the one tuple from index 0
$view->post = $post;
//$view->comments = $commentGetter->getComments($_GET["postID"]);
$comments = $commentGetter->getComments($_GET["postID"]); //gets descendent comments of post from DB
CommentHTMLGenerator::generateCommentHTML($comments); //generates html and stores it in generator
$view->comments = commentHTMLGenerator::getHTML();
//var_dump($view->comments);
//var_dump($view->comments[0]->getChildren()[0]);
//glue
require_once ("Views/post.phtml");