diff --git a/widgets/Modal.php b/widgets/Modal.php index bbc7795..85fbede 100644 --- a/widgets/Modal.php +++ b/widgets/Modal.php @@ -1,5 +1,4 @@ initOptions(); - echo $this->renderToggleButton() . "\n"; - echo Html::beginTag('div', $this->options) . "\n"; - echo $this->renderHeader() . "\n"; - echo $this->renderBodyBegin() . "\n"; + echo $this->renderToggleButton()."\n"; + echo Html::beginTag('div', $this->options)."\n"; + echo $this->renderHeader()."\n"; + echo $this->renderBodyBegin()."\n"; } /** @@ -100,9 +104,9 @@ public function init() */ public function run() { - echo "\n" . $this->renderBodyEnd(); - echo "\n" . $this->renderFooter(); - echo "\n" . Html::endTag('div'); + echo "\n".$this->renderBodyEnd(); + echo "\n".$this->renderFooter(); + echo "\n".Html::endTag('div'); ModalAsset::register($this->view); //$this->registerPlugin('spinner'); @@ -114,14 +118,28 @@ public function run() */ protected function renderHeader() { + $html = ''; + $button = $this->renderCloseButton(); + if ($button !== null) { - $this->title = $button . "\n" . Html::tag('h4', $this->title, ['class' => 'modal-title']); + $html = $button; } + if ($this->title !== null) { - return Html::tag('div', "\n" . $this->title . "\n", ['class' => 'modal-header']); + $html .= Html::tag('h4', $this->title, ['class' => 'modal-title']); + } + + if ($this->subtitle !== null) + { + $html .= Html::tag('p', $this->subtitle, ['class' => 'modal-subtitle']); + } + + if ($html) + { + return Html::tag('div', "\n".$html."\n", ['class' => 'modal-header']); } else { @@ -155,7 +173,7 @@ protected function renderFooter() { if ($this->footer !== null) { - return Html::tag('div', "\n" . $this->footer . "\n", ['class' => 'modal-footer']); + return Html::tag('div', "\n".$this->footer."\n", ['class' => 'modal-footer']); } else { @@ -210,7 +228,7 @@ protected function initOptions() $this->options = array_merge([ 'class' => 'fade', 'tabindex' => -1, - ], $this->options); + ], $this->options); Html::addCssClass($this->options, 'modal'); if ($this->fullWidth) { @@ -231,19 +249,18 @@ protected function initOptions() 'data-dismiss' => 'modal', 'aria-hidden' => 'true', 'class' => 'close', - ], $this->closeButton); + ], $this->closeButton); } if (!empty($this->toggleButton)) { $this->toggleButton = array_merge([ 'options' => ['data-toggle' => 'modal'], - ], $this->toggleButton); + ], $this->toggleButton); if (!isset($this->toggleButton['options']['data-target']) && !isset($this->toggleButton['options']['href'])) { - $this->toggleButton['options']['data-target'] = '#' . $this->options['id']; + $this->toggleButton['options']['data-target'] = '#'.$this->options['id']; } } } - -} +} \ No newline at end of file