-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPanel.php
More file actions
152 lines (132 loc) · 3.5 KB
/
Panel.php
File metadata and controls
152 lines (132 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
declare(strict_types=1);
/**
* This file is part of the EaseTWBootstrap3 package
*
* https://github.com/VitexSoftware/php-ease-twbootstrap
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ease\TWB;
class Panel extends \Ease\Html\DivTag
{
/**
* Hlavička panelu.
*/
public \Ease\Html\DivTag $heading;
/**
* Tělo panelu.
*/
public \Ease\Html\DivTag $body;
/**
* Patička panelu.
*/
public \Ease\Html\DivTag $footer;
/**
* Typ Panelu.
*
* @var string succes|wanring|info|danger
*/
public string $type = 'default';
/**
* Obsah k přidání do patičky panelu.
*/
public $addToFooter;
/**
* Panel Twitter Bootstrapu.
*
* @param mixed|string $heading
* @param string $type succes|wanring|info|danger
* @param mixed $body tělo panelu
* @param mixed $footer patička panelu. FALSE = nezobrazit vůbec
*/
public function __construct(
$heading = null,
$type = 'default',
$body = null,
$footer = null,
) {
$this->type = $type;
$this->addToFooter = $footer;
parent::__construct(null, ['class' => 'panel panel-'.$this->type]);
if (null !== $heading) {
$this->heading = parent::addItem(new \Ease\Html\DivTag(
$heading,
['class' => 'panel-heading'],
), 'head');
}
if ($body) {
$this->getBody($body);
}
}
/**
* Ensure the body is initialized.
*
* @param mixed $initialContent
*
* @return \Ease\Html\DivTag body
*/
public function getBody($initialContent = '')
{
if (isset($this->body) === false) {
$this->body = parent::addItem(new \Ease\Html\DivTag(
$initialContent,
['class' => 'panel-body'],
), 'body');
}
return $this->body;
}
/**
* Vloží další element do objektu.
*
* @param mixed $pageItem hodnota nebo EaseObjekt s metodou draw()
* @param string $pageItemName Pod tímto jménem je objekt vkládán do stromu
*
* @return pointer Odkaz na vložený objekt
*/
public function &addItem($pageItem, $pageItemName = null)
{
$added = $this->getBody()->addItem($pageItem, $pageItemName);
return $added;
}
/**
* Vloží obsah do patičky.
*/
public function finalize(): void
{
if (!\count($this->body->pageParts)) {
unset($this->pageParts['body']);
}
if ($this->addToFooter) {
$this->footer()->addItem($this->addToFooter);
}
parent::finalize();
}
/**
* Vrací patičku panelu.
*
* @param mixed $content obsah pro vložení to patičky
*
* @return \Ease\Html\DivTag
*/
public function footer($content = null)
{
if (isset($this->footer)) {
if ($content) {
$this->footer->addItem($content);
}
} else {
$this->footer = parent::addItem(
new \Ease\Html\DivTag(
$content,
['class' => 'panel-footer panel-'.$this->type],
),
'footer',
);
}
return $this->footer;
}
}