diff options
author | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
commit | 2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 (patch) | |
tree | 17848d95522dab25d3cdeb9c4a6450e2a234861f /includes/titlebar.inc | |
parent | 108525534c28013cfe1897c30e4565f9893f3766 (diff) | |
download | pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.gz pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.bz2 pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.zip |
Update
Diffstat (limited to 'includes/titlebar.inc')
-rw-r--r-- | includes/titlebar.inc | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/includes/titlebar.inc b/includes/titlebar.inc new file mode 100644 index 0000000..de58549 --- /dev/null +++ b/includes/titlebar.inc @@ -0,0 +1,182 @@ +<?php global $toplevel; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); ?> +<span> + <?php + +$parts = explode("/", $_GET['_']); +$name = $toplevel === "" ? "home" : $toplevel; + +$actionsProfile = "default"; +$part1 = "<page>"; +$part2 = null; +$part3 = null; + +if (isset($pages[$name])) { + if (($name === "docs" || $name === "toys" || $name === "actions") && isset($parts[2])) { + $part3 = "<a class='title-bar-backlink' href='/-/dashboard'>Dashboard</a>"; + $part2 = "<a class='title-bar-backlink' href='/-/$name'>" . $pages[$name]['name'] . "</a>"; + + if ($name === "docs") { + $actionsProfile = "docs-item"; + $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $parts[2] . ".json"), true)["name"]; + } else { + $actionsProfile = "$name-item"; + $list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($name === "toys" ? "toys/toys" : "actions/actions") . ".json"), true); + $part1 = array_values(array_filter($list, function ($i) use ($parts) { + return $i["id"] === $parts[2]; + }))[0]["name"]; + } + } else { + if ($pages[$name]["admin"]) { + $part1 = $pages[$name]['name']; + $part2 = "<a class='title-bar-backlink' href='/-/dashboard'>Dashboard</a>"; + } else { + $part1 = $pages[$name]['name']; + } + } +} elseif ($name === "cloudburst") { + if (isset($parts[2])) { + $part2 = "<a class='title-bar-backlink' href='/cloudburst'>Cloudburst System</a>"; + + if ($parts[2] === "subsystem") { + $actionsProfile = "subsystem"; + $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/ynmuc-$parts[3].json"), true)["name"]; + } else { + $part1 = $pages["s:" . $parts[2]]['name'] ?? $parts[2]; + } + } else { + $actionsProfile = "system"; + $part1 = "Cloudburst System"; + } +} elseif ($name === "raindrops") { + if (isset($parts[2])) { + $part2 = "<a class='title-bar-backlink' href='/raindrops'>Raindrops System</a>"; + + if ($parts[2] === "subsystem") { + $actionsProfile = "subsystem"; + $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/subsystems/gdapd-$parts[3].json"), true)["name"]; + } else { + $part1 = $pages["s:" . $parts[2]]['name'] ?? $parts[2]; + } + } else { + $actionsProfile = "system"; + $part1 = "Raindrops System"; + } +} else { + $member = getMemberFromName($name); + $actionsProfile = "member"; + + if (isset($member)) { + $memberName = $member["display_name"] ?? $member["name"]; + $part1 = "$memberName"; + + if ($member["_system"] === "gdapd") { + $part2 = "<a class='title-bar-backlink' href='/raindrops'>Raindrops System</a>"; + } else { + $part2 = "<a class='title-bar-backlink' href='/cloudburst'>Cloudburst System</a>"; + } + } else { + $part1 = "$name"; + } +} + +if ($actionsProfile === "default") { + switch ($name) { + case "home": + $actionsProfile = "home"; + break; + + case "emergency": + case "wakeup": + case "pleasure": + $actionsProfile = "alert"; + break; + + case "fronting": + $actionsProfile = "planner"; + break; + + case "actions": + case "toys": + $actionsProfile = "actions-or-toys"; + break; + + case "docs": + $actionsProfile = "docs"; + break; + + case "debug": + $actionsProfile = "debug"; + break; + + case "bitset": + $actionsProfile = "bitset"; + break; + + case "parser": + case "prefix": + $actionsProfile = "parser-prefix"; + break; + } +} + +if (isset($part3)) { + echo "$part3 > $part2 > <b>$part1</b>"; +} elseif (isset($part2)) { + echo "$part2 > <b>$part1</b>"; +} else { + echo "<b>$part1</b>"; +} + +$links = [ + "default" => [ + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ] +]; + +$linksList = $links[isset($links[$actionsProfile]) ? $actionsProfile : "default"]; + +?> (<code><?= $actionsProfile ?></code>)<!--<pre><?php var_dump($parts); ?></pre>--> + <span id="title-bar-actions"> + <?php foreach ($linksList as $index => $link): ?> + <a style="display: inline-block; padding: 4px;" id="title-bar-action-<?= $index ?>" <?php if ($link["link"]["type"] === "url"): ?>href<?php else: ?>onclick<?php endif; ?>="<?= $link["link"]["text"] ?>" title="<?= $link["name"] ?>" data-bs-toggle="tooltip" class="title-bar-action tooltip-nohelp"> + <img src="<?= $link["icon"] ?>" <?php if ($link["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px;vertical-align: middle;"> + </a> + <?php endforeach; ?> + </span> +</span> + +<style> + .title-bar-backlink { + color: white !important; + text-decoration: none; + } + + .title-bar-backlink:hover { + opacity: .75; + } + + #title-bar-actions { + position: fixed; + right: 0; + height: 34px; + top: 0; + display: block; + border-left: 1px solid rgba(255, 255, 255, .25); + } + + .title-bar-action { + cursor: pointer; + } + + .title-bar-action:hover { + background-color: rgba(255, 255, 255, .1); + } +</style>
\ No newline at end of file |