|
1
|
|
|
<?php namespace Cornford\Bootstrapper; |
|
2
|
|
|
|
|
3
|
|
|
use Cornford\Bootstrapper\Contracts\IncludableInterface; |
|
4
|
|
|
use Cornford\Bootstrapper\Contracts\FormableInterface; |
|
5
|
|
|
use Cornford\Bootstrapper\Contracts\LinkableInterface; |
|
6
|
|
|
use Cornford\Bootstrapper\Contracts\AlertableInterface; |
|
7
|
|
|
|
|
8
|
|
|
class Bootstrap extends BootstrapBase implements IncludableInterface, FormableInterface, LinkableInterface, AlertableInterface { |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Include the Bootstrap CDN / Local CSS file |
|
12
|
|
|
* |
|
13
|
|
|
* @param string $type |
|
14
|
|
|
* @param array $attributes |
|
15
|
|
|
* |
|
16
|
|
|
* @return string |
|
17
|
|
|
*/ |
|
18
|
|
|
public function css($type = 'cdn', array $attributes = array()) |
|
19
|
|
|
{ |
|
20
|
|
|
switch($type) |
|
21
|
|
|
{ |
|
22
|
|
|
case 'cdn': |
|
23
|
|
|
$return = $this->add('style', self::CSS_BOOTSTRAP_CDN, $attributes) . |
|
24
|
|
|
$this->add('style', self::CSS_DATETIME_CDN, $attributes); |
|
25
|
|
|
break; |
|
26
|
|
|
case 'local': |
|
27
|
|
|
default: |
|
28
|
|
|
$return = $this->add('style', asset(self::CSS_BOOTSTRAP_LOCAL), $attributes) . |
|
29
|
|
|
$this->add('style', asset(self::CSS_DATETIME_LOCAL), $attributes); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
return $return; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Include the Bootstrap CDN JS file. Include jQuery CDN / Local JS file. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $type |
|
39
|
|
|
* @param array $attributes |
|
40
|
|
|
* |
|
41
|
|
|
* @return string |
|
42
|
|
|
*/ |
|
43
|
|
|
public function js($type = 'cdn', array $attributes = array()) |
|
44
|
|
|
{ |
|
45
|
|
|
switch($type) |
|
46
|
|
|
{ |
|
47
|
|
|
case 'cdn': |
|
48
|
|
|
$return = $this->add('script', self::JS_JQUERY_CDN, $attributes) . |
|
49
|
|
|
$this->add('script', self::JS_BOOTSTRAP_CDN, $attributes) . |
|
50
|
|
|
$this->add('script', self::JS_MOMENT_CDN, $attributes) . |
|
51
|
|
|
$this->add('script', self::JS_DATETIME_CDN, $attributes); |
|
52
|
|
|
break; |
|
53
|
|
|
case 'local': |
|
54
|
|
|
default: |
|
55
|
|
|
$return = $this->add('script', asset(self::JS_JQUERY_LOCAL), $attributes) . |
|
56
|
|
|
$this->add('script', asset(self::JS_BOOTSTRAP_LOCAL), $attributes) . |
|
57
|
|
|
$this->add('script', asset(self::JS_MOMENT_LOCAL), $attributes) . |
|
58
|
|
|
$this->add('script', asset(self::JS_DATETIME_LOCAL), $attributes); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $return; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Create a form text field. |
|
66
|
|
|
* |
|
67
|
|
|
* @param string $name |
|
68
|
|
|
* @param string $label |
|
69
|
|
|
* @param string $value |
|
70
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
71
|
|
|
* @param array $options |
|
72
|
|
|
* |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
public function text($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->input('text', $name, $label, $value, $errors, $options); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Create a form password field. |
|
82
|
|
|
* |
|
83
|
|
|
* @param string $name |
|
84
|
|
|
* @param string $label |
|
85
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
86
|
|
|
* @param array $options |
|
87
|
|
|
* |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
|
|
public function password($name, $label = null, $errors = null, array $options = array()) |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->input('password', $name, $label, null, $errors, $options); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Create a form email field. |
|
97
|
|
|
* |
|
98
|
|
|
* @param string $name |
|
99
|
|
|
* @param string $label |
|
100
|
|
|
* @param string $value |
|
101
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
102
|
|
|
* @param array $options |
|
103
|
|
|
* |
|
104
|
|
|
* @return string |
|
105
|
|
|
*/ |
|
106
|
|
|
public function email($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->input('email', $name, $label, $value, $errors, $options); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Create a form telephone field. |
|
113
|
|
|
* |
|
114
|
|
|
* @param string $name |
|
115
|
|
|
* @param string $label |
|
116
|
|
|
* @param string $value |
|
117
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
118
|
|
|
* @param array $options |
|
119
|
|
|
* |
|
120
|
|
|
* @return string |
|
121
|
|
|
*/ |
|
122
|
|
|
public function telephone($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->input('telephone', $name, $label, $value, $errors, $options); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Create a form number field. |
|
129
|
|
|
* |
|
130
|
|
|
* @param string $name |
|
131
|
|
|
* @param string $label |
|
132
|
|
|
* @param string $value |
|
133
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
134
|
|
|
* @param array $options |
|
135
|
|
|
* |
|
136
|
|
|
* @return string |
|
137
|
|
|
*/ |
|
138
|
|
|
public function number($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->input('number', $name, $label, $value, $errors, $options); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Create a form url field. |
|
145
|
|
|
* |
|
146
|
|
|
* @param string $name |
|
147
|
|
|
* @param string $label |
|
148
|
|
|
* @param string $value |
|
149
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
150
|
|
|
* @param array $options |
|
151
|
|
|
* |
|
152
|
|
|
* @return string |
|
153
|
|
|
*/ |
|
154
|
|
|
public function url($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->input('url', $name, $label, $value, $errors, $options); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Create a form range field. |
|
161
|
|
|
* |
|
162
|
|
|
* @param string $name |
|
163
|
|
|
* @param string $label |
|
164
|
|
|
* @param string $value |
|
165
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
166
|
|
|
* @param array $options |
|
167
|
|
|
* |
|
168
|
|
|
* @return string |
|
169
|
|
|
*/ |
|
170
|
|
|
public function range($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
171
|
|
|
{ |
|
172
|
|
|
return $this->input('range', $name, $label, $value, $errors, $options); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* Create a form search field. |
|
177
|
|
|
* |
|
178
|
|
|
* @param string $name |
|
179
|
|
|
* @param string $label |
|
180
|
|
|
* @param string $value |
|
181
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
182
|
|
|
* @param array $options |
|
183
|
|
|
* |
|
184
|
|
|
* @return string |
|
185
|
|
|
*/ |
|
186
|
|
|
public function search($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
187
|
|
|
{ |
|
188
|
|
|
return $this->input('search', $name, $label, $value, $errors, $options); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Create a form file field. |
|
193
|
|
|
* |
|
194
|
|
|
* @param string $name |
|
195
|
|
|
* @param string $label |
|
196
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
197
|
|
|
* @param array $options |
|
198
|
|
|
* |
|
199
|
|
|
* @return string |
|
200
|
|
|
*/ |
|
201
|
|
|
public function file($name, $label = null, $errors = null, array $options = array()) |
|
202
|
|
|
{ |
|
203
|
|
|
return $this->input('file', $name, $label, null, $errors, $options); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Create a form date field. |
|
208
|
|
|
* |
|
209
|
|
|
* @param string $name |
|
210
|
|
|
* @param string $label |
|
211
|
|
|
* @param string $value |
|
212
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
213
|
|
|
* @param array $options |
|
214
|
|
|
* @param array $parameters |
|
215
|
|
|
* |
|
216
|
|
|
* @return string |
|
217
|
|
|
*/ |
|
218
|
|
|
public function date($name, $label = null, $value = null, $errors = null, array $options = array(), array $parameters = array()) |
|
219
|
|
|
{ |
|
220
|
|
|
return $this->input('date', $name, $label, $value, $errors, $options, $parameters); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* Create a form datetime field. |
|
225
|
|
|
* |
|
226
|
|
|
* @param string $name |
|
227
|
|
|
* @param string $label |
|
228
|
|
|
* @param string $value |
|
229
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
230
|
|
|
* @param array $options |
|
231
|
|
|
* @param array $parameters |
|
232
|
|
|
* |
|
233
|
|
|
* @return string |
|
234
|
|
|
*/ |
|
235
|
|
|
public function datetime($name, $label = null, $value = null, $errors = null, array $options = array(), array $parameters = array()) |
|
236
|
|
|
{ |
|
237
|
|
|
return $this->input('datetime', $name, $label, $value, $errors, $options, $parameters); |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* Create a form time field. |
|
242
|
|
|
* |
|
243
|
|
|
* @param string $name |
|
244
|
|
|
* @param string $label |
|
245
|
|
|
* @param string $value |
|
246
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
247
|
|
|
* @param array $options |
|
248
|
|
|
* @param array $parameters |
|
249
|
|
|
* |
|
250
|
|
|
* @return string |
|
251
|
|
|
*/ |
|
252
|
|
|
public function time($name, $label = null, $value = null, $errors = null, array $options = array(), array $parameters = array()) |
|
253
|
|
|
{ |
|
254
|
|
|
return $this->input('time', $name, $label, $value, $errors, $options, $parameters); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
/** |
|
258
|
|
|
* Create a form textarea field. |
|
259
|
|
|
* |
|
260
|
|
|
* @param string $name |
|
261
|
|
|
* @param string $label |
|
262
|
|
|
* @param string $value |
|
263
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
264
|
|
|
* @param array $options |
|
265
|
|
|
* |
|
266
|
|
|
* @return string |
|
267
|
|
|
*/ |
|
268
|
|
|
public function textarea($name, $label = null, $value = null, $errors = null, array $options = array()) |
|
269
|
|
|
{ |
|
270
|
|
|
return $this->input('textarea', $name, $label, $value, $errors, $options); |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* Create a form select field. |
|
275
|
|
|
* |
|
276
|
|
|
* @param string $name |
|
277
|
|
|
* @param string $label |
|
278
|
|
|
* @param array $list |
|
279
|
|
|
* @param string $selected |
|
280
|
|
|
* @param \Illuminate\Support\MessageBag $errors |
|
281
|
|
|
* @param array $options |
|
282
|
|
|
* |
|
283
|
|
|
* @return string |
|
284
|
|
|
*/ |
|
285
|
|
|
public function select($name, $label = null, array $list = array(), $selected = null, $errors = null, array $options = array()) |
|
286
|
|
|
{ |
|
287
|
|
|
return $this->options($name, $label, $list, $selected, $errors, $options); |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
/** |
|
291
|
|
|
* Create a form field. |
|
292
|
|
|
* |
|
293
|
|
|
* @param string $name |
|
294
|
|
|
* @param string $label |
|
295
|
|
|
* @param integer $value |
|
296
|
|
|
* @param string $checked |
|
297
|
|
|
* @param array $options |
|
298
|
|
|
* |
|
299
|
|
|
* @return string |
|
300
|
|
|
*/ |
|
301
|
|
|
public function checkbox($name, $label = null, $value = 1, $checked = null, array $options = array()) |
|
302
|
|
|
{ |
|
303
|
|
|
return $this->field('checkbox', $name, $label, $value, $checked, $options); |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
/** |
|
307
|
|
|
* Create a form radio field. |
|
308
|
|
|
* |
|
309
|
|
|
* @param string $name |
|
310
|
|
|
* @param string $label |
|
311
|
|
|
* @param string $value |
|
312
|
|
|
* @param string $checked |
|
313
|
|
|
* @param array $options |
|
314
|
|
|
* |
|
315
|
|
|
* @return string |
|
316
|
|
|
*/ |
|
317
|
|
|
public function radio($name, $label = null, $value = null, $checked = null, array $options = array()) |
|
318
|
|
|
{ |
|
319
|
|
|
return $this->field('radio', $name, $label, $value, $checked, $options); |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* Create a form submit button. |
|
324
|
|
|
* |
|
325
|
|
|
* @param string $value |
|
326
|
|
|
* @param array $attributes |
|
327
|
|
|
* |
|
328
|
|
|
* @return string |
|
329
|
|
|
*/ |
|
330
|
|
|
public function submit($value, array $attributes = array()) |
|
331
|
|
|
{ |
|
332
|
|
|
return $this->action('submit', $value, $attributes); |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
/** |
|
336
|
|
|
* Create a form button. |
|
337
|
|
|
* |
|
338
|
|
|
* @param string $value |
|
339
|
|
|
* @param array $attributes |
|
340
|
|
|
* |
|
341
|
|
|
* @return string |
|
342
|
|
|
*/ |
|
343
|
|
|
public function button($value, array $attributes = array()) |
|
344
|
|
|
{ |
|
345
|
|
|
return $this->action('button', $value, $attributes); |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* Create a form reset button. |
|
350
|
|
|
* |
|
351
|
|
|
* @param string $value |
|
352
|
|
|
* @param array $attributes |
|
353
|
|
|
* |
|
354
|
|
|
* @return string |
|
355
|
|
|
*/ |
|
356
|
|
|
public function reset($value, array $attributes = array()) |
|
357
|
|
|
{ |
|
358
|
|
|
return $this->action('reset', $value, $attributes); |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* Create a button link to url. |
|
363
|
|
|
* |
|
364
|
|
|
* @param string $url |
|
365
|
|
|
* @param string $title |
|
366
|
|
|
* @param array $attributes |
|
367
|
|
|
* @param string $secure |
|
368
|
|
|
* |
|
369
|
|
|
* @return string |
|
370
|
|
|
*/ |
|
371
|
|
|
public function link($url, $title = null, array $attributes = array(), $secure = null) |
|
372
|
|
|
{ |
|
373
|
|
|
return $this->hyperlink('link', $url, $title, $parameters = array(), $attributes, $secure); |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* Create a secure button link to url. |
|
378
|
|
|
* |
|
379
|
|
|
* @param string $url |
|
380
|
|
|
* @param string $title |
|
381
|
|
|
* @param array $attributes |
|
382
|
|
|
* @param string $secure |
|
383
|
|
|
* |
|
384
|
|
|
* @return string |
|
385
|
|
|
*/ |
|
386
|
|
|
public function secureLink($url, $title = null, array $attributes = array(), $secure = null) |
|
387
|
|
|
{ |
|
388
|
|
|
return $this->hyperlink('secureLink', $url, $title, array(), $attributes, $secure); |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* Create a button link to route. |
|
393
|
|
|
* |
|
394
|
|
|
* @param string $name |
|
395
|
|
|
* @param string $title |
|
396
|
|
|
* @param array $parameters |
|
397
|
|
|
* @param array $attributes |
|
398
|
|
|
* |
|
399
|
|
|
* @return string |
|
400
|
|
|
*/ |
|
401
|
|
|
public function linkRoute($name, $title = null, array $parameters = array(), array $attributes = array()) |
|
402
|
|
|
{ |
|
403
|
|
|
return $this->hyperlink('linkRoute', $name, $title, $parameters, $attributes, null); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* Create a button link to action. |
|
408
|
|
|
* |
|
409
|
|
|
* @param string $action |
|
410
|
|
|
* @param string $title |
|
411
|
|
|
* @param array $parameters |
|
412
|
|
|
* @param array $attributes |
|
413
|
|
|
* |
|
414
|
|
|
* @return string |
|
415
|
|
|
*/ |
|
416
|
|
|
public function linkAction($action, $title = null, array $parameters = array(), array $attributes = array()) |
|
417
|
|
|
{ |
|
418
|
|
|
return $this->hyperlink('linkAction', $action, $title, $parameters, $attributes, null); |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
/** |
|
422
|
|
|
* Create a button link to an email address. |
|
423
|
|
|
* |
|
424
|
|
|
* @param string $email |
|
425
|
|
|
* @param string $title |
|
426
|
|
|
* @param array $attributes |
|
427
|
|
|
* |
|
428
|
|
|
* @return string |
|
429
|
|
|
*/ |
|
430
|
|
|
public function mailto($email, $title = null, array $attributes = array()) |
|
431
|
|
|
{ |
|
432
|
|
|
return $this->hyperlink('mailto', $email, $title, array(), $attributes, null); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* Create a none alert item. |
|
437
|
|
|
* |
|
438
|
|
|
* @param string $content |
|
439
|
|
|
* @param string $emphasis |
|
440
|
|
|
* @param boolean $dismissible |
|
441
|
|
|
* @param array $attributes |
|
442
|
|
|
* |
|
443
|
|
|
* @return string |
|
444
|
|
|
*/ |
|
445
|
|
|
public function none($content = null, $emphasis = null, $dismissible = false, array $attributes = array()) |
|
446
|
|
|
{ |
|
447
|
|
|
return $this->alert('message', $content, $emphasis, $dismissible, $attributes); |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
/** |
|
451
|
|
|
* Create a success alert item. |
|
452
|
|
|
* |
|
453
|
|
|
* @param string $content |
|
454
|
|
|
* @param string $emphasis |
|
455
|
|
|
* @param boolean $dismissible |
|
456
|
|
|
* @param array $attributes |
|
457
|
|
|
* |
|
458
|
|
|
* @return string |
|
459
|
|
|
*/ |
|
460
|
|
|
public function success($content = null, $emphasis = null, $dismissible = false, array $attributes = array()) |
|
461
|
|
|
{ |
|
462
|
|
|
return $this->alert('success', $content, $emphasis, $dismissible, $attributes); |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
/** |
|
466
|
|
|
* Create an info alert item. |
|
467
|
|
|
* |
|
468
|
|
|
* @param string $content |
|
469
|
|
|
* @param string $emphasis |
|
470
|
|
|
* @param boolean $dismissible |
|
471
|
|
|
* @param array $attributes |
|
472
|
|
|
* |
|
473
|
|
|
* @return string |
|
474
|
|
|
*/ |
|
475
|
|
|
public function info($content = null, $emphasis = null, $dismissible = false, array $attributes = array()) |
|
476
|
|
|
{ |
|
477
|
|
|
return $this->alert('info', $content, $emphasis, $dismissible, $attributes); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* Create a warning alert item. |
|
482
|
|
|
* |
|
483
|
|
|
* @param string $content |
|
484
|
|
|
* @param string $emphasis |
|
485
|
|
|
* @param boolean $dismissible |
|
486
|
|
|
* @param array $attributes |
|
487
|
|
|
* |
|
488
|
|
|
* @return string |
|
489
|
|
|
*/ |
|
490
|
|
|
public function warning($content = null, $emphasis = null, $dismissible = false, array $attributes = array()) |
|
491
|
|
|
{ |
|
492
|
|
|
return $this->alert('warning', $content, $emphasis, $dismissible, $attributes); |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* Create a danger alert item. |
|
497
|
|
|
* |
|
498
|
|
|
* @param string $content |
|
499
|
|
|
* @param string $emphasis |
|
500
|
|
|
* @param boolean $dismissible |
|
501
|
|
|
* @param array $attributes |
|
502
|
|
|
* |
|
503
|
|
|
* @return string |
|
504
|
|
|
*/ |
|
505
|
|
|
public function danger($content = null, $emphasis = null, $dismissible = false, array $attributes = array()) |
|
506
|
|
|
{ |
|
507
|
|
|
return $this->alert('danger', $content, $emphasis, $dismissible, $attributes); |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
} |