Fixed error when trying to use the forum posting form.

This commit is contained in:
flash 2023-01-03 00:31:39 +00:00
parent ebabb19998
commit cb40fdc7c4
2 changed files with 5 additions and 3 deletions

View file

@ -43,7 +43,7 @@
</div>
{% endif %}
<div class="container forum__post js-forum-posting" style="{{ posting_post.poster_colour|default(current_user.colour.raw)|html_colour('--accent-colour') }}">
<div class="container forum__post js-forum-posting" style="{{ posting_post.poster_colour|default(current_user.colour)|html_colour('--accent-colour') }}">
<div class="forum__post__info">
<div class="forum__post__info__background"></div>
<div class="forum__post__info__content">

View file

@ -1,4 +1,6 @@
<?php
use \Index\Colour\Colour;
function array_test(array $array, callable $func): bool {
foreach($array as $value)
if(!$func($value))
@ -105,8 +107,8 @@ function render_info(?string $message, int $httpCode, string $template = 'errors
return \Misuzu\Template::renderRaw(sprintf($template, $httpCode));
}
function html_colour(?int $colour, $attribs = '--user-colour'): string {
$colour = (string)\Index\Colour\Colour::fromMisuzu($colour ?? 0x40000000);
function html_colour(int|null|Colour $colour, $attribs = '--user-colour'): string {
$colour = (string)($colour instanceof Colour ? $colour : Colour::fromMisuzu($colour ?? 0x40000000));
if(is_string($attribs))
$attribs = [ $attribs => '%s' ];