Skip to content

Commit f4b528d

Browse files
author
Mikaël Capelle
committed
Update documentation.
1 parent 671f40c commit f4b528d

File tree

3 files changed

+93
-20
lines changed

3 files changed

+93
-20
lines changed

src/View/Helper/BootstrapFormHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BootstrapFormHelper extends FormHelper {
3434
];
3535

3636
/**
37-
* Default config for the helper.
37+
* Default configuration for the helper.
3838
*
3939
* - `idPrefix` See CakePHP `FormHelper`.
4040
* - `errorClass` See CakePHP `FormHelper`. Overriden by `'has-error'`.

src/View/Helper/BootstrapModalHelper.php

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,66 @@ class BootstrapModalHelper extends Helper {
2020

2121
use BootstrapTrait ;
2222

23+
/**
24+
* Other helpers used by BootstrapModalHelper.
25+
*
26+
* @var array
27+
*/
2328
public $helpers = ['Html'];
2429

30+
/**
31+
* Current part of the modal (`null`, `'header'`, `'body'`, `'footer'`).
32+
*
33+
* @var string
34+
*/
2535
protected $_current = null;
2636

37+
/**
38+
* Current id of the modal.
39+
*
40+
* @var mixed
41+
*/
2742
protected $_currentId = null;
2843

2944
/**
45+
* Open a modal
3046
*
31-
* Create a Twitter Bootstrap like modal.
47+
* If `$title` is a string, the modal header is created using `$title` as its
48+
* content and default options.
3249
*
33-
* @param array|string $title If array, works as $options, otherwize used as the modal title.
34-
* @param array $options Options for the main div of the modal.
50+
* ```php
51+
* echo $this->Modal->create('My Modal Title');
52+
* ```
3553
*
36-
* Extra options (useless if $title not specified) :
37-
* - close: Add close buttons to header (default true)
38-
* - no-body: Do not open the body after the create (default false)
39-
* - size: Modal size (small, large or custom classes)
40-
**/
54+
* If the modal header is created, the modal body is automatically opened after
55+
* it, except if the `body` options is specified (see below).
56+
*
57+
* If `$title` is an array, it is used as `$options`.
58+
*
59+
* ```php
60+
* echo $this->Modal->create(['class' => 'my-modal-class']);
61+
* ```
62+
*
63+
* ### Options
64+
*
65+
* - `aria-hidden` HTML attribute. Default is `'true'`.
66+
* - `body` If `$title` is a string, set to `false` to not open the body after
67+
* the panel header. Default is `true`.
68+
* - `close` Set to `false` to no add a close button to the modal. Default is `true`.
69+
* - `id` Identifier of the modal. If specified, a `aria-labelledby` HTML attribute
70+
* will be added to the modal and the header will be set accordingly.
71+
* - `role` HTML attribute. Default is `'dialog'`.
72+
* - `size` Size of the modal. Either a shortcut (`'lg'`/`'large'`/`'modal-lg'` or
73+
* (`'sm'`/`'small'`/`'modal-sm'`) or `false` (no size specified) or a custom class.
74+
* - `tabindex` HTML attribute. Default is `-1`.
75+
* Other options will be passed to the `Html::div` method for creating the
76+
* outer modal `<div>`.
77+
*
78+
* @param array|string $title The modal title or an array of options.
79+
* @param array $options Array of options. See above.
80+
*
81+
* @return An HTML string containing opening elements for a modal.
82+
*/
4183
public function create($title = null, $options = []) {
4284

4385
if (is_array($title)) {
@@ -100,15 +142,22 @@ public function create($title = null, $options = []) {
100142
}
101143

102144
/**
145+
* Closes a modal, cleans part that have not been closed correctly and optionaly
146+
* adds a footer with buttons to the modal.
103147
*
104-
* End a modal. If $buttons is not null, the ModalHelper::footer functions is called
105-
* with $buttons and $options arguments.
148+
* If `$buttons` is not null, the `footer()` method will be used to create the modal
149+
* footer using `$buttons` and `$options`:
106150
*
107-
* @param array|null $buttons
108-
* @param array $options
151+
* ```
152+
* echo $this->Modal->end([$this->Form->button('Save'), $this->Form->button('Close')]);
153+
* ```
109154
*
110-
**/
111-
public function end ($buttons = NULL, $options = []) {
155+
* @param array|null $buttons Array of buttons for the `footer()` method or `null`.
156+
* @param array $options Array of options for the `footer()` method.
157+
*
158+
* @return string An HTML string containing closing tags for the modal.
159+
*/
160+
public function end($buttons = NULL, $options = []) {
112161
$res = $this->_cleanCurrent();
113162
if ($buttons !== null) {
114163
$res .= $this->footer($buttons, $options) ;
@@ -117,22 +166,39 @@ public function end ($buttons = NULL, $options = []) {
117166
return $res ;
118167
}
119168

120-
protected function _cleanCurrent () {
169+
/**
170+
* Cleans the current modal part and return necessary HTML closing elements.
171+
*
172+
* @return string An HTML string containing closing elements.
173+
*/
174+
protected function _cleanCurrent() {
121175
if ($this->_current) {
122176
$this->_current = null ;
123177
return '</div>';
124178
}
125179
return '' ;
126180
}
127181

128-
protected function _part ($part, $content = null, $options = []) {
182+
/**
183+
* Cleans the current modal part, create a new ones with the given content, and
184+
* update the internal `_current` variable if necessary.
185+
*
186+
* @param string $part The name of the part (`'header'`, `'body'`, `'footer'`).
187+
* @param string $content The content of the part or `null`.
188+
* @param array $options Array of options for the `Html::tag` method.
189+
*
190+
* @return string
191+
*/
192+
protected function _part($part, $content = null, $options = []) {
129193
$out = $this->_cleanCurrent().$this->Html->tag('div', $content, $options);
130194
if (!$content)
131195
$this->_current = $part;
132196
return $out;
133197
}
134198

135-
protected function _createHeader ($title = null, $options = []) {
199+
// TODO: Update doc below this point.
200+
201+
protected function _createHeader($title = null, $options = []) {
136202
$options += [
137203
'close' => true
138204
];

src/View/Helper/BootstrapPanelHelper.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ class BootstrapPanelHelper extends Helper {
2020

2121
use BootstrapTrait;
2222

23+
/**
24+
* Other helpers used by BootstrapPanelHelper.
25+
*
26+
* @var array
27+
*/
2328
public $helpers = [
2429
'Html' => [
2530
'className' => 'Bootstrap.BootstrapHtml'
2631
]
2732
];
2833

2934
/**
30-
* Default configuration.
35+
* Default configuration for the helper.
36+
*
37+
* - `collapsible` Default behavior for collapsible panel.
3138
*
3239
* @var array
3340
*/
@@ -216,7 +223,7 @@ public function endGroup() {
216223
* - `panel-count` Panel counter, can be used to override the default counter when inside
217224
* a group. This value is used to generate the panel, header and body ID attribute.
218225
* - `type` Type of the panel (`'default'`, `'primary'`, ...). Default is `'default'`.
219-
* - Other attributes will be passed to the `Html::div` method for creating the
226+
* - Other options will be passed to the `Html::div` method for creating the
220227
* panel `<div>`.
221228
*
222229
* @param array|string $title The panel title or an array of options.

0 commit comments

Comments
 (0)