summaryrefslogtreecommitdiff
path: root/src/web/helpers/lang.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-02-23 22:57:27 -0500
committerFreya Murphy <freya@freyacat.org>2026-02-23 22:57:27 -0500
commitf373ead95fb5beb962c376b5b7b46dfde8ac4e57 (patch)
treec99df23521ff2a5e5e2e4627c525a5e99dc2e3ae /src/web/helpers/lang.php
parentadd 96x96 logo (diff)
downloadwebsite-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.gz
website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.bz2
website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.zip
update website to work with crimson framework
Diffstat (limited to '')
-rw-r--r--src/web/helpers/lang.php90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/web/helpers/lang.php b/src/web/helpers/lang.php
deleted file mode 100644
index 72167fc..0000000
--- a/src/web/helpers/lang.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php /* Copyright (c) 2024 Freya Murphy */
-$__lang = array();
-
-/**
- * @param ?array<string,mixed> $sub
- */
-function lang(
- string $key,
- ?string $default = NULL,
- ?array $sub = NULL) {
- $lang = $GLOBALS['__lang'];
- if(array_key_exists($key, $lang)) {
- if ($sub) {
- return sprintf($lang[$key], ...$sub);
- } else {
- return $lang[$key];
- }
- } else if ($default !== NULL) {
- return $default;
- } else {
- trigger_error('Undefined lang string: ' . $key, E_USER_WARNING);
- return $key;
- }
-}
-
-/**
- * @param array<string,string> $attrs
- * @param ?array<string,mixed> $sub
- */
-function ilang(
- string $key,
- ?string $class = NULL,
- ?string $id = NULL,
- ?string $href = NULL,
- ?string $click = NULL,
- array $attrs = array(),
- ?array $sub = NULL,
- bool $button = FALSE,
- string $container = 'span'
-) {
- $text = ucfirst(lang($key . "_text", FALSE, sub: $sub));
- $tip = lang($key . "_tip", FALSE, sub: $sub);
- $icon = lang($key . "_icon", FALSE);
- $content = lang($key . "_content", FALSE);
-
- if ($click || $button) {
- echo '<button ';
- } else {
- echo '<a ';
- }
- if ($tip) {
- echo 'title="' . $tip . '" ';
- echo 'aria-label="' . $tip . '" ';
- }
- if ($class) {
- echo 'class="' . $class . '" ';
- }
- if ($id) {
- echo 'id="' . $id . '" ';
- }
- if ($click) {
- echo 'onclick="' . $click . '" ';
- }
- if ($href) {
- echo 'href="' . $href . '" ';
- }
- foreach ($attrs as $key => $attr) {
- echo $key . '="' . $attr . '" ';
- }
- echo '> ';
- if ($icon) {
- echo '<i class="' . $icon . '">';
- if ($content) {
- echo $content;
- }
- echo '</i>';
- }
- if ($text) {
- echo '<' . $container;
- if ($icon) {
- echo ' class="ml-sm"';
- }
- echo '>' . $text . '</' . $container . '>';
- }
- if ($click || $button) {
- echo '</button>';
- } else {
- echo '</a>';
- }
-}