summaryrefslogtreecommitdiff
path: root/includes/helper/message_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/helper/message_helper.php')
-rw-r--r--includes/helper/message_helper.php78
1 files changed, 52 insertions, 26 deletions
diff --git a/includes/helper/message_helper.php b/includes/helper/message_helper.php
index 37fc84bb..4fa0efe3 100644
--- a/includes/helper/message_helper.php
+++ b/includes/helper/message_helper.php
@@ -2,52 +2,78 @@
/**
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
+ *
+ * @return string
*/
-function msg() {
- if (! isset($_SESSION['msg'])) {
- return "";
- }
- $msg = $_SESSION['msg'];
- $_SESSION['msg'] = "";
- return $msg;
+function msg()
+{
+ $session = session();
+
+ $message = $session->get('msg', '');
+ $session->set('msg', '');
+
+ return $message;
}
/**
* Rendert eine Information
+ *
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function info($msg, $immediatly = false) {
- return alert('info', $msg, $immediatly);
+function info($msg, $immediately = false)
+{
+ return alert('info', $msg, $immediately);
}
/**
* Rendert eine Fehlermeldung
+ *
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function error($msg, $immediatly = false) {
- return alert('danger', $msg, $immediatly);
+function error($msg, $immediately = false)
+{
+ return alert('danger', $msg, $immediately);
}
/**
* Rendert eine Erfolgsmeldung
+ *
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function success($msg, $immediatly = false) {
- return alert('success', $msg, $immediatly);
+function success($msg, $immediately = false)
+{
+ return alert('success', $msg, $immediately);
}
/**
* Renders an alert with given alert-* class.
+ *
+ * @param string $class
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function alert($class, $msg, $immediatly = false) {
- if ($immediatly) {
- if ($msg == "") {
- return "";
+function alert($class, $msg, $immediately = false)
+{
+ $session = session();
+
+ if (empty($msg)) {
+ return '';
}
- return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
- }
-
- if (! isset($_SESSION['msg'])) {
- $_SESSION['msg'] = "";
- }
- $_SESSION['msg'] .= alert($class, $msg, true);
-}
-?> \ No newline at end of file
+ if ($immediately) {
+ return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
+ }
+
+ $message = $session->get('msg', '');
+ $message .= alert($class, $msg, true);
+ $session->set('msg', $message);
+
+ return '';
+}