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