1 |
65866f79
|
Thane Gill
|
<?php
|
2 |
ac24dc24
|
Renato Botelho
|
/*
|
3 |
|
|
* Modal.class.php
|
4 |
|
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2015 Sjon Hortensius
|
8 |
|
|
* All rights reserved.
|
9 |
ac24dc24
|
Renato Botelho
|
*
|
10 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
11 |
|
|
* you may not use this file except in compliance with the License.
|
12 |
|
|
* You may obtain a copy of the License at
|
13 |
ac24dc24
|
Renato Botelho
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
15 |
ac24dc24
|
Renato Botelho
|
*
|
16 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
17 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
18 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19 |
|
|
* See the License for the specific language governing permissions and
|
20 |
|
|
* limitations under the License.
|
21 |
ac24dc24
|
Renato Botelho
|
*/
|
22 |
65866f79
|
Thane Gill
|
|
23 |
561cc25d
|
Sjon Hortensius
|
class Modal extends Form_Section
|
24 |
65866f79
|
Thane Gill
|
{
|
25 |
561cc25d
|
Sjon Hortensius
|
protected $_attributes = array(
|
26 |
|
|
'id' => null,
|
27 |
|
|
'class' => array(
|
28 |
|
|
'modal' => true,
|
29 |
|
|
'fade' => true,
|
30 |
|
|
),
|
31 |
|
|
'role' => 'dialog',
|
32 |
|
|
'aria-labelledby' => null,
|
33 |
|
|
'aria-hidden' => 'true',
|
34 |
|
|
);
|
35 |
|
|
protected $_global = array();
|
36 |
|
|
protected $_isLarge;
|
37 |
|
|
|
38 |
|
|
public function __construct($title, $id, $isLarge = false, $submit = null)
|
39 |
65866f79
|
Thane Gill
|
{
|
40 |
|
|
$this->_title = $title;
|
41 |
561cc25d
|
Sjon Hortensius
|
$this->_attributes['id'] = $this->_attributes['aria-labelledby'] = $id;
|
42 |
|
|
$this->_isLarge = $isLarge;
|
43 |
65866f79
|
Thane Gill
|
|
44 |
561cc25d
|
Sjon Hortensius
|
if (gettype($submit) == 'string')
|
45 |
|
|
$submit = (new Form_Button(
|
46 |
|
|
'save',
|
47 |
|
|
$submit
|
48 |
|
|
))->setAttribute('data-dismiss', 'modal');
|
49 |
65866f79
|
Thane Gill
|
|
50 |
561cc25d
|
Sjon Hortensius
|
if (false !== $submit)
|
51 |
aa49b6b3
|
Sjon Hortensius
|
array_push($this->_global, $submit);
|
52 |
65866f79
|
Thane Gill
|
}
|
53 |
|
|
|
54 |
|
|
public function __toString()
|
55 |
|
|
{
|
56 |
561cc25d
|
Sjon Hortensius
|
$element = Form_Element::__toString();
|
57 |
|
|
$title = htmlspecialchars(gettext($this->_title));
|
58 |
aeeda8b4
|
Stephen Beaver
|
$html = implode('', $this->_groups);
|
59 |
65866f79
|
Thane Gill
|
$footer = implode('', $this->_global);
|
60 |
561cc25d
|
Sjon Hortensius
|
$modalClass = $this->_isLarge ? 'modal-lg' : 'modal-sm';
|
61 |
65866f79
|
Thane Gill
|
|
62 |
|
|
return <<<EOT
|
63 |
561cc25d
|
Sjon Hortensius
|
{$element}
|
64 |
|
|
<div class="modal-dialog {$modalClass}">
|
65 |
65866f79
|
Thane Gill
|
<div class="modal-content">
|
66 |
|
|
<div class="modal-header">
|
67 |
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
68 |
|
|
<span aria-hidden="true">×</span>
|
69 |
|
|
</button>
|
70 |
561cc25d
|
Sjon Hortensius
|
<h3 class="modal-title">{$title}</h3>
|
71 |
65866f79
|
Thane Gill
|
</div>
|
72 |
309e8f8f
|
Stephen Beaver
|
<!-- <form class="form-horizontal" action="" method="post"> -->
|
73 |
65866f79
|
Thane Gill
|
<div class="modal-body">
|
74 |
|
|
{$html}
|
75 |
|
|
</div>
|
76 |
|
|
<div class="modal-footer">
|
77 |
|
|
{$footer}
|
78 |
|
|
</div>
|
79 |
309e8f8f
|
Stephen Beaver
|
<!-- </form> -->
|
80 |
65866f79
|
Thane Gill
|
</div>
|
81 |
|
|
</div>
|
82 |
|
|
</div>
|
83 |
|
|
EOT;
|
84 |
|
|
}
|
85 |
ac24dc24
|
Renato Botelho
|
}
|