-
Notifications
You must be signed in to change notification settings - Fork 0
/
Alert.php
39 lines (32 loc) · 1.04 KB
/
Alert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* @copyright (C) FIT-Media.com (fit-media.com), {@link http://tanitacms.net}
* Date: 27.02.15, Time: 18:48
*
* @author Dmitrij "m00nk" Sheremetjev <[email protected]>
* @package
*/
namespace m00nk\b3w;
use yii\helpers\Html;
use yii\base\Widget;
use \Yii;
class Alert extends Widget
{
public function run()
{
$html = '';
$s = Yii::$app->session;
$_ = $s->getFlash('success'); if($_) $html .= $this->_drawBox($_, 'success');
$_ = $s->getFlash('danger'); if($_) $html .= $this->_drawBox($_, 'danger');
$_ = $s->getFlash('error'); if($_) $html .= $this->_drawBox($_, 'danger');
$_ = $s->getFlash('info'); if($_) $html .= $this->_drawBox($_, 'info');
$_ = $s->getFlash('warning');if($_) $html .= $this->_drawBox($_, 'warning');
return $html;
}
private function _drawBox($text, $type = 'default')
{
return Html::tag('div',
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'.$text,
['class' => 'alert alert-dismissible alert-'.$type]);
}
}