mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Migrate includes/status_message.php to RaspAP/Messages
This commit is contained in:
parent
c2d740ef44
commit
07b950cf65
1 changed files with 41 additions and 0 deletions
41
src/RaspAP/Messages/StatusMessage.php
Executable file
41
src/RaspAP/Messages/StatusMessage.php
Executable file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Status message class
|
||||
*
|
||||
* @description Status message class for RaspAP
|
||||
* @author Bill Zimmerman <billzimmerman@gmail.com>
|
||||
* @license https://github.com/raspap/raspap-webgui/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace RaspAP\Messages;
|
||||
|
||||
class StatusMessage
|
||||
{
|
||||
public $messages = array();
|
||||
|
||||
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>';
|
||||
|
||||
array_push($this->messages, $status);
|
||||
}
|
||||
|
||||
public function showMessages($clear = true)
|
||||
{
|
||||
foreach ($this->messages as $message) {
|
||||
echo $message;
|
||||
}
|
||||
if ($clear) {
|
||||
$this->messages = array();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue