From 30303a3ad0d0f31d93c25f42bfd10d70e8277b72 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 10 Dec 2022 22:27:08 +0100 Subject: Update --- includes/functions.inc | 55 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 11 deletions(-) (limited to 'includes/functions.inc') diff --git a/includes/functions.inc b/includes/functions.inc index c3ec313..cc94f11 100644 --- a/includes/functions.inc +++ b/includes/functions.inc @@ -179,6 +179,10 @@ if (!function_exists("getMiniName")) { $parts = explode(" ", $name); if (strlen($parts[0]) > 3 && !str_ends_with($parts[0], "e") && $parts[0] !== "Filly" && $parts[0] !== "Windy" && (isset($parts[1]) && $parts[1] !== "Brightdawn")) { + if ($parts[0] === "Princess") { + array_shift($parts); + } + if (str_contains($parts[0], "/")) { return explode("/", $parts[0])[0]; } else { @@ -250,7 +254,7 @@ if (!function_exists("showMembersFromList")) { function showMembersFromList(array $list) { foreach ($list as $member) { if ($member['name'] !== "unknown" && $member['name'] !== "fusion") { echo(' -
+
' . ($member['display_name'] ?? $member['name']) . '
' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? " ") : ($member['proxy_tags'][0]['prefix'] ?? " ")) . '
@@ -301,18 +305,19 @@ if (!function_exists("showSystem")) { echo('
'); } - showMembersFromList(scoreOrder([...array_map(function ($i) use ($id) { + showMembersFromList(scoreOrder([...array_map(function ($i) use ($id, $travelling) { $i["travelling"] = false; $i["system"] = $id; + $i["equestria"] = $travelling[$i['id']]['travelling'] && $travelling[$i['id']]['equestria']; return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$id/members.json"), true), function ($i) use ($travelling) { - return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']); + return !(isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria'])); })), ...array_map(function ($i) use ($id) { $i["travelling"] = true; $i["system"] = ($id === "gdapd" ? "ynmuc" : "gdapd"); return $i; }, array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($id === "gdapd" ? "ynmuc" : "gdapd") . "/members.json"), true), function ($i) use ($travelling) { - return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling']; + return isset($travelling[$i['id']]) && $travelling[$i['id']]['travelling'] && (!isset($travelling[$i['id']]['equestria']) || !$travelling[$i['id']]['equestria']); }))], $id)); echo('
@@ -349,23 +354,30 @@ if (!function_exists("getMember")) { } if (!function_exists("timeAgo")) { - function timeAgo($time): string { + function timeAgo($time, $french = false): string { if (!is_numeric($time)) { $time = strtotime($time); } $periods = ["sec.", "mn.", "hr.", "d.", "wk.", "mo.", "y.", "ages"]; + $periods_fr = ["sec.", "mn.", "hr.", "j.", "sem.", "m.", "a.", "des années"]; $lengths = array("60", "60", "24", "7", "4.35", "12", "100"); $now = time(); $difference = $now - $time; if ($difference <= 10 && $difference >= 0) { - return $tense = "now"; + if ($french) { + return $tense_fr = "à l'instant"; + } else { + return $tense = "now"; + } } elseif ($difference > 0) { $tense = "ago"; + $tense_fr = "il y a"; } else { $tense = "later"; + $tense_fr = "dans"; } for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { @@ -374,8 +386,13 @@ if (!function_exists("timeAgo")) { $difference = round($difference); - $period = $periods[$j]; - return "{$difference} {$period} {$tense}"; + if ($french) { + $period = $periods_fr[$j]; + return "{$tense_fr} {$difference} {$period}"; + } else { + $period = $periods[$j]; + return "{$difference} {$period} {$tense}"; + } } } @@ -412,21 +429,37 @@ if (!function_exists("timeIn")) { if (!function_exists("duration")) { function duration($seconds) { + global $lang; global $pages; + if ($seconds >= 60) { if (floor($seconds / 60) >= 60) { if (floor($seconds / 3600) >= 24) { $days = floor($seconds / 86400); - return $days . " day" . ($days > 1 ? "s" : ""); + + if ($lang["_french"]) { + return $days . " jour" . ($days > 1 ? "s" : ""); + } else { + return $days . " day" . ($days > 1 ? "s" : ""); + } } else { $hours = floor($seconds / 3600); - return $hours . " hour" . ($hours > 1 ? "s" : ""); + + if ($lang["_french"]) { + return $hours . " heure" . ($hours > 1 ? "s" : ""); + } else { + return $hours . " hour" . ($hours > 1 ? "s" : ""); + } } } else { $minutes = floor($seconds / 60); return $minutes . " minute" . ($minutes > 1 ? "s" : ""); } } else { - return $seconds . " seconds"; + if ($lang["_french"]) { + return $seconds . " secondes"; + } else { + return $seconds . " seconds"; + } } } } -- cgit