char()]); } /** * Render the left sidebar navigation menu. Provide the active tab to highlight it. Will retrieve the current * tab from the GLOBALS. */ function c_left_nav() { return render('components/left_nav'); } /** * Render the debug query log. */ function c_debug_query_log() { return render('components/debug_query_log'); } /** * Render the character select radio buttons. */ function c_char_select_box($id, $char) { return render('components/char_select_box', ['id' => $id, 'char' => $char]); } /** * Render an alert with a given type and message. */ function c_alert($type, $message) { $a = $type !== 'danger' ? ' auto-close="5000"' : ''; return "
$message
×
"; } /** * Renders a danger alert with form errors, if there are any. Add an optional placement id. */ function c_form_errors($placement = '') { $errors = $GLOBALS[($placement !== '' ? "form-errors-$placement" : 'form-errors')] ?? false; if ($errors === false) return ''; $html = ''; foreach ($errors as $field) if (!empty($field)) foreach ($field as $message) $html .= !empty($message) ? "

$message

" : ''; return c_alert('danger', $html); } /** * Generate a text form field. This component will automatically add the error class if there are errors for this field, * depending on the form-errors GLOBAL. Pass an optional form ID to target a specific form GLOBAL. */ function c_form_field($type, $name, $placeholder, $required = false, $autocomplete = "off", $formId = '') { $errors = $GLOBALS[($formId !== '' ? "form-errors-$formId" : 'form-errors')] ?? false; $html = ""; } /** * Render the stopwatch debug component. */ function c_debug_stopwatch() { return render('components/debug_stopwatch'); }