From 34b1b391d4b03659a96f868857c230002b351514 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Mon, 9 Sep 2024 17:57:00 +0200 Subject: More updates --- src/application/mystic/forum/Messaging.php | 101 +++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/application/mystic/forum/Messaging.php (limited to 'src/application/mystic/forum/Messaging.php') diff --git a/src/application/mystic/forum/Messaging.php b/src/application/mystic/forum/Messaging.php new file mode 100644 index 0000000..2f5c80d --- /dev/null +++ b/src/application/mystic/forum/Messaging.php @@ -0,0 +1,101 @@ +\n"; + echo "
\n"; + + echo "
\n"; + echo "".htmlentities($headerText, self::ENT_FLAGS)."\n"; + echo "
\n"; + + echo "
\n"; + + echo "
\n"; + + foreach ($items as $item) { + if (is_scalar($item)) { + echo "

" . htmlentities(strval($item), self::ENT_FLAGS) . "

\n"; + } elseif (is_array($item)) { + if (count(array_keys($item)) === 2 && isset($item["___!type"]) && isset($item["___!content"])) { + // special item + switch ($item["___!type"]) { + case "HTML": + echo $item["___!content"]; + break; + default: + echo "invalid"; + break; + } + } elseif (array_is_list($item)) { + echo "
    \n"; + foreach ($item as $i) + echo "
  • " . htmlentities($i, self::ENT_FLAGS) . "
  • \n"; + echo "
\n"; + } else { + echo "\n"; + foreach ($item as $k => $i) { + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + } + echo "
" . htmlentities($k, self::ENT_FLAGS) . ""; + if (is_scalar($i)) { + echo htmlentities($i, self::ENT_FLAGS); + } else { + echo gettype($i); + } + echo "
\n"; + } + } else { + echo gettype($item); + } + } + + echo "
\n"; + + echo "
\n"; + echo "\n"; + } + + public static function bold(string $contents): array { + return self::html("

" . htmlentities($contents, self::ENT_FLAGS) . "

\n"); + } + + public static function italic(string $contents): array { + return self::html("

" . htmlentities($contents, self::ENT_FLAGS) . "

\n"); + } + + public static function bold_italic(string $contents): array { + return self::html("

" . htmlentities($contents, self::ENT_FLAGS) . "

\n"); + } + + public static function html(string $contents): array { + return [ + "___!type" => "HTML", + "___!content" => $contents, + ]; + } + + public static function info(string|array $contents): void { + if (is_string($contents)) + $contents = [$contents]; + self::message($contents, "INFORMATION", "SKYBLUE", "BLACK"); + } + + public static function error(string|array $contents): void { + if (is_string($contents)) + $contents = [$contents]; + self::message($contents, "ERROR", "RED", "WHITE"); + } +} -- cgit v1.2.3