diff options
author | Minteck <contact@minteck.org> | 2022-08-31 22:03:07 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-31 22:03:07 +0200 |
commit | b5f589c323f415bb42ea7069cb4d1a8a2233dd69 (patch) | |
tree | c3b80234ab7f463a2e7b8b672ceff57422b3496b /pages/nicknames.php | |
parent | 09bd0164ebc020a54b944b7326dcba496fb5d82c (diff) | |
download | pluralconnect-b5f589c323f415bb42ea7069cb4d1a8a2233dd69.tar.gz pluralconnect-b5f589c323f415bb42ea7069cb4d1a8a2233dd69.tar.bz2 pluralconnect-b5f589c323f415bb42ea7069cb4d1a8a2233dd69.zip |
Update I guess - Stuffie
Diffstat (limited to 'pages/nicknames.php')
-rw-r--r-- | pages/nicknames.php | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/pages/nicknames.php b/pages/nicknames.php new file mode 100644 index 0000000..050c275 --- /dev/null +++ b/pages/nicknames.php @@ -0,0 +1,117 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +$title = "Relations nicknames"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +$members = scoreOrderGlobal(); +$relations = []; + +foreach ($members as $member) { + foreach ([ + ...array_map(function ($i) { + $r = [ + "name" => $i + ]; + $r["type"] = "marefriends"; + return $r; + }, $member["_metadata"]["marefriends"] ?? []), + ...array_map(function ($i) { + $r = [ + "name" => $i + ]; + $r["type"] = "sisters"; + return $r; + }, $member["_metadata"]["sisters"] ?? []), + ...array_map(function ($i) { + $r = [ + "name" => $i + ]; + $r["type"] = "caretaking"; + return $r; + }, $member["_metadata"]["caretakers"] ?? []) + ] as $rel) { + $id = $rel["name"]; + $otherMember = getSystemMember(explode("/", $id)[0], explode("/", $id)[1]); + + $parts = [ + $member["id"], + $otherMember["id"] + ]; + + asort($parts); + + $relations[implode("-", $parts)] = [ + "id" => implode("", $parts), + "name" => getMiniName($member["display_name"] ?? $member["name"]) . " and " . getMiniName($otherMember["display_name"] ?? $otherMember["name"]), + "type" => $rel["type"], + "images" => [ + file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-$member[name].png") ? "/assets/uploads/pt-$member[name].png" : "/assets/uploads/pt.png", + file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-$otherMember[name].png") ? "/assets/uploads/pt-$otherMember[name].png" : "/assets/uploads/pt.png", + ] + ]; + } +} + +$nicknames = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/nicknames.json"), true); + +?> + +<br> +<div class="container"> + <div id="page-content"> + <h2>Relations nicknames</h2> + <?php foreach ($relations as $relation): ?> + <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1fr 3fr;"> + <a class="relation-intro" title="<?= $relation["id"] ?>" data-bs-toggle="tooltip" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;"> + <span style="vertical-align: middle;"><img src="<?= $relation["images"][0] ?>" style="width:24px;"><img src="<?= $relation["images"][1] ?>" style="width:24px;"></span> <span style="vertical-align: middle;"><?= $relation["name"] ?></span> + </a> + <div class="relation-item relation-item-marefriends" style="text-align:left;margin-left:10px;padding:0 20px;"> + <?php if (isset($nicknames[$relation["id"]])): ?> + "<?= implode('", "', $nicknames[$relation["id"]]) ?>" + <?php else: ?> + <span class="text-muted">No nickname for this relation</span> + <?php endif; ?> + </div> + </div> + <?php endforeach; ?> + </div> +</div> + +<style> + .relation-intro { + opacity: 1 !important; + } + + @media (max-width: 991px) { + .relation { + grid-template-columns: 1fr !important; + } + + .relation-intro { + text-align: center; + border-bottom-left-radius: 0 !important; + border-top-right-radius: 10px; + border-right: none !important; + border-bottom: 1px solid rgba(255, 255, 255, .1); + } + + .relation-item-marefriends { + margin-top: 20px !important; + text-align: center !important; + } + + .relation-item { + margin-top: 10px; + margin-left: 0 !important; + padding: 10px 0 !important; + } + } + + .relation-item { + text-align: center; + } +</style> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?> |