DK2/src/components.php

65 lines
1.4 KiB
PHP

<?php
const nav_tabs = [
'home' => 0,
'chars' => 1,
];
/**
* Render the logout button's form.
*/
function c_logout_button(): string
{
return render('components/logout_button');
}
/**
* Render the character bar. Relies on there being a character in the session. Without one, this will return an empty
* string.
*/
function c_char_bar(): string
{
if (char() === false) return '';
return render('components/char_bar', ['char' => char()]);
}
/**
* Render the left sidebar navigation menu. Provide the active tab to highlight it.
*/
function c_left_nav(int $activeTab): string
{
return render('components/left_nav', ['activeTab' => $activeTab]);
}
/**
* Render the debug query log.
*/
function c_debug_query_log(): string
{
return render('components/debug_query_log');
}
/**
* Render the character select radio buttons.
*/
function c_char_select_box(int $id, array $char): string
{
return render('components/char_select_box', ['id' => $id, 'char' => $char]);
}
/**
* Render an alert with a given type and message.
*/
function c_alert(string $t, string $m): string
{
return "<div class=\"alert $t\">$m</div>";
}
/**
* Generate a form field.
*/
function c_form_field(string $type, string $name, string $id, string $placeholder, bool $required = false): string
{
return render('components/form_field', ['type' => $type, 'name' => $name, 'id' => $id, 'placeholder' => $placeholder, 'required' => $required]);
}