1
|
<?php
|
2
|
|
3
|
class Modal extends Form_Section
|
4
|
{
|
5
|
protected $_attributes = array(
|
6
|
'id' => null,
|
7
|
'class' => array(
|
8
|
'modal' => true,
|
9
|
'fade' => true,
|
10
|
),
|
11
|
'role' => 'dialog',
|
12
|
'aria-labelledby' => null,
|
13
|
'aria-hidden' => 'true',
|
14
|
);
|
15
|
protected $_global = array();
|
16
|
protected $_isLarge;
|
17
|
|
18
|
public function __construct($title, $id, $isLarge = false, $submit = null)
|
19
|
{
|
20
|
$this->_title = $title;
|
21
|
$this->_attributes['id'] = $this->_attributes['aria-labelledby'] = $id;
|
22
|
$this->_isLarge = $isLarge;
|
23
|
|
24
|
if (gettype($submit) == 'string')
|
25
|
$submit = (new Form_Button(
|
26
|
'save',
|
27
|
$submit
|
28
|
))->setAttribute('data-dismiss', 'modal');
|
29
|
|
30
|
if (false !== $submit)
|
31
|
array_push($this->_global, $submit);
|
32
|
}
|
33
|
|
34
|
public function __toString()
|
35
|
{
|
36
|
$element = Form_Element::__toString();
|
37
|
$title = htmlspecialchars(gettext($this->_title));
|
38
|
$html = implode('', $this->_groups);
|
39
|
$footer = implode('', $this->_global);
|
40
|
$modalClass = $this->_isLarge ? 'modal-lg' : 'modal-sm';
|
41
|
|
42
|
return <<<EOT
|
43
|
{$element}
|
44
|
<div class="modal-dialog {$modalClass}">
|
45
|
<div class="modal-content">
|
46
|
<div class="modal-header">
|
47
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
48
|
<span aria-hidden="true">×</span>
|
49
|
</button>
|
50
|
<h3 class="modal-title">{$title}</h3>
|
51
|
</div>
|
52
|
<!-- <form class="form-horizontal" action="" method="post"> -->
|
53
|
<div class="modal-body">
|
54
|
{$html}
|
55
|
</div>
|
56
|
<div class="modal-footer">
|
57
|
{$footer}
|
58
|
</div>
|
59
|
<!-- </form> -->
|
60
|
</div>
|
61
|
</div>
|
62
|
</div>
|
63
|
EOT;
|
64
|
}
|
65
|
}
|