You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.4 KiB
PHTML

<?php
/**
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
*
* @return string
*/
8 years ago
function msg()
{
8 years ago
if (!isset($_SESSION['msg'])) {
8 years ago
return "";
}
$msg = $_SESSION['msg'];
$_SESSION['msg'] = "";
return $msg;
}
/**
* Rendert eine Information
*
* @param string $msg
* @param bool $immediately
* @return string
*/
function info($msg, $immediately = false)
8 years ago
{
return alert('info', $msg, $immediately);
}
/**
* Rendert eine Fehlermeldung
*
* @param string $msg
* @param bool $immediately
* @return string
*/
function error($msg, $immediately = false)
8 years ago
{
return alert('danger', $msg, $immediately);
}
/**
* Rendert eine Erfolgsmeldung
*
* @param string $msg
* @param bool $immediately
* @return string
*/
function success($msg, $immediately = false)
8 years ago
{
return alert('success', $msg, $immediately);
}
/**
* Renders an alert with given alert-* class.
*
* @param string $class
* @param string $msg
* @param bool $immediately
* @return string|null
*/
function alert($class, $msg, $immediately = false)
8 years ago
{
if ($immediately) {
8 years ago
if ($msg == "") {
return "";
}
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
}
8 years ago
if (!isset($_SESSION['msg'])) {
8 years ago
$_SESSION['msg'] = "";
}
$_SESSION['msg'] .= alert($class, $msg, true);
return null;
}