-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentries_public.php
96 lines (92 loc) · 4.43 KB
/
entries_public.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
<?php
// Alle Blogeinträge holen, die Blog-ID ist in der Variablen $blogId gespeichert (wird in index.php gesetzt)
// Hier Code... (Schlaufe über alle Einträge dieses Blogs)
// Nachfolgend das Beispiel einer Ausgabe in HTML, dieser Teil muss mit einer Schlaufe über alle Blog-Beiträge und der Ausgabe mit PHP ersetzt werden
if(isset($_GET['bid'])){
if(!userExistsByUid($_GET['bid'])){
$url = $_SERVER['PHP_SELF'] . "?function=blogs";
echo "<script>window.location = '$url'</script>";
}
}
$blogEntries = getEntries($blogId);
$comments = [];
$hide = true;
if(isset($_GET['eid'])) {
$comments = getComments($entryId);
$hide = false;
}
?>
<div class='container' style='margin:0;'>
<div class='row'>
<div class='col'>
<?php
foreach ($blogEntries as $entry) {
echo "<div class='card' style='width:40rem;height:15rem;margin-bottom:2rem;'>
<a href='index.php?function=entries_public&bid=" . $blogId . "&eid=" . $entry['eid'] . "' title='Blog auswählen' style='color:black;text-decoration:none;'>
<div class='card-body'>
<h4 class='card-title'>" . date('Y-m-d H:i:s', $entry['datetime']) . "</h4>
<div class='card-header'>" . $entry['title'] . "</div>
<p class='card-text'>" . substr($entry['content'], 0, 25) . "...</p>
</div>
</a>
</div>
";
}
?>
</div>
<div class='col'>
<div class='row'>
<?php
if (sizeof($blogEntries) == 0) {
print "<p>Keine Einträge vorhanden</p>";
}
foreach ($blogEntries as $entry) {
if ($entry['eid'] == $entryId) {
echo "<div class='container text'>";
echo "<h2>" . $entry['title'] . "</h2>";
echo "<p>" . nl2br($entry['content']) . "</p>";
echo "</div>";
}
}
?>
</div>
<div class='row' >
<h3 class='comment'>Kommentare</h3>
<?php
if (sizeof($comments) == 0 and !$hide) {
echo "<p>Keine Kommentare vorhanden</p>";
}
foreach ($comments as $comment) {
echo "<div class='container'>
<div class='card' style='width:40vw;margin-bottom:1vw;margin-top: 1vw;'>
<div class='card-body'>
<h4 class='card-title'>Autor: " . $comment['name'] . " - Erstellt: " . date('Y-m-d H:i:s', $comment['datetime']). "</h4>
<p>" . nl2br($comment['content']) . "</p>
</div>
</div>
</div>";
}
?>
<div <?php if($hide) echo 'hidden' ?>>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] . '?function=comment_add&bid='.$blogId.'&eid='.$entryId ?>">
<div class="form-group" style="width:40vw;" name="<?php echo $entryId; ?>">
<!-- <label for="exampleFormControlInput1">Eintrag</label>
<input type="text" class="form-control" id="commentEid" name="eid"
value="<?php echo $entryId; ?>" readonly> -->
</div>
<div class="form-group" style="width:40vw;" name="<?php echo $entryId; ?>">
<label for="exampleFormControlInput1">Autor</label>
<input type="text" class="form-control" id="commentAutor" name="name" placeholder="Autor">
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Kommentar</label>
<textarea class="form-control" style="font-size:1vw;" id="commentText" rows="3"
name='content'></textarea>
</div>
<button type="submit" style="font-size:1.2vw;" class="btn btn-primary">Erstellen</button>
</form>
</div>
</div>
</div>
</div>
</div>