1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Formularium\Frontend\Bulma\Renderable; |
4
|
|
|
|
5
|
|
|
use Formularium\Datatype; |
6
|
|
|
use Formularium\Datatype\Datatype_file; |
7
|
|
|
use Formularium\Field; |
8
|
|
|
use Formularium\Frontend\Bulma\RenderableBulmaTrait; |
9
|
|
|
use Formularium\Frontend\HTML\Framework; |
10
|
|
|
use Formularium\Frontend\HTML\Renderable; |
11
|
|
|
use Formularium\HTMLNode; |
12
|
|
|
|
13
|
|
|
class Renderable_file extends Renderable |
14
|
|
|
{ |
15
|
|
|
use RenderableBulmaTrait; |
16
|
|
|
|
17
|
|
|
public function viewable($value, Field $field, HTMLNode $previous): HTMLNode |
18
|
|
|
{ |
19
|
|
|
return $previous; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Subcall of wrapper editable() |
24
|
|
|
* |
25
|
|
|
* @param mixed $value |
26
|
|
|
* @param Field $field |
27
|
|
|
* @param HTMLNode $previous |
28
|
|
|
* @return HTMLNode |
29
|
|
|
*/ |
30
|
|
|
public function _editable($value, Field $field, HTMLNode $previous): HTMLNode |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
$renderable = $field->getRenderables(); |
33
|
|
|
$validators = $field->getValidators(); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$input = $previous->get('input')[0]; |
36
|
|
|
$input->addAttribute('class', 'file-input'); |
37
|
|
|
|
38
|
|
|
$content = HTMLNode::factory( |
39
|
|
|
'div', |
40
|
|
|
['class' => "file has-name"], |
41
|
|
|
[ |
42
|
|
|
HTMLNode::factory( |
43
|
|
|
'label', |
44
|
|
|
['class' => "file-label"], |
45
|
|
|
[ |
46
|
|
|
$input, |
47
|
|
|
HTMLNode::factory( |
48
|
|
|
'span', |
49
|
|
|
['class' => "file-cta"], |
50
|
|
|
[ |
51
|
|
|
HTMLNode::factory( |
52
|
|
|
'span', |
53
|
|
|
['class' => "file-icon"], |
54
|
|
|
HTMLNode::factory( |
55
|
|
|
'i', |
56
|
|
|
[ 'class' => "fas fa-upload" ] |
57
|
|
|
) |
58
|
|
|
), |
59
|
|
|
HTMLNode::factory( |
60
|
|
|
'span', |
61
|
|
|
['class' => "file-label"], |
62
|
|
|
$renderable[Renderable::COMMENT] ?? 'Pick file or drag-drop' |
63
|
|
|
), |
64
|
|
|
] |
65
|
|
|
), |
66
|
|
|
HTMLNode::factory( |
67
|
|
|
'span', |
68
|
|
|
['class' => "formularium-file-name file-name"], |
69
|
|
|
'' // TODO |
70
|
|
|
) |
71
|
|
|
] |
72
|
|
|
), |
73
|
|
|
HTMLNode::factory( |
74
|
|
|
'label', |
75
|
|
|
['class' => "formularium-label"], |
76
|
|
|
$renderable[Renderable::LABEL] ?? '' |
77
|
|
|
) |
78
|
|
|
] |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
return $content; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.