-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoto.php
88 lines (80 loc) · 3.03 KB
/
photo.php
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php require_once("admin/includes/init.php"); ?>
<?php
if(empty($_GET['photo_id']))
{
redirect("index.php");
}
$photo = Photo::find_by_id($_GET['photo_id']);
$message = "";
if(isset($_POST['submit']))
{
$author = trim($_POST['author']);
$content = trim($_POST['content']);
$new_comment = Comment::create_comment($photo->id, $author, $content);
if($new_comment && $new_comment->save())
{
redirect("photo.php?photo_id={$photo->id}");
}
else
{
$message = "There was a problem saving the comment";
$author = "";
$content = "";
}
}
$comments = Comment::find_the_comments($photo->id);
?>
<?php include("includes/header.php"); ?>
<div class="row">
<div class="col-lg-12">
<h1><?php echo $photo->photo_title; ?></h1>
<!-- Author -->
<p class="lead">
by <a href="#">Hanne Digital</a>
</p>
<hr>
<!-- Date/Time -->
<p><span class="glyphicon glyphicon-time"></span> Posted on August 24, 2013 at 9:00 PM</p>
<hr>
<!-- Preview Image -->
<img class="img-responsive" src="admin/<?php echo $photo->image_path(); ?>" alt="">
<hr>
<!-- Post Content -->
<p class="lead"><?php echo $photo->photo_caption; ?></p>
<p><?php echo $photo->photo_description; ?></p>
<hr>
<!-- Comments Form -->
<div class="well">
<?php echo $message; ?>
<h4>Leave a Comment:</h4>
<form role="form" method="post">
<div class="form-group">
<label for="author">Author</label>
<input type="text" name="author" class="form-control" rows="3">
</div>
<div class="form-group">
<label for="content">Comment</label>
<textarea name="content" class="form-control" rows="3"></textarea>
</div>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<hr>
<!-- Posted Comments -->
<?php foreach($comments as $comment) : ?>
<!-- Comment -->
<div class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/64x64" alt="">
</a>
<div class="media-body">
<h4 class="media-heading"><?php echo $comment->author; ?>
<small>August 25, 2014 at 9:30 PM</small>
</h4>
<?php echo $comment->content?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php include("includes/footer.php"); ?>