-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.php
85 lines (83 loc) · 3.09 KB
/
views.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
<?php
session_start();
require $_SERVER["DOCUMENT_ROOT"]."/functions/montage.php";
require $_SERVER["DOCUMENT_ROOT"]."/functions/like.php";
$imagePerPages = 5;
$montages = get_montages(0, $imagePerPages);
$more = false;
$lastMontageId = 0;
if ($montages != "" && array_key_exists("more", $montages)) {
$more = true;
$lastMontageId = $montages[count($montages) - 2]['image_id'];
}
?>
<!DOCTYPE html>
<HTML>
<header>
<link rel="stylesheet" type="text/css" href="style/views.css">
<link rel="stylesheet" type="text/css" href="style/modal.css">
<meta charset="UTF-8">
<title>CAMAGRU</title>
</header>
<body>
<?php include('template/header.php') ?>
<div id="views">
<?php
$gallery = "";
if ($montages != null && $montages['error'] == null) {
for ($i = 0; $montages[$i] && $i < $imagePerPages; $i++) {
$class = "icon";
if ($montages[$i]['user_id'] == $_SESSION['id']) {
$class .= " removable";
}
$comments = get_comments($montages[$i]['path']);
$_SESSION['comment'] = $comments;
$j = 0;
$commentsHTML = "";
while ($comments[$j] != null) {
$commentsHTML .= "<span class=\"comment\">" . htmlspecialchars($comments[$j]['username']) .": " . htmlspecialchars($comments[$j]['text']) . "</span>";
$j++;
}
$gallery .= "
<div class=\"img\" data-img=\"" . $montages[$i]['path'] . "\">
<img class=\"" . $class . "\" src=\"montage/" . $montages[$i]['path'] . "\"></img>
<div id=\"buttons-like\">
<img class=\"button-like\" src=\"img/up.png\" data-image=\"". $montages[$i]['path'] ."\"></img>
<span class=\"nb-like\" data-src=\"". $montages[$i]['path'] ."\">" . get_nb_likes($montages[$i]['path']) . "</span>
<img class=\"button-dislike\" src=\"img/down.png\" data-image=\"". $montages[$i]['path'] ."\"></img>
<span class=\"nb-dislike\" data-src=\"". $montages[$i]['path'] ."\">" . get_nb_dislikes($montages[$i]['path']) . "</span>
</div>"
. $commentsHTML .
"</div>";
}
echo $gallery;
}
?>
</div>
<div id="modal">
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
</div>
<div class="modal-body">
<img id="img-modal"></img>
</div>
<div class="modal-footer">
<textarea <?php if (!$_SESSION['id']) echo "disabled" ?> id="comment" placeholder="Comment..." rows="5" cols="50" maxlength="255"></textarea>
<div <?php if (!$_SESSION['id']) echo "disabled=\"true\"" ?> id="send-comment" class="button-send <?php if (!$_SESSION['id']) echo "disabled" ?>">Send</div>
</div>
</div>
</div>
<?php if ($more == true) { ?>
<div id="load-more" onclick="loadMore(<?php echo($lastMontageId) ?>, <?php echo($imagePerPages) ?>)">... LOAD MORE</div>
<?php } ?>
<?php include('template/footer.php') ?>
<?php
print_r($_SESSION['getmontages']);
print_r($_SESSION['getcomment']);
?>
</body>
<script type="text/javascript" src="js/modal.js"></script>
<script type="text/javascript" src="js/like.js"></script>
<script type="text/javascript" src="js/loadMore.js"></script>
</HTML>