mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-25 03:01:21 +08:00
made some changes, fix some pitfalls, remove PHP_EOL
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
|
||||
namespace yii\bootstrap\helpers\base;
|
||||
|
||||
use yii\bootstrap\enum\AlertEnum;
|
||||
use yii\bootstrap\enum\BootstrapEnum;
|
||||
use yii\bootstrap\enum\Enum;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/**
|
||||
@@ -20,6 +19,16 @@ use yii\helpers\Html;
|
||||
class Alert
|
||||
{
|
||||
|
||||
/**
|
||||
* constants
|
||||
*/
|
||||
const CLASS_NAME = 'alert';
|
||||
const TYPE_DEFAULT = '';
|
||||
const TYPE_SUCCESS = 'alert-success';
|
||||
const TYPE_INFORMATION = 'alert-info';
|
||||
const TYPE_ERROR = 'alert-error';
|
||||
const SIZE_BLOCK = 'alert-block';
|
||||
|
||||
/**
|
||||
* Generates an alert box
|
||||
* @param $message
|
||||
@@ -31,14 +40,14 @@ class Alert
|
||||
{
|
||||
// TODO: this method may should be added to ArrayHelper::add or ArrayHelper::append?
|
||||
if (isset($htmlOptions['class']))
|
||||
$htmlOptions['class'] .= ' ' . AlertEnum::CLASS_NAME;
|
||||
$htmlOptions['class'] .= ' ' . static::CLASS_NAME;
|
||||
else
|
||||
$htmlOptions['class'] = AlertEnum::CLASS_NAME;
|
||||
$htmlOptions['class'] = static::CLASS_NAME;
|
||||
|
||||
ob_start();
|
||||
echo Html::beginTag('div', $htmlOptions);
|
||||
if ($dismiss)
|
||||
echo Button::closeLink('×', BootstrapEnum::ALERT);
|
||||
echo Button::closeLink('×', Enum::ALERT);
|
||||
echo $message;
|
||||
echo Html::endTag('div');
|
||||
return ob_get_clean();
|
||||
|
||||
Reference in New Issue
Block a user