-
Notifications
You must be signed in to change notification settings - Fork 0
/
photo.php
147 lines (106 loc) · 4.13 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php include("includes/header.php"); ?>
<?php
require_once("admin/includes/init.php");
if(empty($_GET['id']))
{
header("Location: 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())
{
header("Location: photo.php?id={$photo->id}");
} else {
$message = "There was some problem saving";
}
} else {
$author = "";
$body = "";
}
$comments = Comment::find_the_comments($photo->id);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Blog Post - Start Bootstrap Template</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/blog-post.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Page Content -->
<div class="container">
<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="#"> </a>
</p> -->
<hr>
<!-- Date/Time -->
<!-- <p><span class="glyphicon glyphicon-time"></span> Posted on August 24, 2013 at 9:00 PM</p> -->
<!-- Preview Image -->
<img class="img-responsive" width="100%" src=" admin/<?php echo $photo->photo_path(); ?>" alt="">
<!-- 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>Author</label>
<input type="text" class="form-control" name="author">
</div>
<div class="form-group">
<textarea class="form-control" name="body" rows="3"></textarea>
</div>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<hr>
<!-- Posted Comments -->
<!-- Comment -->
<?php foreach($comments as $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 class="col-md-4"> -->
<?php //include("includes/sidebar.php"); ?>
</div>
<!-- </div> -->
</div>
<!-- Blog Sidebar Widgets Column -->
<!-- /.row -->
<?php include("includes/footer.php"); ?>