9 Yii::import(
'booster.widgets.TbWidget');
93 if (!isset($this->htmlOptions[
'id'])) {
94 $this->htmlOptions[
'id'] = $this->getId();
97 if (is_string($this->alerts)) {
98 $this->alerts = array($this->alerts);
102 if (!isset($this->alerts)) {
103 $this->alerts = array(
118 public function run() {
120 $id = $this->htmlOptions[
'id'];
122 echo CHtml::openTag(
'div', $this->htmlOptions);
124 foreach ($this->alerts as $type => $alert) {
126 if (is_string($alert)) {
131 if (isset($alert[
'visible']) && $alert[
'visible'] ===
false) {
136 $userComponent = Yii::app()->getComponent($this->userComponentId);
137 if (!$userComponent->hasFlash($type))
140 $alertText = $userComponent->getFlash($type);
141 if (empty($alertText)) {
148 echo CHtml::closeTag(
'div');
150 $id .=
'_' . self::$_containerId++;
151 $selector =
"#{$id} .alert";
154 $cs = Yii::app()->getClientScript();
155 $cs->registerScript(__CLASS__ .
'#' . $id,
"jQuery('{$selector}').alert();");
157 foreach ($this->events as $name => $handler) {
158 $handler = CJavaScript::encode($handler);
160 __CLASS__ .
'#' . $id .
'_' . $name,
161 "jQuery('{$selector}').on('{$name}', {$handler});"
173 $classes = array(
'alert in');
175 if (!isset($alert[
'fade'])) {
179 if ($alert[
'fade'] ===
true) {
187 if (!isset($alert[
'htmlOptions'])) {
188 $alert[
'htmlOptions'] = array();
191 $classes = implode(
' ', $classes);
192 if (isset($alert[
'htmlOptions'][
'class'])) {
193 $alert[
'htmlOptions'][
'class'] .=
' ' . $classes;
195 $alert[
'htmlOptions'][
'class'] = $classes;
198 echo CHtml::openTag(
'div', $alert[
'htmlOptions']);
202 if (!isset($alert[
'closeText'])) {
203 $alert[
'closeText'] = (isset($this->closeText) && $this->closeText !==
false)
209 if ($alert[
'closeText'] !==
false) {
210 echo
'<a href="#" class="close" data-dismiss="alert">' . $alert[
'closeText'] .
'</a>';
214 echo CHtml::closeTag(
'div');