aboutsummaryrefslogtreecommitdiff
path: root/app/class/Model.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-13 19:29:56 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-13 19:29:56 +0200
commitce3fcb72f2d5d154461a14183069bf87db1e5776 (patch)
tree34364d5cf6ef977599a465f08b57d4fe432fc750 /app/class/Model.php
parent5d1d446ff8a7e63562a0cafac6214b473f3f9baf (diff)
downloadwcms-ce3fcb72f2d5d154461a14183069bf87db1e5776.tar.gz
wcms-ce3fcb72f2d5d154461a14183069bf87db1e5776.zip
first arrival of flash messages close #85
Diffstat (limited to 'app/class/Model.php')
-rw-r--r--app/class/Model.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/class/Model.php b/app/class/Model.php
index 1d8d27a..e26a006 100644
--- a/app/class/Model.php
+++ b/app/class/Model.php
@@ -83,6 +83,13 @@ abstract class Model
'card' => 'card'
];
+ const FLASH_MESSAGE_TYPES = [
+ 'info' =>'info',
+ 'warning' => 'warning',
+ 'success' => 'success',
+ 'error' => 'error'
+ ];
+
const COLUMNS = ['id', 'favicon', 'title', 'description', 'tag', 'date', 'datemodif', 'datecreation', 'secure', 'authors', 'linkto', 'visitcount', 'affcount', 'editcount'];
const TEXT_ELEMENTS = ['header', 'nav', 'main', 'aside', 'footer'];
@@ -180,4 +187,31 @@ abstract class Model
return array_unique(array_values(self::MEDIA_EXT));
}
+ public static function getflashmessages()
+ {
+ if (!empty($_SESSION['user' . Config::basepath()]['flashmessages'])) {
+ $flashmessage = $_SESSION['user' . Config::basepath()]['flashmessages'];
+ $_SESSION['user' . Config::basepath()]['flashmessages'] = [];
+ if (is_array($flashmessage)) {
+ return $flashmessage;
+ } else {
+ return [];
+ }
+ return $flashmessage;
+ }
+ }
+
+ /**
+ * Add a message to flash message list
+ *
+ * @param string $content The message content
+ * @param string $type Message Type, can be `info|warning|success`
+ */
+ public static function sendflashmessage(string $content, string $type = 'info')
+ {
+ if (!key_exists($type, self::FLASH_MESSAGE_TYPES)) {
+ $type = 'info';
+ }
+ $_SESSION['user' . Config::basepath()]['flashmessages'][] = ['content' => $content, 'type' => $type];
+ }
}