2013-09-18 01:38:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @return string
|
2013-09-18 01:38:36 +02:00
|
|
|
*/
|
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-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $msg
|
|
|
|
* @param bool $immediately
|
|
|
|
* @return string
|
2013-09-18 01:38:36 +02:00
|
|
|
*/
|
2017-01-03 03:22:48 +01:00
|
|
|
function info($msg, $immediately = false)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2017-01-03 03:22:48 +01:00
|
|
|
return alert('info', $msg, $immediately);
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Fehlermeldung
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $msg
|
|
|
|
* @param bool $immediately
|
|
|
|
* @return string
|
2013-09-18 01:38:36 +02:00
|
|
|
*/
|
2017-01-03 03:22:48 +01:00
|
|
|
function error($msg, $immediately = false)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2017-01-03 03:22:48 +01:00
|
|
|
return alert('danger', $msg, $immediately);
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rendert eine Erfolgsmeldung
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $msg
|
|
|
|
* @param bool $immediately
|
|
|
|
* @return string
|
2013-09-18 01:38:36 +02:00
|
|
|
*/
|
2017-01-03 03:22:48 +01:00
|
|
|
function success($msg, $immediately = false)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2017-01-03 03:22:48 +01:00
|
|
|
return alert('success', $msg, $immediately);
|
2016-09-29 09:49:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders an alert with given alert-* class.
|
2017-01-03 03:22:48 +01:00
|
|
|
*
|
|
|
|
* @param string $class
|
|
|
|
* @param string $msg
|
|
|
|
* @param bool $immediately
|
|
|
|
* @return string|null
|
2016-09-29 09:49:25 +02:00
|
|
|
*/
|
2017-01-03 03:22:48 +01:00
|
|
|
function alert($class, $msg, $immediately = false)
|
2017-01-02 03:57:23 +01:00
|
|
|
{
|
2017-01-03 03:22:48 +01:00
|
|
|
if ($immediately) {
|
2017-01-02 03:57:23 +01:00
|
|
|
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);
|
2017-01-03 03:22:48 +01:00
|
|
|
|
|
|
|
return null;
|
2013-09-18 01:38:36 +02:00
|
|
|
}
|