-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoto.php
122 lines (77 loc) · 2.58 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php include "includes/header.php";?>
<?php require_once "admin/includes/init.php"?>
<?php
if (empty($_GET['id'])) {
redirect("index.php");
}
$photo = Photo::find_by_id($_GET['id']);
if (isset($_POST['submit'])) {
$author = trim($_POST['author']);
$body = trim($_POST['body']);
$new_comment = Comment::create_comment($photo->id, $author, $body);
if ($new_comment && $new_comment->save()) {
redirect("photo.php?id={$photo->id}");
} else {
$message = "There was some problems saving";
}
} else {
$author = "";
$body = "";
}
$comments = Comment::find_the_comments($photo->id);
?>
<div class="row">
<!-- Blog Post Content Column -->
<div class="col-lg-12">
<!-- Blog Post -->
<!-- Title -->
<h1><?php echo $photo->title; ?></h1>
<!-- Author -->
<p class="lead">
by <a href="#">Maulik</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->picture_path();?>" alt="">
<hr>
<!-- Post Content -->
<p class="lead">
<?php echo $photo->caption; ?></p>
<p><?php echo $photo->description;?></p>
<hr>
<!-- Blog Comments -->
<!-- Comments Form -->
<div class="well">
<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">
</div>
<div class="form-group">
<textarea name="body" 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; ?>
</h4>
<?php echo $comment->body; ?>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<?php include "includes/footer.php";?>