PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.49
E2Pdf – Export Pdf Tool for WordPress v1.32.49
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
e2pdf / classes / helper / e2pdf-graph.php

e2pdf-graph.php in E2Pdf – Export Pdf Tool for WordPress 1.32.49, at classes/helper/e2pdf-graph.php

487 lines 24.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Graph Helper
5 * @copyright Copyright 2017 https://e2pdf.com
6 * @license GPLv3
7 * @version 1
8 * @link https://e2pdf.com
9 * @since 1.22.00
10 */
11 if (!defined('ABSPATH')) {
12 die('Access denied.');
13 }
14
15 class Helper_E2pdf_Graph {
16
17 private $helper;
18
19 public function __construct() {
20 $this->helper = Helper_E2pdf_Helper::instance();
21 }
22
23 public function graph($value = '', $field = []) {
24
25 if (!$value) {
26 return '';
27 }
28
29 if (!class_exists('Goat1000\SVGGraph\SVGGraph')) {
30 require_once $this->helper->get('plugin_dir') . 'vendors/svggraph/autoloader.php';
31 }
32
33 $width = $field['width'];
34 $height = $field['height'];
35
36 $settings = [
37 'auto_fit' => false,
38 'keep_colour_order' => true,
39 'back_stroke_width' => 0,
40 'back_stroke_colour' => '',
41 'link_base' => '/',
42 'link_target' => '_top',
43 'axis_font' => $this->get_value('text_font', 'Noto Sans Regular', $field),
44 'label_font' => $this->get_value('text_font', 'Noto Sans Regular', $field),
45 'graph_title_font' => $this->get_value('text_font', 'Noto Sans Regular', $field),
46 'legend_title_font' => $this->get_value('text_font', 'Noto Sans Regular', $field),
47 'back_colour' => $this->get_value('background', 'none', $field),
48 /* Graph */
49 'stroke_colour' => $this->get_value('g_stroke_colour', '', $field),
50 'stroke_width' => $this->get_value('g_stroke_width', '0', $field),
51 'fill_under' => $this->get_boolean('g_fill_under', $field),
52 'sort' => $this->get_boolean('g_sort', $field),
53 'percentage' => $this->get_boolean('g_percentage', $field),
54 'reverse' => $this->get_boolean('g_reverse', $field),
55 /* Title */
56 'graph_title_colour' => $this->get_value('g_graph_title_colour', '', $field),
57 'graph_title' => $this->get_value('g_graph_title', '', $field),
58 'graph_title_font_size' => $this->get_value('g_graph_title_font_size', '12', $field),
59 'graph_title_position' => $this->get_value('g_graph_title_position', 'top', $field),
60 'graph_title_space' => $this->get_value('g_graph_title_space', '0', $field),
61 /* Labels */
62 'label_colour' => $this->get_value('g_label_colour', '', $field),
63 'label_font_size' => $this->get_value('g_label_font_size', '10', $field),
64 'label_space' => $this->get_value('g_label_space', '0', $field),
65 'label_h' => $this->get_value('g_label_h', '', $field),
66 'label_v' => $this->get_value('g_label_v', '', $field),
67 'data_label_type' => $this->get_value('g_data_label_type', 'plain', $field),
68 /* Markers */
69 'marker_type' => $this->get_value('g_marker_type', 'circle', $field),
70 'marker_size' => $this->get_value('g_marker_size', '0', $field),
71 'marker_colour' => $this->get_value('g_marker_colour', '', $field),
72 /* Legend */
73 'show_legend' => $this->get_boolean('g_show_legend', $field),
74 'legend_back_colour' => $this->get_value('g_legend_back_colour', '', $field),
75 'legend_stroke_colour' => $this->get_value('g_legend_stroke_colour', '', $field),
76 'legend_stroke_width' => $this->get_value('g_legend_stroke_width', '0', $field),
77 'legend_entry_width' => $this->get_value('g_legend_entry_width', '0', $field),
78 'legend_padding_x' => $this->get_value('g_legend_padding_x', '0', $field),
79 'legend_padding_y' => $this->get_value('g_legend_padding_y', '0', $field),
80 'legend_colour' => $this->get_value('g_legend_colour', '', $field),
81 'legend_title' => $this->get_value('g_legend_title', '', $field),
82 'legend_title_font_size' => $this->get_value('g_legend_title_font_size', '', $field) === '' ? null : $this->get_value('g_legend_title_font_size', '0', $field),
83 'legend_font_size' => $this->get_value('g_legend_font_size', '0', $field),
84 'legend_position' => $this->get_value('g_legend_position_horizontal', 'right', $field) . ' ' . $this->get_value('g_legend_position_vertical', 'top', $field) . ' ' . $this->get_value('g_legend_position_horizontal_margin', '0', $field) . ' ' . $this->get_value('g_legend_position_vertical_margin', '0', $field) . ' ' . $this->get_value('g_legend_position_join', 'inner', $field),
85 'legend_text_side' => $this->get_value('g_legend_text_side', 'left', $field),
86 'legend_columns' => $this->get_value('g_legend_columns', '1', $field),
87 'legend_shadow_opacity' => '0',
88 /* Grid */
89 'grid_colour' => $this->get_value('g_grid_colour', '', $field),
90 'grid_subdivision_colour' => $this->get_value('g_grid_subdivision_colour', '', $field),
91 'minimum_grid_spacing' => $this->get_value('g_minimum_grid_spacing', '0', $field),
92 'minimum_grid_spacing_v' => $this->get_value('g_minimum_grid_spacing_v', '0', $field) > '0' ? $this->get_value('g_minimum_grid_spacing_v', '0', $field) : null,
93 'minimum_grid_spacing_h' => $this->get_value('g_minimum_grid_spacing_h', '0', $field) > '0' ? $this->get_value('g_minimum_grid_spacing_h', '0', $field) : null,
94 'grid_division_v' => $this->get_value('g_grid_division_v', '0', $field) > '0' ? $this->get_value('g_grid_division_v', '0', $field) : null,
95 'grid_division_h' => $this->get_value('g_grid_division_h', '0', $field) > '0' ? $this->get_value('g_grid_division_h', '0', $field) : null,
96 'show_grid' => $this->get_boolean('g_show_grid', $field),
97 'show_grid_subdivisions' => $this->get_boolean('g_show_grid_subdivisions', $field),
98 /* Axis */
99 'axis_colour' => $this->get_value('g_axis_colour', '', $field),
100 'axis_font_size' => $this->get_value('g_axis_font_size', '12', $field),
101 'axis_overlap' => $this->get_value('g_axis_overlap', '0', $field),
102 'show_axis_v' => $this->get_boolean('g_show_axis_v', $field),
103 'show_axis_text_v' => $this->get_boolean('g_show_axis_text_v', $field),
104 'show_axis_h' => $this->get_boolean('g_show_axis_h', $field),
105 'show_axis_text_h' => $this->get_boolean('g_show_axis_text_h', $field),
106 'show_subdivisions' => $this->get_boolean('g_show_subdivisions', $field),
107 'axis_stroke_width_v' => $this->get_value('g_axis_stroke_width_v', '0', $field),
108 'axis_stroke_width_h' => $this->get_value('g_axis_stroke_width_h', '0', $field),
109 'axis_text_position_v' => $this->get_value('g_axis_text_position_v', 'outside', $field),
110 'axis_text_position_h' => $this->get_value('g_axis_text_position_h', 'outside', $field),
111 'axis_text_space_v' => $this->get_value('g_axis_text_space_v', '2', $field),
112 'axis_text_space_h' => $this->get_value('g_axis_text_space_h', '2', $field),
113 'axis_text_offset_x_v' => $this->get_value('g_axis_text_offset_x_v', '0', $field),
114 'axis_text_offset_y_v' => $this->get_value('g_axis_text_offset_y_v', '0', $field),
115 'axis_text_offset_x_h' => $this->get_value('g_axis_text_offset_x_h', '0', $field),
116 'axis_text_offset_y_h' => $this->get_value('g_axis_text_offset_y_h', '0', $field),
117 /* Bar Labels */
118 'show_bar_labels' => $this->get_boolean('g_show_bar_labels', $field),
119 'bar_label_colour' => $this->get_value('g_bar_label_colour', '', $field),
120 'bar_label_font_size' => $this->get_value('g_bar_label_font_size', '0', $field),
121 'bar_label_position' => $this->get_value('g_bar_label_position_join', 'outer', $field) . ' ' . $this->get_value('g_bar_label_position_horizontal', 'centre', $field) . ' ' . $this->get_value('g_bar_label_position_vertical', 'top', $field),
122 'bar_label_space' => $this->get_value('g_bar_label_space', '0', $field),
123 'units_x' => $this->get_value('g_units_x', '', $field),
124 'units_y' => $this->get_value('g_units_y', '', $field),
125 'units_label' => $this->get_value('g_units_label', '', $field),
126 /* Additional */
127 'bubble_scale' => $this->get_value('g_bubble_scale', '1', $field),
128 'increment' => $this->get_value('g_increment', '0', $field),
129 'stack_group' => $this->get_value('g_stack_group', '0', $field),
130 'project_angle' => $this->get_value('g_project_angle', '0', $field),
131 'depth' => $this->get_value('g_depth', '40', $field),
132 'depth_shade_gradient' => array("black:0.2", "black:0.2", "black:0.2", "h"),
133 'aspect_ratio' => $this->get_value('g_aspect_ratio', '1', $field),
134 'bar_width' => $this->get_value('g_bar_width', '0', $field),
135 'bar_width_min' => $this->get_value('g_bar_width_min', '1', $field),
136 'show_labels' => $this->is_exists('g_show_labels', $field) ? $this->get_boolean('g_show_labels', $field) : true,
137 'show_label_key' => $this->is_exists('g_show_label_key', $field) ? $this->get_boolean('g_show_label_key', $field) : true,
138 'show_label_percent' => $this->get_boolean('g_show_label_percent', $field),
139 'show_label_amount' => $this->get_boolean('g_show_label_amount', $field),
140 'inner_radius' => $this->get_number('g_inner_radius', '0.5', $field),
141 'start_angle' => $this->get_value('g_start_angle', '0', $field),
142 'grid_straight' => $this->get_boolean('g_grid_straight', $field),
143 'fill_opacity' => $this->get_value('g_fill_opacity', '1', $field),
144 'grid_dash' => $this->get_value('g_grid_dash', '', $field),
145 'grid_dash_h' => $this->get_value('g_grid_dash_h', '', $field),
146 'grid_dash_v' => $this->get_value('g_grid_dash_v', '', $field),
147 'axis_colour_h' => $this->get_value('g_axis_colour_h', '', $field),
148 'axis_font_size_h' => $this->get_value('g_axis_font_size_h', '', $field),
149 'axis_colour_v' => $this->get_value('g_axis_colour_v', '', $field),
150 'axis_font_size_v' => $this->get_value('g_axis_font_size_v', '', $field),
151 'axis_font_weight_h' => $this->get_boolean('g_axis_font_weight_h', $field) ? 'bold' : null,
152 'axis_font_weight_v' => $this->get_boolean('g_axis_font_weight_v', $field) ? 'bold' : null,
153 ];
154
155 if ($this->is_exists('g_legend_entry_height', $field)) {
156 $settings['legend_entry_height'] = $this->get_value('g_legend_entry_height', '0', $field);
157 } else {
158 $settings['legend_entry_height'] = $this->get_value('g_legend_entry_height', '20', $field);
159 }
160
161 if ($this->is_exists('g_bar_space', $field)) {
162 $settings['bar_space'] = $this->get_value('g_bar_space', '0', $field);
163 } else {
164 $settings['bar_space'] = $this->get_value('g_bar_space', '10', $field);
165 }
166
167 if (!$this->is_empty('g_axis_text_align_v', $field)) {
168 $settings['axis_text_align_v'] = $this->get_value('g_axis_text_align_v', '', $field);
169 }
170
171 if (!$this->is_empty('g_axis_text_align_h', $field)) {
172 $settings['axis_text_align_h'] = $this->get_value('g_axis_text_align_h', '', $field);
173 }
174
175 if (!$this->is_empty('g_line_curve', $field)) {
176 $settings['line_curve'] = $this->get_value('g_line_curve', '', $field);
177 }
178
179 if (!$this->is_empty('g_line_dataset', $field)) {
180 $settings['line_dataset'] = $this->get_array('g_line_dataset', '', $field);
181 }
182
183 if ($this->get_boolean('g_axis_min_max_h', $field)) {
184 $settings['axis_min_h'] = $this->get_value('g_axis_min_h', '0', $field);
185 $settings['axis_max_h'] = $this->get_value('g_axis_max_h', '0', $field);
186 }
187
188 if ($this->get_boolean('g_axis_min_max_v', $field)) {
189 $settings['axis_min_v'] = $this->get_value('g_axis_min_v', '0', $field);
190 $settings['axis_max_v'] = $this->get_value('g_axis_max_v', '0', $field);
191 }
192
193 /**
194 * Padding
195 */
196 $settings['pad_top'] = $this->get_value('margin_top', '0', $field);
197 $settings['pad_left'] = $this->get_value('margin_left', '0', $field);
198 $settings['pad_right'] = $this->get_value('margin_right', '0', $field);
199 $settings['pad_bottom'] = $this->get_value('margin_bottom', '0', $field);
200
201 $separators = array(
202 'key' => ' => ',
203 'array' => ', ',
204 'sub_array' => '|',
205 );
206 if (!$this->is_empty('g_key_sep', $field)) {
207 $separators['key'] = $field['properties']['g_key_sep'];
208 }
209 if (!$this->is_empty('g_array_sep', $field)) {
210 $separators['array'] = $field['properties']['g_array_sep'];
211 }
212 if (!$this->is_empty('g_sub_array_sep', $field)) {
213 $separators['sub_array'] = $field['properties']['g_sub_array_sep'];
214 }
215
216 $data = $this->get_graph_data(apply_filters('e2pdf_helper_graph_pre_data', $value, $field), $separators, $this->get_value('g_multiline', '0', $field));
217 $data = apply_filters('e2pdf_helper_graph_pre_data', $data, $field);
218 if ($this->get_boolean('g_reverse_data', $field) && is_array($data)) {
219 $data = array_reverse($data);
220 }
221
222 $single_array_conversion = array(
223 'StackedBarGraph',
224 'StackedBar3DGraph',
225 'StackedCylinderGraph',
226 'HorizontalStackedBarGraph',
227 'HorizontalStackedBar3DGraph',
228 'StackedBarAndLineGraph',
229 'StackedLineGraph',
230 'GroupedBarGraph',
231 'GroupedBar3DGraph',
232 'GroupedCylinderGraph',
233 'HorizontalGroupedBarGraph',
234 'HorizontalGroupedBar3DGraph',
235 'StackedGroupedBarGraph',
236 'StackedGroupedBar3DGraph',
237 'StackedGroupedCylinderGraph',
238 'BarAndLineGraph',
239 'Histogram',
240 'LineGraph',
241 'RadarGraph',
242 'ScatterGraph',
243 'SteppedLineGraph',
244 'MultiLineGraph',
245 'MultiSteppedLineGraph',
246 'MultiScatterGraph',
247 'MultiRadarGraph',
248 'StackedBarAndLineGraph',
249 'ParetoChart',
250 'PopulationPyramid'
251 );
252 if (in_array($this->get_value('g_type', 'BarGraph', $field), $single_array_conversion) && $this->get_value('g_multiline', '0', $field) == '2') {
253 $new_data = [];
254 foreach ($data as $key => $tmp) {
255 if (is_array($tmp)) {
256 foreach ($tmp as $sub_key => $sub_tmp) {
257 $new_data[$sub_key][$key] = $sub_tmp;
258 }
259 } else {
260 $new_data[0][$key] = $tmp;
261 }
262 }
263 $data = $new_data;
264 }
265
266 /*
267 * Structured Data
268 */
269 if ($this->get_value('g_structured_data', '0', $field)) {
270 $settings['structured_data'] = true;
271 $structure = [];
272 if (!$this->is_empty('g_structure_key', $field)) {
273 $structure['key'] = $this->get_value('g_structure_key', '0', $field);
274 }
275 if (!$this->is_empty('g_structure_value', $field)) {
276 $structure['value'] = $this->get_array('g_structure_value', '0', $field);
277 }
278 if (!$this->is_empty('g_structure_label', $field)) {
279 $structure['label'] = $this->get_array('g_structure_label', '0', $field);
280 $settings['show_data_labels'] = true;
281 }
282 if (!$this->is_empty('g_structure_legend_text', $field)) {
283 $structure['legend_text'] = $this->get_array('g_structure_legend_text', '0', $field);
284 }
285 if (!$this->is_empty('g_structure_area', $field)) {
286 $structure['area'] = $this->get_array('g_structure_area', '0', $field);
287 }
288 if (!$this->is_empty('g_structure_open', $field)) {
289 $structure['open'] = $this->get_array('g_structure_open', '0', $field);
290 }
291 if (!$this->is_empty('g_structure_end', $field)) {
292 $structure['end'] = $this->get_array('g_structure_end', '0', $field);
293 }
294 if (!$this->is_empty('g_structure_outliers', $field)) {
295 $structure['outliers'] = $this->get_array('g_structure_outliers', '0', $field);
296 }
297 if (!$this->is_empty('g_structure_top', $field)) {
298 $structure['top'] = $this->get_array('g_structure_top', '0', $field);
299 }
300 if (!$this->is_empty('g_structure_bottom', $field)) {
301 $structure['bottom'] = $this->get_array('g_structure_bottom', '0', $field);
302 }
303 if (!$this->is_empty('g_structure_wtop', $field)) {
304 $structure['wtop'] = $this->get_array('g_structure_wtop', '0', $field);
305 }
306 if (!$this->is_empty('g_structure_wbottom', $field)) {
307 $structure['wbottom'] = $this->get_array('g_structure_wbottom', '0', $field);
308 }
309 if (!$this->is_empty('g_structure_high', $field)) {
310 $structure['high'] = $this->get_array('g_structure_high', '0', $field);
311 }
312 if (!$this->is_empty('g_structure_low', $field)) {
313 $structure['low'] = $this->get_array('g_structure_low', '0', $field);
314 }
315 $settings['structure'] = $structure;
316 }
317
318 if (!$this->get_boolean('g_structured_data', $field) && $this->get_boolean('g_show_legend', $field)) {
319 $legends = [];
320 if ($this->get_value('g_multiline', '0', $field) == '1') {
321 if (isset($data[0]) && is_array($data[0])) {
322 $legends = $data[0];
323 }
324 } elseif (is_array($data)) {
325 $legends = $data;
326 }
327 $settings['legend_entries'] = array_keys($legends);
328 }
329
330 if (!$this->is_empty('g_legends', $field)) {
331 $legends = [];
332 foreach (explode("\r\n", $this->get_value('g_legends', '', $field)) as $legend) {
333 $legends[] = implode("\n", explode('\n', $legend));
334 }
335 $settings['legend_entries'] = $legends;
336 }
337
338 if (!$this->is_empty('g_axis_text_callback_y', $field)) {
339 $texts = explode("\r\n", $this->get_value('g_axis_text_callback_y', '', $field));
340 if (!empty($texts)) {
341 $settings['axis_text_callback_y'] = function ($v, $key = '') use ($texts) {
342 return isset($texts[$v]) ? $texts[$v] : $key;
343 };
344 }
345 }
346
347 if (!$this->is_empty('g_axis_text_callback_x', $field)) {
348 $texts = explode("\r\n", $this->get_value('g_axis_text_callback_x', '', $field));
349 if (!empty($texts)) {
350 $settings['axis_text_callback_x'] = function ($v, $key = '') use ($texts) {
351 return isset($texts[$v]) ? $texts[$v] : $key;
352 };
353 }
354 }
355
356 $count = max(count($data), 1);
357 foreach ($data as $sub_data) {
358 if (is_array($sub_data)) {
359 $count = max($count, count($sub_data));
360 }
361 }
362 $colors = [];
363 if (!$this->is_empty('g_colors', $field)) {
364 foreach (explode("\r\n", $this->get_value('g_colors', '', $field)) as $color) {
365 $colors[] = $this->get_array_value($color, '');
366 }
367 } else {
368 $hue = 0;
369 $color_change = 360 / $count;
370 for ($i = 0; $i < $count; $i++) {
371 $colors[] = array($this->get_value('g_palette', '#1e73be', $field) . '/hue(' . $hue . ')');
372 $hue += $color_change;
373 }
374 }
375
376 $colors = apply_filters('e2pdf_helper_graph_colors', $colors, $field);
377 if ($this->get_boolean('g_stroke_dynamic_colour', $field)) {
378 $settings['stroke_colour'] = apply_filters('e2pdf_helper_graph_stroke_colors', $colors, $field);
379 }
380 if ($this->get_boolean('g_marker_dynamic_colour', $field)) {
381 $settings['marker_colour'] = apply_filters('e2pdf_helper_graph_marker_colors', $colors, $field);
382 }
383
384 $graph = new Goat1000\SVGGraph\SVGGraph($width, $height, apply_filters('e2pdf_helper_graph_settings', $settings, $field));
385 $graph->colours($colors);
386 $graph->values(apply_filters('e2pdf_helper_graph_data', $data, $field));
387 try {
388 $svg = $graph->fetch($this->get_value('g_type', 'BarGraph', $field));
389 if (false !== strpos($svg, 'Goat1000')) {
390 $svg = preg_replace('/Goat1000\\\(.[^\s]*)\s/', 'Graph ', $svg);
391 }
392 return base64_encode($svg); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
393 } catch (Exception $e) {
394 return '';
395 }
396 }
397
398 public function get_graph_data($value, $separators = [], $multiline = false) {
399 $data = [];
400 if ($multiline != '0') {
401 $lines = preg_split('/\r\n|\n/', $value);
402 foreach ($lines as $key => $line) {
403 $line_data = $this->get_line_data($line, $separators);
404 if ($multiline == '1') {
405 $data[] = $line_data;
406 } elseif ($multiline == '2') {
407 $data = array_merge($data, $line_data);
408 }
409 }
410 } else {
411 $data = $this->get_line_data($value, $separators);
412 }
413 return $data;
414 }
415
416 public function get_line_data($line, $separators = []) {
417 $value = [];
418 $data = explode($separators['array'], $line);
419 foreach ($data as $line_data) {
420 $key = null;
421 if (strpos($line_data, $separators['key']) !== false) {
422 list($key, $line_data) = explode($separators['key'], $line_data, 2);
423 $key = trim($key);
424 }
425
426 if (strpos($line_data, $separators['sub_array']) !== false) {
427 $sub_array = array_map(
428 function ($item) {
429 $item = trim($item);
430 return $item === '' ? null : $item;
431 }, explode($separators['sub_array'], $line_data)
432 );
433 if ($key !== null) {
434 $value[$key] = $sub_array;
435 } else {
436 $value[] = $sub_array;
437 }
438 } else {
439 $line_data = trim($line_data);
440 if ($key !== null) {
441 $value[$key] = $line_data === '' ? null : $line_data;
442 } else {
443 $value[] = $line_data === '' ? null : $line_data;
444 }
445 }
446 }
447 return $value;
448 }
449
450 public function is_empty($key = '', $field = []) {
451 return isset($field['properties'][$key]) && $field['properties'][$key] !== '' ? false : true;
452 }
453
454 public function is_exists($key = '', $field = []) {
455 return isset($field['properties'][$key]) ? true : false;
456 }
457
458 public function get_value($key = '', $default = '', $field = []) {
459 return isset($field['properties'][$key]) && $field['properties'][$key] ? $field['properties'][$key] : $default;
460 }
461
462 public function get_number($key = '', $default = '', $field = []) {
463 return isset($field['properties'][$key]) ? (float) $field['properties'][$key] : (float) $default;
464 }
465
466 public function get_array($key = '', $default = '', $field = []) {
467 $value = isset($field['properties'][$key]) && $field['properties'][$key] ? $field['properties'][$key] : '';
468 if ($value && (strpos($value, ',') !== false)) {
469 return $value = array_map('trim', explode(',', $value));
470 } else {
471 return $value ? $value : $default;
472 }
473 }
474
475 public function get_array_value($value = '', $default = '') {
476 if ($value && (strpos($value, ',') !== false)) {
477 return $value = array_map('trim', explode(',', $value));
478 } else {
479 return $value ? $value : $default;
480 }
481 }
482
483 public function get_boolean($key = '', $field = []) {
484 return isset($field['properties'][$key]) && $field['properties'][$key] ? true : false;
485 }
486 }
487