diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/components/details.inc | 39 | ||||
-rw-r--r-- | includes/fragments/member.inc | 2 | ||||
-rw-r--r-- | includes/fragments/metadata.inc | 6 | ||||
-rw-r--r-- | includes/util/banner.inc | 6 | ||||
-rw-r--r-- | includes/util/bitset.inc | 4 | ||||
-rw-r--r-- | includes/util/pronouns.inc | 153 |
6 files changed, 44 insertions, 166 deletions
diff --git a/includes/components/details.inc b/includes/components/details.inc index b7d0ebe..e50daf6 100644 --- a/includes/components/details.inc +++ b/includes/components/details.inc @@ -3,32 +3,31 @@ <div> <b><?= $lang["details"]["food"] ?></b><span class="member-small-separator"><br></span> <?= match ($metadata["food"]) { - 0 => "<span data-bs-toggle='tooltip' title='" . ucfirst(str_replace("'", "'", $pronouns["possessive_det"])) . " species indicates that " . str_replace("'", "'", $pronouns["subjective"]) . ' ' . ($pronouns["third"] ? "doesn't" : "don't") . " need to eat food, therefore " . str_replace("'", "'", $pronouns["subjective"]) . " can eat all foods.'>" . $lang["details"]["food_states"][0] . "</span>", - 1 => "<span data-bs-toggle='tooltip' title='" . ucfirst(str_replace("'", "'", $pronouns["subjective"])) . " can't eat fish or meat.'>" . $lang["details"]["food_states"][1] . "</span>", - 2 => "<span data-bs-toggle='tooltip' title='" . ucfirst(str_replace("'", "'", $pronouns["subjective"])) . " can't eat meat, but can eat fish.'>" . $lang["details"]["food_states"][2] . "</span>", - 3 => "<span data-bs-toggle='tooltip' title='" . ucfirst(str_replace("'", "'", $pronouns["subjective"])) . " can eat all foods, meat and fish included.'>" . $lang["details"]["food_states"][3] . "</span>", + 0 => "<span data-bs-toggle='tooltip' title='This pony's species indicates that this pony doesn't need to eat food, therefore this pony can eat all foods.'>" . $lang["details"]["food_states"][0] . "</span>", + 1 => "<span data-bs-toggle='tooltip' title='This pony can't eat fish or meat.'>" . $lang["details"]["food_states"][1] . "</span>", + 2 => "<span data-bs-toggle='tooltip' title='This pony can't eat meat, but can eat fish.'>" . $lang["details"]["food_states"][2] . "</span>", + 3 => "<span data-bs-toggle='tooltip' title='This pony can eat all foods, meat and fish included.'>" . $lang["details"]["food_states"][3] . "</span>", } ?> </div> <div> <b><?= $lang["details"]["memory"] ?></b><span class="member-small-separator"><br></span> <?= match ($metadata["shared_memory"]) { - 0 => "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst($pronouns["subjective"])) . ($pronouns["third"] ? " doesn't directly share" : " don't directly share") . " memory with " . str_replace("'", "'", $pronouns["possessive_det"]) . " headmates, but is able to (slowly) query it if that is needed.'>" . $lang["details"]["memory_states"][0] . "</span>", - 1 => "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst($pronouns["subjective"])) . ($pronouns["third"] ? " doesn't directly shares" : " don't directly share") . " all memories with " . str_replace("'", "'", $pronouns["possessive_det"]) . " headmates, but may be able to share certain memories and/or share memories at will.'>" . $lang["details"]["memory_states"][1] . "</span>", - 2 => "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst($pronouns["subjective"])) . ($pronouns["third"] ? " shares" : " share") . " all memories with " . str_replace("'", "'", $pronouns["possessive_det"]) . " headmates.'>" . $lang["details"]["memory_states"][2] . "</span>", + 0 => "<span data-bs-toggle='tooltip' title='This pony doesn't directly share memories with this pony's headmates, b, but is able to (slowly) query them if that is needed.'>" . $lang["details"]["memory_states"][0] . "</span>", + 1 => "<span data-bs-toggle='tooltip' title='This pony doesn't directly share memories with this pony's headmates, but may be able to share certain memories and/or share memories at will.'>" . $lang["details"]["memory_states"][1] . "</span>", + 2 => "<span data-bs-toggle='tooltip' title='This pony shares all memories with this pony's headmates.'>" . $lang["details"]["memory_states"][2] . "</span>", } ?> </div> - <?php if ($isLoggedIn || $isLowerLoggedIn): ?> <div> <b>Age:</b><span class="member-small-separator"><br></span> <?php if (!isset($metadata["birth"]["year"]) || $metadata["birth"]["age"] > 0): ?> <?php if ($metadata["birth"]["age"] === -1): $age = abs(log(0)); // => INF ?> - <?= "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst($pronouns["subjective"])) . " never age" . str_replace("'", "'", $pronouns["third"] ? "s" : "") . " and " . str_replace("'", "'", $pronouns["third"] ? "doesn't" : "don't") . " have a defined age, making " . str_replace("'", "'", $pronouns["object"]) . " pretty much eternal.'>Eternal</span>" ?> + <?= "<span data-bs-toggle='tooltip' title='This pony never ages and doesn't have a defined age, making this pony pretty much eternal.'>Eternal</span>" ?> <?php elseif ($metadata["birth"]["age"] <= 0): ?> - <?php else: $age = $metadata["birth"]["age"]; if (is_numeric($metadata["birth"]["age"])): ?> - <?= "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst($pronouns["subjective"])) . str_replace("'", "'", $pronouns["third"] ? " doesn't" : " don't") . " age like the body does, making " . str_replace("'", "'", $pronouns["object"]) . " stay " . $metadata["birth"]["age"] . " years old for " . str_replace("'", "'", $pronouns["possessive_det"]) . " entire life.'>" . $metadata["birth"]["age"] . "* years old</span>" ?> + <?= "<span data-bs-toggle='tooltip' title='This pony doesn't age like the body does, making this pony stay " . $metadata["birth"]["age"] . " years old for this pony's entire life.'>" . $metadata["birth"]["age"] . "* years old</span>" ?> <?php else: ?> - <?= "<span data-bs-toggle='tooltip' title='" . str_replace("'", "'", ucfirst($pronouns["object"])) . " age " . str_replace("'", "'", $pronouns["third"] ? " changes" : " change") . " frequently between " . explode("-", $metadata["birth"]["age"])[0] . " and " . explode("-", $metadata["birth"]["age"])[1] . " years old, and " . str_replace("'", "'", $pronouns["subjective"]) . " " . str_replace("'", "'", $pronouns["third"] ? " doesn't" : " don't") . " have a single defined age.'>Sliding " . explode("-", $metadata["birth"]["age"])[0] . " to " . explode("-", $metadata["birth"]["age"])[1] . "</span>" ?> + <?= "<span data-bs-toggle='tooltip' title='This pony's age changes frequently between " . explode("-", $metadata["birth"]["age"])[0] . " and " . explode("-", $metadata["birth"]["age"])[1] . " years old, and this 't have a single defined age.'>Sliding " . explode("-", $metadata["birth"]["age"])[0] . " to " . explode("-", $metadata["birth"]["age"])[1] . "</span>" ?> <?php endif; endif; ?> <?php else: ?> <?php if ($metadata["birth"]["year"] <= 1900): ?> @@ -50,12 +49,11 @@ } ?> - <?= "<span data-bs-toggle='tooltip' title='$age2 with the old algorithm | " . str_replace("'", "'", ucfirst($pronouns["subjective"])) . " age" . str_replace("'", "'", $pronouns["third"] ? "s" : "") . " like the body does, making " . str_replace("'", "'", $pronouns["object"]) . " stay " . $age . " years old for now, having this age change $birthday.'>" . $age . " years old</span>" ?> + <?= "<span data-bs-toggle='tooltip' title='$age2 with the old algorithm | This pony ages like the body does, making this pony stay " . $age . " years old for now, having this age change $birthday.'>" . $age . " years old</span>" ?> <?php endif; ?> <?php endif; ?> </div> - <?php endif; ?> - <?php if ($systemID !== $app["other"]["id"]): ?> + <?php if ($systemID !== $app["other"]["id"]): if ($isLoggedIn || $isLowerLoggedIn): ?> <div> <b><?= $lang["details"]["code"] ?></b><span class="member-small-separator"><br></span> <?php if (isset($metadata["code"]) && trim($metadata["code"]) !== ""): ?> @@ -64,6 +62,7 @@ - <?php endif; ?> </div> + <?php endif; ?> <div> <b>Primary interest:</b><span class="member-small-separator"><br></span> <?php if (isset($metadata["interest"]) && trim($metadata["interest"]) !== ""): ?> @@ -72,7 +71,7 @@ - <?php endif; ?> </div> - <?php endif; ?> + <?php endif ?> <?php if ($systemID !== $app["other"]["id"]): ?> </div> <?php endif; ?> @@ -80,19 +79,19 @@ <?php if ($systemID !== $app["other"]["id"]): ?> <div id="member-details-2" style="background-color: <?= isset($memberData["color"]) ? '#' . $memberData["color"] . "33" : "transparent" ?>; margin-left: -20px; margin-right: -20px;<?php if ($isLowerLoggedIn): ?>grid-template-columns: repeat(3, 1fr);<?php endif; ?>"> <?php endif; ?> - <?php if (((isset($age) && $age >= 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0)) || $metadata["sexual_features"]): ?> + <?php $age2 = $age ?? 0; if (is_string($age2)) $age2 = (int)(explode("-", $age2)[1] ?? "0"); if (((isset($age2) && $age2 >= 16 && $metadata["little"] === 0) || (!isset($age2) && $metadata["little"] === 0)) || $metadata["sexual_features"]): ?> <?php if ($isLoggedIn && $systemID !== $app["other"]["id"]): ?> <div> <span style="vertical-align: middle;"> <b>Sexual consent:</b><span class="member-small-separator"><br></span> <?php if ($metadata["sexually_active"]): ?> - <span title="Consent is assumed when having sex with <?= $pronouns["object"] ?>, however <?= $pronouns["subjective"] ?> may ask to not have sex at the moment and such request must be honored." data-bs-toggle="tooltip">Preemptive</span> + <span title="Consent is assumed when having sex with this pony, however this pony may ask to not have sex at the moment and such request must be honored." data-bs-toggle="tooltip">Preemptive</span> <?php else: ?> - <span title="Consent is absolutely required every time when having sex with <?= $pronouns["object"] ?>." data-bs-toggle="tooltip">Required</span> + <span title="Consent is absolutely required every time when having sex with this pony." data-bs-toggle="tooltip">Required</span> <?php endif; ?> </span> <?php if (!((isset($age) && $age >= 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0))): ?> - <img src="/assets/icons/warning.svg" style="width: 16px;" title="Although this pony is able to engage in sexual relationships, they are not allowed to have sex with ponies who are over 16 years old." data-bs-toggle="tooltip"> + <img src="/assets/icons/warning.svg" style="width: 16px;" title="Although this pony is able to engage in sexual relationships, this pony is not allowed to have sex with ponies who are over 16 years old." data-bs-toggle="tooltip"> <?php endif; ?> </div> <?php endif; ?> @@ -126,7 +125,7 @@ grid-template-columns: <?= $isLowerLoggedIn ? "1fr 1fr 1fr" : "2fr 1fr 1fr" ?>; } </style> - <div style="display: flex; align-items: center; justify-content: center; height: 100%;opacity:.5;">This member is too young to be in a sexual relationship.</div> + <div style="display: flex; align-items: center; justify-content: center; height: 100%;opacity:.5;">This pony is too young to be in a sexual relationship.</div> </div> <?php endif; ?> <div> diff --git a/includes/fragments/member.inc b/includes/fragments/member.inc index 4eed308..bbdfc98 100644 --- a/includes/fragments/member.inc +++ b/includes/fragments/member.inc @@ -120,7 +120,7 @@ if ($memberData["name"] === "fusion") { </ul> </li> <li><b>Date added:</b> <?= date('l j F Y', strtotime($memberData["created"])) ?> (<?= timeAgo($memberData["created"]) ?>, <code><?= $memberData["created"] ?></code>)</li> - <li><b>Pronouns:</b> <?= implode(", ", getPronounsFromMark($memberData['pronouns'])) ?></li> + <li><b>Pronouns:</b> <?= $memberData['pronouns'] ?></li> <li><b>Pronouns usage:</b> <ul><?php foreach (getMemberPronouns($memberData['pronouns']) as $type => $usage) { diff --git a/includes/fragments/metadata.inc b/includes/fragments/metadata.inc index e143153..031fd19 100644 --- a/includes/fragments/metadata.inc +++ b/includes/fragments/metadata.inc @@ -83,6 +83,10 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member </select> </div> </div> + <p> + <b>Gender</b><br> + <input name="gender" class="form-control" style="filter: invert(1) hue-rotate(180deg);" type="text" value="<?= $metadata["gender"] ?? "" ?>"> + </p> <hr> @@ -132,7 +136,7 @@ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member </p> <p> <b>Age (for ponies with fixed age)</b><br> - <input name="age" class="form-control" style="filter: invert(1) hue-rotate(180deg);" type="text" pattern="^\d{1,2}(-\d{1,2}|)$" value="<?= $metadata["birth"]["age"] ?? "" ?>"> + <input name="age" class="form-control" style="filter: invert(1) hue-rotate(180deg);" type="text" pattern="^(-\d{1,2}|\d{1,2}(-\d{1,2}|))$" value="<?= $metadata["birth"]["age"] ?? "" ?>"> </p> <hr> diff --git a/includes/util/banner.inc b/includes/util/banner.inc index 46d9ce5..1657233 100644 --- a/includes/util/banner.inc +++ b/includes/util/banner.inc @@ -3,6 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/pronouns.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/Parsedown.php"; $Parsedown = new Parsedown(); $travelling = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/travelling/travelling.json"), true); @@ -21,11 +22,13 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { global $travelling; global $isLoggedIn; global $lang; + global $Parsedown; $french = $lang["_french"]; $member = getSystemMember($system, $id); $metadata = file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$id.json") ? parseMetadata(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/$id.json"), true)) : parseMetadata([ + // FIXME: This doesn't work now that bitset functionality is removed "bitset" => 4196352, "regression" => null, "median" => null, @@ -463,9 +466,10 @@ function getMemberBannerData(string $id, string $system, bool $french = false) { 'median' => $metadata["median"], 'little' => $metadata["little"] >= 2, 'name' => $member["display_name"] ?? $member["name"], + 'gender' => isset($metadata["gender"]) && trim($metadata["gender"]) !== "" ? $Parsedown->text($metadata["gender"]) : "Agender", 'badges' => $badges, 'prefixes' => $prefixes, - 'pronouns' => getTooltipsFromMark($member["pronouns"], $french) ?? "<span data-bs-toggle='tooltip' title='Pronouns not specified' class='text-muted'>they/them</span>", + 'pronouns' => isset($member["pronouns"]) && trim($member["pronouns"]) !== "" ? $member["pronouns"] : "<i>they/them</i>", 'pronouns_usage' => getMemberPronouns($member['pronouns']), 'last_fronted' => $lastFronted, 'species' => $speciesList, diff --git a/includes/util/bitset.inc b/includes/util/bitset.inc index 131cb39..14f178c 100644 --- a/includes/util/bitset.inc +++ b/includes/util/bitset.inc @@ -11,6 +11,10 @@ function parseMetadata ($metadata) { $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1); } + if (is_string($age) && isset(explode("-", $age)[1]) && is_numeric(explode("-", $age)[1])) { + $age = (int)explode("-", $age)[1]; + } + if ($age > 0 && $age <= 10) { $metadata["little"] = 2; } else if ($age > 0 && $age <= 15) { diff --git a/includes/util/pronouns.inc b/includes/util/pronouns.inc index 6ab2487..b7c8dd4 100644 --- a/includes/util/pronouns.inc +++ b/includes/util/pronouns.inc @@ -1,149 +1,16 @@ <?php -$pronounsSets = [ - "pony" => [ - "gender" => "ponygender", - "gender:fr" => "poneygenre", - "object" => "pony", +function getMemberPronouns(?string $pronouns): ?array { + return [ + "gender" => "invalid", + "gender:fr" => "invalide", + "object" => "this pony", "person" => "pony", - "possessive_det" => "pony's", - "possessive_pro" => "pony's", - "reflexive" => "ponyself", - "subjective" => "pony", - "third" => true, - "color" => "warning" - ], - "she" => [ - "gender" => "female", - "gender:fr" => "fille", - "object" => "her", - "person" => "girl", - "possessive_det" => "her", - "possessive_pro" => "hers", - "reflexive" => "herself", - "subjective" => "she", + "possessive_det" => "this pony's", + "possessive_pro" => "this pony's", + "reflexive" => "this pony", + "subjective" => "this pony", "third" => true, "color" => "success" - ], - "he" => [ - "gender" => "male", - "gender:fr" => "garçon", - "object" => "him", - "person" => "boy", - "possessive_det" => "his", - "possessive_pro" => "his", - "reflexive" => "himself", - "subjective" => "he", - "third" => true, - "color" => "info" - ], - "it" => [ - "gender" => "agender", - "gender:fr" => "agenre", - "object" => "it", - "person" => "person", - "possessive_det" => "its", - "possessive_pro" => "its", - "reflexive" => "itself", - "subjective" => "it", - "third" => true, - "color" => "light" - ], - "they" => [ - "gender" => "non binary", - "gender:fr" => "non binaire", - "object" => "them", - "person" => "person", - "possessive_det" => "their", - "possessive_pro" => "theirs", - "reflexive" => "themself", - "subjective" => "they", - "third" => false, - "color" => "primary" - ] -]; - -$pronounGetCount = 0; - -$possibilitiesPerSet = []; -foreach ($pronounsSets as $name => $set) { - if (!isset($possibilitiesPerSet[$name])) $possibilitiesPerSet[$name] = []; - $possibilitiesPerSet[$name][] = $name; - - foreach ($set as $category => $value) { - if (is_string($value)) $possibilitiesPerSet[$name][] = $value; - } -} - -function getSetFromValue(string $value) { - global $possibilitiesPerSet; - - foreach ($possibilitiesPerSet as $name => $set) { - if (in_array($value, $set)) { - return $name; - } - } - - return null; -} - -function getPronounsFromMark(?string $mark = null): array { - if (!isset($mark) || trim($mark) === "") { - return ["they"]; - } else { - $parts = array_unique(array_map(function ($i) { - return getSetFromValue($i); - }, explode("/", $mark))); - return $parts; - } -} - -function getMemberPronouns(?string $pronouns): ?array { - global $pronounsSets; - $list = getPronounsFromMark($pronouns); - return $pronounsSets[$list[array_rand($list)]] ?? $pronounsSets["she"]; -} - -function getGenderFromPronoun(string $pronoun, bool $french = false) { - global $pronounsSets; - $set = getPronounsFromMark($pronoun)[0]; - - if ($french) { - return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender:fr"]; - } else { - return ($pronounsSets[$set] ?? $pronounsSets["they"])["gender"]; - } -} - -function pronounInFrench(string $pronoun): string { - return match ($pronoun) { - "she" => "elle", - "her" => "elle", - "he" => "il", - "him" => "lui", - "they" => "iel", - "them" => "iel", - "it" => "iel", - "its" => "iel", - "pony" => "poney", - "pony's" => "à poney", - "ponys" => "à poney", - default => $pronoun, - }; -} - -function getTooltipsFromMark(string $mark = null, bool $french = false): ?string { - if (!isset($mark)) { - return null; - } else { - if ($french) { - return implode("/", array_map(function ($i) { - return "<span title='" . ucfirst(getGenderFromPronoun($i, true)) . "' data-bs-toggle='tooltip'>" . pronounInFrench($i) . "</span>"; - }, explode("/", $mark))); - } else { - return implode("/", array_map(function ($i) { - return "<span title='" . ucfirst(getGenderFromPronoun($i, false)) . "' data-bs-toggle='tooltip'>" . $i . "</span>"; - }, explode("/", $mark))); - } - } + ]; }
\ No newline at end of file |