diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-28 00:58:53 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-28 00:58:53 +0500 |
| commit | 5ab2480c609b3f2540f5eb840e9cf3eb0589317d (patch) | |
| tree | 1933c6f206767c60515d85993bc9ef023fdd4a12 | |
| parent | 067348835299febed3080ab61ffca365cd07743f (diff) | |
feat: display emote's author name
| -rw-r--r-- | public/emotes/index.php | 13 | ||||
| -rw-r--r-- | public/emotesets.php | 17 | ||||
| -rw-r--r-- | public/static/style.css | 22 | ||||
| -rw-r--r-- | public/users.php | 6 | ||||
| -rw-r--r-- | src/emote.php | 2 |
5 files changed, 52 insertions, 8 deletions
diff --git a/public/emotes/index.php b/public/emotes/index.php index c278e93..d37b3f5 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -51,12 +51,20 @@ function display_list_emotes(PDO &$db, int $page, int $limit): array $rows = $stmt->fetchAll(); foreach ($rows as $row) { + $uploader = null; + + if ($row["uploaded_by"]) { + $stmt = $db->prepare("SELECT id, username FROM users WHERE id = ?"); + $stmt->execute([$row["uploaded_by"]]); + $uploader = $stmt->fetch(PDO::FETCH_ASSOC); + } + array_push($emotes, new Emote( $row["id"], $row["code"], $row["ext"], intval(strtotime($row["created_at"])), - $row["uploaded_by"], + $uploader, $row["is_in_user_set"], $row["rating"] )); @@ -357,7 +365,8 @@ if (CLIENT_REQUIRES_JSON) { } echo '<img src="/static/userdata/emotes/' . $e->get_id() . '/2x.' . $e->get_ext() . '" alt="' . $e->get_code() . '"/>'; - echo '<p>' . $e->get_code() . '</p>'; + echo '<h1>' . $e->get_code() . '</h1>'; + echo '<p>' . ($e->get_uploaded_by() == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $e->get_uploaded_by()["username"]) . '</p>'; echo '</a>'; } ?> diff --git a/public/emotesets.php b/public/emotesets.php index 69df158..ebec077 100644 --- a/public/emotesets.php +++ b/public/emotesets.php @@ -55,6 +55,13 @@ if ($id == "global") { $stmt->execute([$e["id"]]); $e["emotes"] = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($e["emotes"] as &$em) { + if ($em["uploaded_by"]) { + $stmt = $db->prepare("SELECT id, username FROM users WHERE id = ?"); + $stmt->execute([$em["uploaded_by"]]); + $em["uploaded_by"] = $stmt->fetch(PDO::FETCH_ASSOC); + } + } } } else if (intval($alias_id) > 0) { $alias_id = intval($alias_id); @@ -96,6 +103,13 @@ if ($id == "global") { $stmt->execute([$emote_set["id"]]); $emote_set["emotes"] = $stmt->fetchAll(PDO::FETCH_ASSOC); + foreach ($emote_set["emotes"] as &$e) { + if ($e["uploaded_by"]) { + $stmt = $db->prepare("SELECT id, username FROM users WHERE id = ?"); + $stmt->execute([$e["uploaded_by"]]); + $e["uploaded_by"] = $stmt->fetch(PDO::FETCH_ASSOC); + } + } } } @@ -175,7 +189,8 @@ if (CLIENT_REQUIRES_JSON) { 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.' . $emote_row["ext"] . '" alt="' . $emote_row["code"] . '"/>'; - echo '<p>' . $emote_row["code"] . '</p>'; + echo '<h1>' . $emote_row["code"] . '</h1>'; + echo '<p>' . ($emote_row["uploaded_by"] == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $emote_row["uploaded_by"]["username"]) . '</p>'; echo '</a>'; } } diff --git a/public/static/style.css b/public/static/style.css index 0183846..ae4574f 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -303,8 +303,8 @@ button.purple:hover, } .box.emote { - width: 90px; - height: 90px; + width: 96px; + height: 96px; display: flex; flex-direction: column; @@ -316,9 +316,27 @@ button.purple:hover, overflow: hidden; } +.box.emote:has(p) h1 { + margin-top: 4px; + line-height: 0; +} + +.box.emote h1 { + font-size: 16px; + font-weight: 600; +} + .box.emote p { text-overflow: ellipsis; white-space: nowrap; + font-size: 10px; +} + +.box.emote img { + max-width: 64px; + max-height: 64px; + margin-top: auto; + margin-bottom: auto; } a.box { diff --git a/public/users.php b/public/users.php index 4540f5a..de9bfc8 100644 --- a/public/users.php +++ b/public/users.php @@ -428,7 +428,9 @@ if ($is_json) { foreach ($active_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.' . $emote_row["ext"] . '" alt="' . $emote_row["code"] . '"/>'; - echo '<p>' . $emote_row["code"] . '</p>'; + echo '<h1>' . $emote_row["code"] . '</h1>'; + echo '<p>' . ($emote_row["uploaded_by"] == null ? (ANONYMOUS_DEFAULT_NAME . "*") : $emote_row["uploaded_by"]["username"]) . '</p>'; + echo '</a>'; echo '</a>'; } } else { @@ -453,7 +455,7 @@ if ($is_json) { foreach ($uploaded_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.' . $emote_row["ext"] . '" alt="' . $emote_row["code"] . '"/>'; - echo '<p>' . $emote_row["code"] . '</p>'; + echo '<h1>' . $emote_row["code"] . '</h1>'; echo '</a>'; } ?> diff --git a/src/emote.php b/src/emote.php index 1fa0221..b10fbeb 100644 --- a/src/emote.php +++ b/src/emote.php @@ -4,7 +4,7 @@ class Emote public string $id; public string $code; public string $ext; - public string|null $uploaded_by; + public mixed $uploaded_by; public int $created_at; public mixed $rating; public bool $is_in_user_set; |
