-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_card_tag.php
72 lines (67 loc) · 4.4 KB
/
image_card_tag.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
<h5 class="ms-2 fw-bold"><i class="bi bi-tag-fill"></i> <?php echo $tag; ?> (<?php echo $count; ?>)</h5>
<div class="w-100 px-1 my-2">
<div class="<?php include('../rows_columns/row-cols.php'); echo $rows_columns; ?>">
<?php while ($image = $result->fetchArray()): ?>
<div class="col">
<div class="position-relative">
<a class="rounded ratio ratio-1x1" href="../image.php?artworkid=<?php echo $image['id']; ?>">
<img class="rounded shadow object-fit-cover lazy-load <?php echo ($image['type'] === 'nsfw') ? 'nsfw' : ''; ?>" data-src="../thumbnails/<?php echo $image['filename']; ?>" alt="<?php echo $image['title']; ?>">
</a>
<?php
$current_image_id = $image['id'];
// Query to count main image from the images table
$stmt = $db->prepare("SELECT COUNT(*) as image_count FROM images WHERE id = :id");
$stmt->bindValue(':id', $current_image_id, SQLITE3_INTEGER);
$imageCountQuery = $stmt->execute();
if ($imageCountQuery) {
$imageCountRow = $imageCountQuery->fetchArray(SQLITE3_ASSOC);
$imageCount = $imageCountRow ? $imageCountRow['image_count'] : 0;
} else {
$imageCount = 0;
}
// Query to count associated images from the image_child table
$stmt = $db->prepare("SELECT COUNT(*) as child_image_count FROM image_child WHERE image_id = :image_id");
$stmt->bindValue(':image_id', $current_image_id, SQLITE3_INTEGER);
$childImageCountQuery = $stmt->execute();
if ($childImageCountQuery) {
$childImageCountRow = $childImageCountQuery->fetchArray(SQLITE3_ASSOC);
$childImageCount = $childImageCountRow ? $childImageCountRow['child_image_count'] : 0;
} else {
$childImageCount = 0;
}
// Total count of main images and associated images
$totalImagesCount = $imageCount + $childImageCount;
?>
<?php include('../rows_columns/image_counts.php'); ?>
<div class="position-absolute top-0 start-0">
<div class="dropdown">
<button class="btn border-0 p-1" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-three-dots-vertical text-white link-body-emphasis fs-5" style="text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.3), 3px 3px 6px rgba(0, 0, 0, 0.2); text-stroke: 2;"></i>
</button>
<ul class="dropdown-menu">
<?php
$is_favorited = $db->querySingle("SELECT COUNT(*) FROM favorites WHERE email = '$email' AND image_id = {$image['id']}");
if ($is_favorited) {
?>
<form method="POST">
<input type="hidden" name="image_id" value="<?php echo $image['id']; ?>">
<li><button type="submit" class="dropdown-item fw-bold" name="unfavorite"><i class="bi bi-heart-fill"></i> <small>unfavorite</small></button></li>
</form>
<?php } else { ?>
<form method="POST">
<input type="hidden" name="image_id" value="<?php echo $image['id']; ?>">
<li><button type="submit" class="dropdown-item fw-bold" name="favorite"><i class="bi bi-heart"></i> <small>favorite</small></button></li>
</form>
<?php } ?>
<li><button class="dropdown-item fw-bold" data-bs-toggle="modal" data-bs-target="#shareImage<?php echo $image['id']; ?>"><i class="bi bi-share-fill"></i> <small>share</small></button></li>
<li><button class="dropdown-item fw-bold" data-bs-toggle="modal" data-bs-target="#infoImage_<?php echo $image['id']; ?>"><i class="bi bi-info-circle-fill"></i> <small>info</small></button></li>
</ul>
<?php include('share_tag.php'); ?>
<?php include('../contents/card_image_3.php'); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>