+<?php defined('IN_CMS') or die('No direct access allowed.');\r
+\r
+/*\r
+ Handle error, notice and success messages in the admin\r
+*/\r
+class Notifications {\r
+\r
+ public static function set($type, $message) {\r
+ $data = Session::get('notifications', array());\r
+ \r
+ if(!isset($data[$type])) {\r
+ $data[$type] = array();\r
+ }\r
+ \r
+ if(!is_array($message)) {\r
+ $message = array($message);\r
+ }\r
+ \r
+ $data[$type] = array_merge($data[$type], $message);\r
+ \r
+ Session::set('notifications', $data);\r
+ }\r
+\r
+ public static function read() {\r
+ $data = Session::get('notifications', array());\r
+ $html = '';\r
+ \r
+ foreach($data as $type => $messages) {\r
+ $html .= '<p class="notification ' . $type . '">' . implode('<br>', $messages) . '</p>';\r
+ }\r
+ \r
+ Session::forget('notifications');\r
+ \r
+ return $html;\r
+ }\r
+\r
+}\r