1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package sitemaker |
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace blitze\content\services\form\field; |
11
|
|
|
|
12
|
|
|
class color extends base |
13
|
|
|
{ |
14
|
|
|
/** @var \blitze\sitemaker\services\util */ |
|
|
|
|
15
|
|
|
protected $util; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Constructor |
19
|
|
|
* |
20
|
|
|
* @param \phpbb\language\language $language Language object |
21
|
|
|
* @param \phpbb\request\request_interface $request Request object |
22
|
|
|
* @param \blitze\sitemaker\services\template $ptemplate Sitemaker template object |
23
|
|
|
* @param \blitze\sitemaker\services\util $util Sitemaker utility object |
24
|
|
|
*/ |
25
|
9 |
|
public function __construct(\phpbb\language\language $language, \phpbb\request\request_interface $request, \blitze\sitemaker\services\template $ptemplate, \blitze\sitemaker\services\util $util) |
|
|
|
|
26
|
|
|
{ |
27
|
9 |
|
parent::__construct($language, $request, $ptemplate); |
28
|
|
|
|
29
|
9 |
|
$this->util = $util; |
30
|
9 |
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @inheritdoc |
34
|
|
|
*/ |
35
|
5 |
|
public function get_name() |
36
|
|
|
{ |
37
|
5 |
|
return 'color'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @inheritdoc |
42
|
|
|
*/ |
43
|
4 |
|
public function get_default_props() |
44
|
|
|
{ |
45
|
|
|
return array( |
46
|
4 |
|
'display' => 'box', |
47
|
4 |
|
'num_colors' => 1, |
48
|
4 |
|
'palette' => '', |
49
|
4 |
|
'palette_only' => false, |
50
|
4 |
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritdoc |
55
|
|
|
* @return array |
56
|
3 |
|
*/ |
57
|
|
|
public function get_field_value(array $data) |
58
|
3 |
|
{ |
59
|
3 |
|
return $this->ensure_is_array($data['field_value']); |
60
|
3 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @inheritdoc |
64
|
|
|
*/ |
65
|
|
|
public function display_field(array $data, array $topic_data, $view_mode) |
66
|
3 |
|
{ |
67
|
|
|
$sep = $this->language->lang('COMMA_SEPARATOR'); |
68
|
3 |
|
$field_value = $data['field_value']; |
69
|
3 |
|
|
70
|
|
|
if ($data['field_props']['display'] === 'box') |
71
|
3 |
|
{ |
72
|
3 |
|
$sep = ' '; |
73
|
1 |
|
$field_value = array_map(array($this, 'make_box'), $field_value); |
74
|
1 |
|
} |
75
|
1 |
|
|
76
|
|
|
return join($sep, $field_value); |
77
|
3 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @inheritdoc |
81
|
|
|
*/ |
82
|
|
|
public function get_submitted_value(array $data, $form_is_submitted = false) |
83
|
3 |
|
{ |
84
|
|
|
if ($form_is_submitted) |
85
|
3 |
|
{ |
86
|
|
|
return $this->request->variable($data['field_name'], array(0 => '')); |
87
|
3 |
|
} |
88
|
3 |
|
|
89
|
3 |
|
return $this->get_field_value($data); |
90
|
|
|
} |
91
|
3 |
|
|
92
|
3 |
|
/** |
93
|
3 |
|
* @inheritdoc |
94
|
|
|
*/ |
95
|
3 |
|
public function show_form_field(array &$data) |
96
|
|
|
{ |
97
|
|
|
$this->util->add_assets(array( |
98
|
|
|
'js' => array( |
99
|
|
|
'@blitze_content/vendor/spectrum/spectrum.min.js', |
100
|
|
|
100 => '@blitze_content/assets/fields/form.min.js', |
101
|
|
|
), |
102
|
1 |
|
'css' => array( |
103
|
|
|
'@blitze_content/vendor/spectrum/spectrum.min.css', |
104
|
1 |
|
), |
105
|
1 |
|
)); |
106
|
|
|
|
107
|
|
|
return parent::show_form_field($data); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param string $color |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
|
|
protected function make_box($color) |
115
|
|
|
{ |
116
|
|
|
$style = 'display: inline-block; width: 15px; height: 15px; border: 1 solid #fff; border-radius: 4px; background-color: ' . $color; |
117
|
|
|
return ($color) ? '<div style="' . $style . '" title="' . $color . '"></div>' : ''; |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths