summaryrefslogtreecommitdiff
path: root/pages/profiles.inc
blob: 41e5222272b24dda83194fe22b023ef5358beb12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $_PROFILE; global $isLowerLoggedIn;
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/util/profiles.inc';

?>

<br>
<div class="container">
    <div id="page-content">
        <h2>Profile scores</h2>
        <?php

        $ordered = scoreOrderGlobal();

        $ordered = array_map(function ($i) {
            $i["_score"] = calculateProfileScore($i);
            return $i;
        }, $ordered);

        usort($ordered, function ($a, $b) {
            return $b["_score"]["sortable"] - $a["_score"]["sortable"];
        });

        $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($_PROFILE['login'] === "raindrops" ? "gdapd" : "ynmuc") . "/fronters.json"), true)["members"];

        ?>

        <?php if (!$isLowerLoggedIn && count($fronters) > 0): $me = $fronters[0]; $me = array_values(array_filter($ordered, function ($i) use ($me) { return $i["id"] === $me["id"]; }))[0]; ?>
        <p>Hi <b><?= $me["display_name"] ?></b>,
        <?php if ($me["_score"]["progress"] === 1): ?>
            your profile is complete, congratulations!
        <?php else: ?>
            <?php if (count($me["_score"]["actions"]) > 2): ?>
                your profile is not complete, here is all you need to do:
            <?php else: ?>
                your profile is almost complete, all there's left to do is
            <?php endif; ?>
        <?php endif; ?>

        <?php if (count($me["_score"]["actions"]) > 2 || count($me["_score"]["actions"]) === 0): ?></p><?php endif; ?>

        <?php if ($me["_score"]["progress"] === 1): ?>
            <p>You will be getting a Complete Profile badge pretty soon, so watch out for it.</p>
        <?php elseif (count($me["_score"]["actions"]) > 2): ?>
            <ul>
                <?php $index = -1; foreach ($me["_score"]["actions"] as $action): $index++; ?>
                    <li>add <?= $action ?><?= $index !== count($me["_score"]["actions"]) - 1 ? ($index !== count($me["_score"]["actions"]) - 2 ? ";" : "; and") : "" ?></li>
                <?php endforeach; ?>
            </ul>
        <?php else: ?>
            add <?= implode(" and ", $me["_score"]["actions"]) ?>.
            <p>Once you are done, you will get a Complete Profile badge.</p>
        <?php endif; ?>

        <hr>
        <?php endif; ?>

        <?php foreach ($ordered as $member): ?>
        <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1.5fr 6fr;">
            <a class="relation-intro" 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;" href="/<?= $member["name"] ?>">
                <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?>
            </a>

            <div style="margin: -10px -10px -10px 10px;background: linear-gradient(90deg, rgba(255, 255, 255, .1) 0%, rgba(255, 255, 255, .1) <?= round($member["_score"]["progress"] * 100) ?>%, transparent <?= round($member["_score"]["progress"] * 100) ?>.000001%);border-top-right-radius: 10px;border-bottom-right-radius: 10px;display: flex;align-items: center;">
                <div style="margin-left: 10px; width: 100%;">
                    <?php if (count($member["_score"]["actions"]) < 3): ?>
                        Add <?= implode(" and ", $member["_score"]["actions"]) ?> to get to 100%
                    <?php else: ?>
                        <?= round($member["_score"]["progress"] * 100) ?>% complete
                    <?php endif; ?>

                    <div id="icons" style="float:right; margin-right: 10px;">
                        <span title="<?= $member["_score"]["values"][5] ? "This member has a Pony Town character" : "This member does not have a Pony Town character" ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/ponytown.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][5] ? "1" : ".25" ?>;">
                        </span>
                        <span title="<?= $member["_score"]["values"][6] ? "This member has a color" : "This member does not have a color" ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/color.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][6] ? "1" : ".25" ?>;">
                        </span>
                        <span title="<?= $member["_score"]["values"][2] ? "This member has a public page that is over 200 letters long" : ($member["_score"]["pages"][0] ? "This member has a public page but it is only " . $member["_score"]["characters"][0] . " characters long" : "This member does not have a public page") ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/global.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][2] ? "1" : ($member["_score"]["pages"][0] ? ".5" : ".25") ?>;">
                        </span>
                        <span title="<?= $member["_score"]["values"][3] ? "This member has a public page that is over 200 letters long" : ($member["_score"]["pages"][1] ? "This member has a public page but it is only " . $member["_score"]["characters"][1] . " characters long" : "This member does not have a public page") ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/logout.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][3] ? "1" : ($member["_score"]["pages"][1] ? ".5" : ".25") ?>;">
                        </span>
                        <span title="<?= $member["_score"]["values"][0] ? "This member has their age entered" : (in_array("alicorn", $member["_metadata"]["species"]) ? "This member does not have their age entered, but this might be because they are an alicorn" : "This member does not have their age entered") ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/age.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][0] ? "1" : (in_array("alicorn", $member["_metadata"]["species"]) ? ".5" : ".25") ?>;">
                        </span>
                        <span title="<?= $member["_score"]["values"][4] ? "This member has a banner" : "This member does not have a banner" ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/banner.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][4] ? "1" : ".25" ?>;">
                        </span>
                        <span title="<?= $member["_score"]["values"][1] ? "This member has their birth date entered" : "This member does not have their birth date entered" ?>" data-bs-toggle="tooltip">
                            <img alt="" src="/assets/icons/splitting.svg" style="filter: invert(1); opacity: <?= $member["_score"]["values"][1] ? "1" : ".25" ?>;">
                        </span>
                    </div>
                </div>
            </div>
        </div>
        <?php endforeach; ?>
    </div>
</div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>