2013-09-18 01:38:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
|
|
|
*/
|
|
|
|
function msg() {
|
2016-09-29 09:49:25 +02:00
|
|
|
if (! isset($_SESSION['msg'])) {
|
2013-09-18 01:38:36 +02:00
|
|
|
return "";
|
2016-09-29 09:49:25 +02:00
|
|
|
}
|
2013-09-18 01:38:36 +02:00
|
|
|
$msg = $_SESSION['msg'];
|
|
|
|
$_SESSION['msg'] = "";
|
|
|
|
return $msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Information
|
|
|
|
*/
|
|
|
|
function info($msg, $immediatly = false) {
|
2016-09-29 09:49:25 +02:00
|
|
|
return alert('info', $msg, $immediatly);
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Fehlermeldung
|
|
|
|
*/
|
|
|
|
function error($msg, $immediatly = false) {
|
2016-09-29 09:49:25 +02:00
|
|
|
return alert('danger', $msg, $immediatly);
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Erfolgsmeldung
|
|
|
|
*/
|
|
|
|
function success($msg, $immediatly = false) {
|
2016-09-29 09:49:25 +02:00
|
|
|
return alert('success', $msg, $immediatly);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders an alert with given alert-* class.
|
|
|
|
*/
|
|
|
|
function alert($class, $msg, $immediatly = false) {
|
2013-09-18 01:38:36 +02:00
|
|
|
if ($immediatly) {
|
2016-09-29 09:49:25 +02:00
|
|
|
if ($msg == "") {
|
2013-09-18 01:38:36 +02:00
|
|
|
return "";
|
2016-09-29 09:49:25 +02:00
|
|
|
}
|
|
|
|
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
|
2013-09-18 01:38:36 +02:00
|
|
|
} else {
|
2016-09-29 09:49:25 +02:00
|
|
|
if (! isset($_SESSION['msg'])) {
|
2013-09-18 01:38:36 +02:00
|
|
|
$_SESSION['msg'] = "";
|
2016-09-29 09:49:25 +02:00
|
|
|
}
|
|
|
|
$_SESSION['msg'] .= alert($class, $msg, true);
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|