public static function alert($color, $message, $htmlOptions = array())
{
self::addCssClass('alert', $htmlOptions);
if (!empty($color)) {
self::addCssClass('alert-' . $color, $htmlOptions);
}
if (TbArray::popValue('in', $htmlOptions, true)) {
self::addCssClass('in', $htmlOptions);
}
if (TbArray::popValue('block', $htmlOptions, false)) {
self::addCssClass('alert-block', $htmlOptions);
}
if (TbArray::popValue('fade', $htmlOptions, true)) {
self::addCssClass('fade', $htmlOptions);
}
$closeText = TbArray::popValue('closeText', $htmlOptions, self::CLOSE_TEXT);
$closeOptions = TbArray::popValue('closeOptions', $htmlOptions, array());
$closeOptions['dismiss'] = self::CLOSE_DISMISS_ALERT;
$output = self::openTag('div', $htmlOptions);
$output .= $closeText !== false ? self::closeLink($closeText, '#', $closeOptions) : '';
$output .= $message;
$output .= '</div>';
return $output;
}
/** * Runs the widget. */ public function run() { /* @var $user CWebUser */ $user = Yii::app()->getUser(); echo CHtml::openTag('div', $this->htmlOptions); foreach ($this->alerts as $style => $alert) { if (isset($alert['visible']) && !$alert['visible']) { continue; } if ($user->hasFlash($style)) { $htmlOptions = TbHtml::popOption('htmlOptions', $alert, array()); $htmlOptions = TbHtml::defaultOption('closeText', $this->closeText, $htmlOptions); $htmlOptions = TbHtml::defaultOption('block', $this->block, $htmlOptions); $htmlOptions = TbHtml::defaultOption('fade', $this->fade, $htmlOptions); echo TbHtml::alert($style, $user->getFlash($style), $htmlOptions); } } echo '</div>'; $this->registerEvents("#{$this->htmlOptions['id']} > .alert", $this->events); }