2016-07-09 01:55:03 +02:00
|
|
|
<?php
|
2019-04-10 10:37:35 +02:00
|
|
|
class StatusMessages
|
|
|
|
{
|
|
|
|
public $messages = array();
|
2016-07-09 01:55:03 +02:00
|
|
|
|
2019-04-10 10:37:35 +02:00
|
|
|
public function addMessage($message, $level = 'success', $dismissable = true)
|
|
|
|
{
|
|
|
|
$status = '<div class="alert alert-'.$level;
|
|
|
|
if ($dismissable) {
|
|
|
|
$status .= ' alert-dismissable';
|
|
|
|
}
|
|
|
|
$status .= '">'. _($message);
|
|
|
|
if ($dismissable) {
|
|
|
|
$status .= '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>';
|
|
|
|
}
|
|
|
|
$status .= '</div>';
|
2016-07-09 01:55:03 +02:00
|
|
|
|
2019-04-10 10:37:35 +02:00
|
|
|
array_push($this->messages, $status);
|
|
|
|
}
|
2016-07-09 01:55:03 +02:00
|
|
|
|
2019-04-10 10:37:35 +02:00
|
|
|
public function showMessages($clear = true)
|
|
|
|
{
|
|
|
|
foreach ($this->messages as $message) {
|
|
|
|
echo $message;
|
|
|
|
}
|
|
|
|
if ($clear) {
|
|
|
|
$this->messages = array();
|
|
|
|
}
|
2016-07-09 02:00:53 +02:00
|
|
|
}
|
2016-07-09 01:55:03 +02:00
|
|
|
}
|