summaryrefslogtreecommitdiff
path: root/includes/functions.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/functions.inc')
-rw-r--r--includes/functions.inc55
1 files changed, 44 insertions, 11 deletions
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']) . ' -->
-<a href="/' . $member['name'] . '" style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;"><div>
+<a href="/' . $member['name'] . '" style="text-decoration:none !important;filter:none !important;"><div class="hpd-item-card" style="background-color:rgba(255, 255, 255, .1);border:1px solid ' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';outline-color:' . (isset($member['color']) ? "#" . $member['color'] . "55" : "transparent") . ';border-radius:10px;text-align:center;display:flex;align-items:center;justify-content:center;padding:5px;' . ($member["equestria"] ? 'opacity:.5;' : '') . '"><div>
<img alt="" src="' . getAsset($member["system"], $member["id"]) . '" style="border-radius:999px;background-color:rgba(0, 0, 0, .25);height:48px;display:block;margin-left:auto;margin-right:auto;">
<div style="text-decoration:none;color:white;margin-top:5px;">' . ($member['display_name'] ?? $member['name']) . '</div>
<div style="text-decoration:none !important;color:black !important;"><code style="text-decoration:none !important;color:white !important;">' . (isset($member['travelling']) && $member['travelling'] ? "+" . ($member['proxy_tags'][0]['prefix'] ?? "&nbsp;") : ($member['proxy_tags'][0]['prefix'] ?? "&nbsp;")) . '</code></div>
@@ -301,18 +305,19 @@ if (!function_exists("showSystem")) {
echo(' <div style="display:grid;grid-template-columns:repeat(6, 1fr);padding-left:10px;grid-gap:10px;">');
}
- 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('</div>
@@ -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";
+ }
}
}
}