summaryrefslogtreecommitdiff
path: root/public/emotesets.php
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-05-16 01:04:52 +0500
committerilotterytea <iltsu@alright.party>2025-05-16 01:15:12 +0500
commit0fac4eabc661e4425cf21d461c0e18b542fa8003 (patch)
treee4737cd1a1e311a47d59fbff569ff696e33cd46e /public/emotesets.php
parent98e7d4bcb8fdf99d97f95be2fb0cc18a0543808b (diff)
feat: some code refactoring
Diffstat (limited to 'public/emotesets.php')
-rw-r--r--public/emotesets.php43
1 files changed, 6 insertions, 37 deletions
diff --git a/public/emotesets.php b/public/emotesets.php
index 7044091..d393779 100644
--- a/public/emotesets.php
+++ b/public/emotesets.php
@@ -74,22 +74,14 @@ $emote_sets = null;
// fetching emotes
if ($emote_set) {
- $emotes = fetch_all_emotes_from_emoteset($db, $emote_set["id"], $user_id, null);
- $emote_set["emotes"] = $emotes;
+ $emote_set = Emoteset::from_array_extended($emote_set, $user_id, $db);
} elseif (!EMOTESET_PUBLIC_LIST) {
generate_alert("/404.php", "The public list of emotesets is disabled", 403);
exit;
} else {
$emote_sets = [];
- foreach ($db->query("SELECT es.* FROM emote_sets es", PDO::FETCH_ASSOC) as $row) {
- $emote_set_row = $row;
- $emote_set_row["emotes"] = fetch_all_emotes_from_emoteset(
- $db,
- $emote_set_row["id"],
- $user_id,
- 5
- );
- array_push($emote_sets, $emote_set_row);
+ foreach ($db->query("SELECT * FROM emote_sets", PDO::FETCH_ASSOC) as $row) {
+ array_push($emote_sets, Emoteset::from_array_extended($row, $user_id, $db));
}
}
@@ -125,7 +117,7 @@ if (CLIENT_REQUIRES_JSON) {
<?php
$title = match ($emote_set == null) {
true => count($emote_sets) . ' emotesets',
- false => 'Emoteset - ' . $emote_set["name"],
+ false => "Emoteset - {$emote_set->name}",
};
echo "$title - " . INSTANCE_NAME;
@@ -148,32 +140,9 @@ if (CLIENT_REQUIRES_JSON) {
<div class="box content small-gap items">
<?php
if (!empty($emote_sets)) {
- foreach ($emote_sets as $set_row) {
- ?>
- <a href="/emotesets.php?id=<?php echo $set_row["id"] ?>" class="box">
- <div>
- <p><?php echo $set_row["name"] ?></p>
- </div>
-
- <div>
- <?php
- foreach ($set_row["emotes"] as $emm) {
- echo '<img src="/static/userdata/emotes/' . $emm["id"] . '/1x.webp" height="' . EMOTE_MAX_SIZE[1] / 4 . '">';
- }
- ?>
- </div>
- </a>
- <?php }
-
- echo '</div></section>';
+ html_display_emoteset($emote_sets);
} else if (!empty($emote_set)) {
- foreach ($emote_set["emotes"] as $emote_row) {
- echo '<a class="box emote" href="/emotes?id=' . $emote_row["id"] . '">';
- echo '<img src="/static/userdata/emotes/' . $emote_row["id"] . '/2x.webp" alt="' . $emote_row["code"] . '" />';
- echo '<h1>' . $emote_row["code"] . '</h1>';
- echo '<p>' . ($emote_row["uploaded_by"] == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $emote_row["uploaded_by"]["username"]) . '</p>';
- echo '</a>';
- }
+ html_display_emotes($emote_set->emotes);
} else {
echo 'Nothing found...';
}