From 0fac4eabc661e4425cf21d461c0e18b542fa8003 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Fri, 16 May 2025 01:04:52 +0500 Subject: feat: some code refactoring --- public/emotesets.php | 43 ++++++------------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) (limited to 'public/emotesets.php') 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) { 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) {
- " class="box"> -
-

-
- -
- '; - } - ?> -
-
- '; + html_display_emoteset($emote_sets); } else if (!empty($emote_set)) { - foreach ($emote_set["emotes"] as $emote_row) { - echo ''; - echo '' . $emote_row['; - echo '

' . $emote_row["code"] . '

'; - echo '

' . ($emote_row["uploaded_by"] == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $emote_row["uploaded_by"]["username"]) . '

'; - echo '
'; - } + html_display_emotes($emote_set->emotes); } else { echo 'Nothing found...'; } -- cgit v1.2.3