Skip to content

Commit 9497839

Browse files
committed
Merge branch 'panel-helper'
Conflicts: README.md src/View/Helper/BootstrapPaginatorHelper.php src/View/Helper/BootstrapPanelHelper.php
2 parents 1afc168 + beaf4ea commit 9497839

File tree

5 files changed

+307
-346
lines changed

5 files changed

+307
-346
lines changed

README.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/View/Helper/BootstrapModalHelper.php

Lines changed: 71 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class BootstrapModalHelper extends Helper {
3131
public $helpers = ['Html'];
3232

3333
public $current = NULL ;
34-
34+
3535
/**
36-
*
37-
* Create a Twitter Bootstrap like modal.
36+
*
37+
* Create a Twitter Bootstrap like modal.
3838
*
3939
* @param array|string $title If array, works as $options, otherwize used as the modal title.
40-
* @param array $options Options for the main div of the modal.
40+
* @param array $options Options for the main div of the modal.
4141
*
4242
* Extra options (useless if $title not specified) :
4343
* - close: Add close buttons to header (default true)
@@ -60,40 +60,43 @@ public function create($title = null, $options = array()) {
6060
$options['aria-labelledby'] = $this->currentId.'Label' ;
6161
}
6262
$options['size'] = $this->_extractOption('size', $options, '');
63-
switch($options['size']) {
64-
case 'lg':
65-
case 'large':
66-
case 'modal-lg':
67-
$size = 'modal-lg';
68-
break;
69-
case 'sm':
70-
case 'small':
71-
case 'modal-sm':
72-
$size = 'modal-sm';
73-
break;
74-
default:
75-
$size = '';
76-
break;
77-
}
78-
unset($options['size']);
79-
80-
$res = $this->Html->div('modal fade '.$this->_extractOption('class', $options, ''), NULL, $options).$this->Html->div('modal-dialog '.$size).$this->Html->div('modal-content');
63+
switch($options['size']) {
64+
case 'lg':
65+
case 'large':
66+
case 'modal-lg':
67+
$size = 'modal-lg';
68+
break;
69+
case 'sm':
70+
case 'small':
71+
case 'modal-sm':
72+
$size = 'modal-sm';
73+
break;
74+
default:
75+
$size = '';
76+
break;
77+
}
78+
unset($options['size']);
79+
80+
$res = $this->Html->div('modal fade '.$this->_extractOption('class', $options, ''),
81+
null, $options)
82+
.$this->Html->div('modal-dialog '.$size).$this->Html->div('modal-content');
8183
if (is_string($title) && $title) {
8284
$res .= $this->_createHeader($title, array('close' => $close)) ;
8385
if (!$nobody) {
8486
$res .= $this->_startPart('body');
8587
}
8688
}
8789
return $res ;
88-
}
89-
90+
}
91+
9092
/**
91-
*
92-
* End a modal. If $buttons is not null, the ModalHelper::footer functions is called with $buttons and $options arguments.
93+
*
94+
* End a modal. If $buttons is not null, the ModalHelper::footer functions is called
95+
* with $buttons and $options arguments.
9396
*
9497
* @param array|null $buttons
9598
* @param array $options
96-
*
99+
*
97100
**/
98101
public function end ($buttons = NULL, $options = array()) {
99102
$res = '' ;
@@ -105,7 +108,7 @@ public function end ($buttons = NULL, $options = array()) {
105108
$res .= $this->footer($buttons, $options) ;
106109
}
107110
$res .= '</div></div></div>' ;
108-
return $res ;
111+
return $res ;
109112
}
110113

111114
protected function _cleanCurrent () {
@@ -120,42 +123,56 @@ protected function _createHeader ($title, $options = array()) {
120123
$close = $this->_extractOption('close', $options, true);
121124
unset($options['close']) ;
122125
if ($close) {
123-
$button = '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' ;
126+
$button = '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">'
127+
.'&times;'
128+
.'</button>' ;
124129
}
125130
else {
126131
$button = '' ;
127132
}
128-
return $this->_cleanCurrent().$this->Html->div('modal-header '.$this->_extractOption('class', $options, ''),
129-
$button.$this->Html->tag('h4', $title, array('class' => 'modal-title', 'id' => $this->currentId ? $this->currentId.'Label' : false)),
130-
$options
131-
) ;
133+
return $this->_cleanCurrent()
134+
.$this->Html->div('modal-header '.$this->_extractOption('class', $options, ''),
135+
$button.$this->Html->tag('h4', $title, [
136+
'class' => 'modal-title',
137+
'id' => $this->currentId ? $this->currentId.'Label' : false
138+
]),
139+
$options
140+
) ;
132141
}
133142

134143
protected function _createBody ($text, $options = array()) {
135-
return $this->_cleanCurrent().$this->Html->div('modal-body '.$this->_extractOption('class', $options, ''), $text, $options) ;
144+
return $this->_cleanCurrent()
145+
.$this->Html->div('modal-body '.$this->_extractOption('class', $options, ''),
146+
$text, $options) ;
136147
}
137148

138149
protected function _createFooter ($buttons = NULL, $options = array()) {
139150
if ($buttons == NULL) {
140151
$close = $this->_extractOption('close', $options, true);
141152
unset($options['close']) ;
142153
if ($close) {
143-
$buttons = '<button type="button" class="btn btn-default" data-dismiss="modal">'.__('Close').'</button>' ;
154+
$buttons = '<button type="button" class="btn btn-default" data-dismiss="modal">'
155+
.__('Close')
156+
.'</button>' ;
144157
}
145158
else {
146159
$buttons = '' ;
147160
}
148161
}
149-
return $this->_cleanCurrent().$this->Html->div('modal-footer '.$this->_extractOption('class', $options, ''), $buttons, $options) ;
162+
return $this->_cleanCurrent()
163+
.$this->Html->div('modal-footer '.$this->_extractOption('class', $options, ''),
164+
$buttons, $options) ;
150165
}
151-
166+
152167
protected function _startPart ($part, $options = array()) {
153168
$res = '' ;
154169
if ($this->current != NULL) {
155170
$res = $this->_endPart () ;
156171
}
157172
$this->current = $part ;
158-
return $res.$this->Html->div('modal-'.$part.' '.$this->_extractOption('class', $options, ''), NULL, $options) ;
173+
return $res
174+
.$this->Html->div('modal-'.$part.' '.$this->_extractOption('class', $options, ''),
175+
null, $options) ;
159176
}
160177

161178
protected function _endPart () {
@@ -164,11 +181,12 @@ protected function _endPart () {
164181

165182
/**
166183
*
167-
* Create / Start the header. If $info is specified as a string, create and return the whole header, otherwize only open the header.
168-
*
184+
* Create / Start the header. If $info is specified as a string, create and return the
185+
* whole header, otherwize only open the header.
186+
*
169187
* @param array|string $info If string, use as the modal title, otherwize works as $options.
170188
* @param array $options Options for the header div.
171-
*
189+
*
172190
* Special option (if $info is string):
173191
* - close: Add the 'close' button in the header (default true).
174192
*
@@ -182,11 +200,12 @@ public function header ($info = NULL, $options = array()) {
182200

183201
/**
184202
*
185-
* Create / Start the body. If $info is not null, it is used as the body content, otherwize start the body div.
186-
*
203+
* Create / Start the body. If $info is not null, it is used as the body content,
204+
* otherwize start the body div.
205+
*
187206
* @param array|string $info If string, use as the body content, otherwize works as $options.
188207
* @param array $options Options for the footer div.
189-
*
208+
*
190209
*
191210
**/
192211
public function body ($info = NULL, $options = array()) {
@@ -199,17 +218,15 @@ public function body ($info = NULL, $options = array()) {
199218
return $this->_startPart('body', is_array($info) ? $info : $options) ;
200219
}
201220

202-
protected function _isAssociativeArray ($array) {
203-
return array_keys($array) !== range(0, count($array) - 1);
204-
}
205-
206221
/**
207222
*
208-
* Create / Start the footer. If $buttons is specified as an associative arrays or as null, start the footer, otherwize create the footer with the specified buttons.
209-
*
210-
* @param array|string $buttons If string, use as the footer content, if list, concatenate values in the list as content (use for buttons purpose), otherwize works as $options.
223+
* Create / Start the footer. If $buttons is specified as an associative arrays or as null,
224+
* start the footer, otherwize create the footer with the specified buttons.
225+
*
226+
* @param array|string $buttons If string, use as the footer content, if list, concatenate
227+
* values in the list as content (use for buttons purpose), otherwize works as $options.
211228
* @param array $options Options for the footer div.
212-
*
229+
*
213230
* Special option (if $buttons is NOT NULL but empty):
214231
* - close: Add the 'close' button to the footer (default true).
215232
*
@@ -221,7 +238,8 @@ public function footer ($buttons = [], $options = []) {
221238
if (empty($buttons)) {
222239
return $this->_createFooter(NULL, $options) ;
223240
}
224-
return $this->_createFooter(is_string($buttons) ? $buttons : implode('', $buttons), $options) ;
241+
return $this->_createFooter(is_string($buttons) ? $buttons : implode('', $buttons),
242+
$options) ;
225243
}
226244

227245
}

0 commit comments

Comments
 (0)