-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
273 lines (215 loc) · 6.9 KB
/
test.php
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
require_once "vendor/autoload.php";
require_once "test-common.php";
use Unicorn\Forms\Conditions\InputDiffer;
use Unicorn\Forms\Form;
use Unicorn\Forms\TextInput;
use Unicorn\UI\Base\HtmlElement;
use Unicorn\UI\Bootstrap\Alert;
use Unicorn\UI\Bootstrap\Badge;
use Unicorn\UI\Bootstrap\BadgeCounter;
use Unicorn\UI\Bootstrap\BoolCheck;
use Unicorn\UI\Bootstrap\BootstrapHtmlPage;
use Unicorn\UI\Bootstrap\Breadcrumbs;
use Unicorn\UI\Bootstrap\Button;
use Unicorn\UI\Bootstrap\Collapsible;
use Unicorn\UI\Bootstrap\ContextualStyle;
use Unicorn\UI\Bootstrap\HtmlDebugger;
use Unicorn\UI\Bootstrap\Icons\TrueIcon;
use Unicorn\UI\Bootstrap\Label;
use Unicorn\UI\Bootstrap\LinkButton;
use Unicorn\UI\Bootstrap\Modal;
use Unicorn\UI\Bootstrap\ModalForm;
use Unicorn\UI\Bootstrap\Navbar;
use Unicorn\UI\Bootstrap\Navigation;
use Unicorn\UI\Bootstrap\NavigationItem;
use Unicorn\UI\Bootstrap\OrmTable;
use Unicorn\UI\Bootstrap\Panel;
use Unicorn\UI\Bootstrap\PanelTitle;
use Unicorn\UI\Bootstrap\Tab;
use Unicorn\UI\Bootstrap\Table;
use Unicorn\UI\Bootstrap\Tabs;
use Unicorn\UI\HTML\Header;
use Unicorn\UI\HTML\Image;
use Unicorn\UI\Bootstrap\LeadParagraph;
use Unicorn\UI\HTML\Link;
use Unicorn\UI\Bootstrap\Paragraph;
use Unicorn\UI\HTML\TableRow;
class TestForm extends Form
{
/** @var TextInput */
private $appel;
/** @var TextInput */
private $peer;
/** @var RadioInput */
private $radio;
public function checkAccess(): bool
{
return true;
}
public function title(): string
{
return "Test form";
}
public function form(): void
{
}
public function handle(): void
{
// DB::nieuw($this->appel->value(), $this->peer->value());
}
protected function buildForm(): void
{
$this->appel = new TextInput($this, "appel", "Appel");
$this->appel->setDefaultValue("abc");
$this->appel->required("Appels zijn belangrijk.");
$this->addInput($this->appel);
$this->peer = new TextInput($this, "peer", "Peer");
$this->peer->setDefaultValue("123");
$this->addInput($this->peer);
// $this->radio = new RadioInput($this, "radio", "Radio element");
// $this->radio->addOption("appel", "Appel");
// $this->radio->addOption("peer", "Peer");
// $this->radio->required("Maak een keuze.");
// $this->addInput($this->radio);
$this->ensure(new InputDiffer($this->appel, $this->peer, "Appels niet met peren vergelijken."));
$this->setSubmitButton(new SubmitButton($this, "submit", "Verstuur"));
}
}
class TestPage extends TestPageLayout
{
function __construct()
{
parent::__construct();
$this->setTitle("appel");
$this->addChild(new Header("Test page", "h1", "Alles over appels"));
$this->addChild(new Alert("Let op!", "Dit is een belangrijke test", ContextualStyle::info()));
$breadcrumbs = new Breadcrumbs("Test");
$breadcrumbs->addBreadcrumb("appel", "appel.php");
$this->addChild($breadcrumbs);
$this->addChild($this->tabs());
}
private function tabs(): Tabs
{
$tabs = new Tabs();
$tabs->addTab($this->formTab());
$tabs->addTab($this->searchTab());
$tabs->addTab($this->verhaalTab());
$tabs->addTab($this->panelTab());
$tabs->addTab($this->tableTab());
$tabs->addTab($this->ormTableTab());
$tabs->addTab($this->columnTableTab());
return $tabs;
}
private function formTab()
{
$tab = new Tab("form", "Form");
$form = new TestForm(new BootstrapFormRenderer(), "testForm", "test.php");
$modal = new ModalForm($form);
$tab->addChild(new HtmlDebugger("testForm-debug", $modal));
$tab->addChild($modal->toggleButton("Toon form"));
return $tab;
}
private function searchTab()
{
$tab = new Tab("searchform", "Search Form");
// $form = new SearchForm("searchForm", "test.php");
//
// $tab->addChild(new HtmlDebugger("searchForm-debug", $form));
//
// if($form->isActive() && $form->isSane()) {
// $tab->addText("Zoekresultaten voor '" . $form->querty() . "'.");
// }
return $tab;
}
private function verhaalTab(): Tab
{
$tab = new Tab("verhaal", "Verhaal");
$modal = new Modal("verhaalmodal");
$modal->addCloseButton();
$modal->setTitle("Verhaal");
$tab->addChild($modal);
$tab->addChild($modal->toggleButton("Toon verhaal"));
$modal->addChild(new LeadParagraph($this->lipsum()));
$collapse = new Collapsible("verhaaltje", "Lees meer", new TrueIcon);
$p = new Paragraph();
$img = new Image("http://lorempixel.com/400/200/");
$img->addClass("pull-right");
$p->addChild($img);
$p->addText($this->lipsum());
$collapse->addChild($p);
$collapse->addChild(new Paragraph($this->lipsum()));
$collapse->addChild(new Paragraph($this->lipsum()));
$modal->addChild($collapse);
return $tab;
}
private function panelTab(): Tab
{
$tab = new Tab("panel", "Panel");
$panel = new Panel(ContextualStyle::success());
$panel->header()->addChild(new PanelTitle("Badge, Label en Icon test panel"));
$p = new Paragraph();
$p->addChild(new Badge("test"));
$p->addChild(new BadgeCounter(0));
$p->addChild(new BadgeCounter(1));
$p->addChild(new Label("Hallo", ContextualStyle::info()));
$p->addChild(new BoolCheck(true));
$p->addChild(new BoolCheck(false));
$p->addChild(new Button("Test", new TrueIcon));
$panel->body()->addChild($p);
$table = new Table();
$table->header()->addRow(TableRow::headerFromArray(["A", "B", "C"]));
$table->body()->addRow(TableRow::fromArray(["1", "2", "3"]));
$row = TableRow::fromArray(["4", "5", "6"]);
$row->setStyle(ContextualStyle::success());
$table->body()->addRow($row);
$table->body()->addRow(TableRow::fromArray(["7", "8", "9"]));
$panel->setTable($table);
$panel->footer()->addText("En ook een spannende tabel");
$tab->addChild($panel);
return $tab;
}
private function tableTab(): Tab
{
$tab = new Tab("table", "Table");
$table = new Table();
$table->striped();
$table->header()->fromArray(["Naam", "Leeftijd", "Woonplaats"]);
$table->body()->fromArray([
["Henk", "23", "Oss"],
["Piet", "53", "Eindhoven"],
["Klaas", "34", "Veldhoven"],
["Bert", "47", "Waalre"],
]);
$tab->addChild($table);
return $tab;
}
private function ormTableTab(): Tab
{
$tab = new Tab("ormTable", "ORM Table");
$data = [
["Henk", "23", "Oss"],
["Piet", "53", "Eindhoven"],
["Klaas", "34", "Veldhoven"],
["Bert", "47", "Waalre"],
];
$table = new OrmTable($data);
$table->striped();
$table->addColumnFunction("Naam", function($element) { return $element[0]; });
$table->addColumnFunction("Leeftijd", function($element) { return $element[1]; });
$table->addColumnFunction("Woonplaats", function($element) { return $element[2]; });
$tab->addChild($table);
return $tab;
}
private function columnTableTab(): Tab
{
$tab = new Tab("coltable", "Kolommen tabel");
$table = new Table();
$table->hoverRows();
$table->addColumn("Naam", ["Henk", "Piet", "Klaas", "Bert"]);
$table->addColumn("Leeftijd", ["23", "53", "34", "47"]);
$tab->addChild($table);
return $tab;
}
}
echo new TestPage();