Every other type will lead to an error message indicating an invalid message type. * @param string $MessageHeadline The headline of the status message. *
It may be formatted with special color/link/bold tags. * @param string $MessageText The text of the status message. *
It may be formatted with special color/link/bold tags. This parameter is optional. * @param string[]|string|null $MessageVariables The variables that are used to replace the spacers (%s) in the * submitted text. This parameter is optional. * @param bool $returnOutput if set to true this function will return the generated HTML code instead of printing it directly (default: false) * @return string HTML code if $returnOutput is set to true, otherwise null */ function StatusMessage($MessageTyp, $MessageHeadline, $MessageText = '', array|string|null $MessageVariables = [], bool $returnOutput = false): string { /* Setting CSS-StyleSheet class depending on the $MessageTyp and rewriting $MessageTyp with a readable string. */ if ($MessageTyp == "INFO") { $class = "class=\"statusInfo lam-status-message\""; } elseif ($MessageTyp == "WARN") { $class = "class=\"statusWarn lam-status-message\""; } elseif ($MessageTyp == "ERROR") { $class = "class=\"statusError lam-status-message\""; } /* Set output-message, when none or false $MessageTyp is submitted. */ else { $class = "class=\"statusError lam-status-message\""; $MessageHeadline = "Invalid/Missing Message type"; $MessageText = "Please report this error to the Bug-Tracker at {link=http://www.ldap-account-manager.org/}LDAP Account Manager Development Team{endlink}. Thank you."; } $MessageHeadline = "
" . $MessageHeadline . "
"; // Format $MessageHeadline if ($MessageText != '') { $MessageText = "

" . $MessageText . "

"; // Format $MessageText } $format = "
\n\n\n\n\n
" . $MessageHeadline . $MessageText . "
\n
\n"; if (is_array($MessageVariables)) { if ($MessageVariables !== []) { array_unshift($MessageVariables, $format); $output = call_user_func_array(sprintf(...), $MessageVariables); } else { $output = $format; } } elseif ($MessageVariables !== null) { $output = sprintf($format, $MessageVariables); } else { $output = $format; } if ($returnOutput) { return $output; } else { echo $output; } return ''; }