PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.12
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.12
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Render / Sidebar.php

Sidebar.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.0.12, at classes/Visualizer/Render/Sidebar.php

753 lines 26.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 // +----------------------------------------------------------------------+
6 // | This program is free software; you can redistribute it and/or modify |
7 // | it under the terms of the GNU General Public License, version 2, as |
8 // | published by the Free Software Foundation. |
9 // | |
10 // | This program is distributed in the hope that it will be useful, |
11 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 // | GNU General Public License for more details. |
14 // | |
15 // | You should have received a copy of the GNU General Public License |
16 // | along with this program; if not, write to the Free Software |
17 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 // | MA 02110-1301 USA |
19 // +----------------------------------------------------------------------+
20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
21 // +----------------------------------------------------------------------+
22 /**
23 * Base class for all chart sidebar groups.
24 *
25 * @category Visualizer
26 * @package Render
27 *
28 * @since 1.0.0
29 * @abstract
30 */
31 abstract class Visualizer_Render_Sidebar extends Visualizer_Render {
32
33 /**
34 * The array of font families accepted by visualization API.
35 *
36 * @since 1.0.0
37 *
38 * @static
39 * @access protected
40 * @var array
41 */
42 protected static $_fontFamilies = array(
43 'Arial' => 'Arial',
44 'Sans Serif' => 'Sans Serif',
45 'serif' => 'Serif',
46 'Arial black' => 'Wide',
47 'Arial Narrow' => 'Narrow',
48 'Comic Sans MS' => 'Comic Sans MS',
49 'Courier New' => 'Courier New',
50 'Garamond' => 'Garamond',
51 'Georgia' => 'Georgia',
52 'Tahoma' => 'Tahoma',
53 'Verdana' => 'Verdana',
54 );
55
56 /**
57 * The Yes/No array.
58 *
59 * @since 1.0.0
60 *
61 * @access protected
62 * @var array
63 */
64 protected $_yesno;
65
66 /**
67 * The array of available legend positions.
68 *
69 * @since 1.0.0
70 *
71 * @access protected
72 * @var array
73 */
74 protected $_legendPositions;
75
76 /**
77 * The array of available alignments.
78 *
79 * @since 1.0.0
80 *
81 * @access protected
82 * @var array
83 */
84 protected $_alignments;
85
86 /**
87 * Whether this chart supports animation or not.
88 *
89 * @access protected
90 * @var bool
91 */
92 protected $_supportsAnimation = true;
93
94 /**
95 * Constructor.
96 *
97 * @since 1.0.0
98 *
99 * @access public
100 * @param array $data The data what has to be associated with this render.
101 */
102 public function __construct( $data = array() ) {
103 parent::__construct( $data );
104
105 $this->_legendPositions = array(
106 '' => '',
107 'left' => esc_html__( 'Left of the chart', 'visualizer' ),
108 'right' => esc_html__( 'Right of the chart', 'visualizer' ),
109 'top' => esc_html__( 'Above the chart', 'visualizer' ),
110 'bottom' => esc_html__( 'Below the chart', 'visualizer' ),
111 'in' => esc_html__( 'Inside the chart', 'visualizer' ),
112 'none' => esc_html__( 'Omit the legend', 'visualizer' ),
113 );
114
115 $this->_alignments = array(
116 '' => '',
117 'start' => esc_html__( 'Aligned to the start of the allocated area', 'visualizer' ),
118 'center' => esc_html__( 'Centered in the allocated area', 'visualizer' ),
119 'end' => esc_html__( 'Aligned to the end of the allocated area', 'visualizer' ),
120 );
121
122 $this->_yesno = array(
123 '' => '',
124 '1' => esc_html__( 'Yes', 'visualizer' ),
125 '0' => esc_html__( 'No', 'visualizer' ),
126 );
127 }
128
129 /**
130 * Renders chart title settings.
131 *
132 * @since 1.0.0
133 *
134 * @access protected
135 */
136 protected function _renderChartTitleSettings() {
137 self::_renderTextItem(
138 esc_html__( 'Chart Title', 'visualizer' ),
139 'title',
140 $this->title,
141 esc_html__( 'Text to display above the chart.', 'visualizer' )
142 );
143
144 self::_renderColorPickerItem(
145 esc_html__( 'Chart Title Color', 'visualizer' ),
146 'titleTextStyle[color]',
147 isset( $this->titleTextStyle['color'] ) ? $this->titleTextStyle['color'] : null,
148 '#000'
149 );
150 }
151
152 /**
153 * Renders chart advanced settings group.
154 *
155 * @access protected
156 */
157 protected function _renderAdvancedSettings() {
158 self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) );
159 self::_renderSectionStart();
160 self::_renderSectionDescription( esc_html__( 'Configure frontend actions here.', 'visualizer' ) );
161 self::_renderSectionEnd();
162
163 $this->_renderActionSettings();
164 self::_renderGroupEnd();
165
166 self::_renderGroupStart( esc_html__( 'Manual Configuration', 'visualizer' ) );
167 self::_renderSectionStart();
168 self::_renderSectionDescription( __( 'Configure the graph by providing configuration variables right from the', 'visualizer' ) . ' <a href="https://developers.google.com/chart/interactive/docs/reference" target="_blank">Google Visualization</a> API.' );
169
170 $example = '
171 {
172 "vAxis": {
173 "ticks": [5, 10, 15, 20],
174 "titleTextStyle": {
175 "color": "red"
176 },
177 "textPosition": "in"
178 }
179 }';
180
181 self::_renderTextAreaItem(
182 esc_html__( 'Configuration', 'visualizer' ),
183 'manual',
184 $this->manual,
185 sprintf(
186 esc_html__( 'One per line in valid JSON (key:value) format e.g. %s', 'visualizer' ),
187 '<br><code>' . $example . '</code>'
188 ),
189 '',
190 array( 'rows' => 5 )
191 );
192
193 self::_renderSectionEnd();
194 self::_renderGroupEnd();
195
196 }
197
198 /**
199 * Renders chart action buttons group.
200 *
201 * @access protected
202 */
203 protected function _renderActionSettings() {
204 global $wp_version;
205 $disable_actions = version_compare( $wp_version, '4.7.0', '<' );
206 self::_renderSectionStart( esc_html__( 'Actions', 'visualizer' ), false );
207 self::_renderCheckboxItem(
208 esc_html__( 'Print', 'visualizer' ),
209 'actions[]',
210 isset( $this->actions ) && in_array( 'print', $this->actions ) ? true : false,
211 'print',
212 $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable printing the data.', 'visualizer' ),
213 $disable_actions
214 );
215 self::_renderCheckboxItem(
216 esc_html__( 'CSV', 'visualizer' ),
217 'actions[]',
218 isset( $this->actions ) && in_array( 'csv;application/csv', $this->actions ) ? true : false,
219 'csv;application/csv',
220 $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable downloading the data as a CSV.', 'visualizer' ),
221 $disable_actions
222 );
223
224 $disabled = ! ( class_exists( 'PHPExcel' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && version_compare( PHP_VERSION, '5.2.0', '>' ) );
225 self::_renderCheckboxItem(
226 esc_html__( 'Excel', 'visualizer' ),
227 'actions[]',
228 isset( $this->actions ) && in_array( 'xls;application/vnd.ms-excel', $this->actions ) ? true : false,
229 'xls;application/vnd.ms-excel',
230 $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : ( $disabled ? '<span class="viz-section-error">' . esc_html__( 'Enable the ZIP and XML extensions to use this setting.', 'visualizer' ) . '</span>' : esc_html__( 'To enable downloading the data as an Excel spreadsheet.', 'visualizer' ) ),
231 $disable_actions || $disabled
232 );
233 self::_renderCheckboxItem(
234 esc_html__( 'Copy', 'visualizer' ),
235 'actions[]',
236 isset( $this->actions ) && in_array( 'copy', $this->actions ) ? true : false,
237 'copy',
238 $disable_actions ? '<span class="viz-section-error">' . esc_html__( 'Upgrade to at least WordPress 4.7 to use this.', 'visualizer' ) . '</span>' : esc_html__( 'To enable copying the data to the clipboard.', 'visualizer' ),
239 $disable_actions
240 );
241 self::_renderSectionEnd();
242 }
243
244 /**
245 * Renders chart general settings group.
246 *
247 * @since 1.0.0
248 *
249 * @access protected
250 */
251 protected function _renderGeneralSettings() {
252 self::_renderGroupStart( esc_html__( 'General Settings', 'visualizer' ) );
253 self::_renderSectionStart();
254 self::_renderSectionDescription( esc_html__( 'Configure title, font styles, tooltip, legend and else settings for the chart.', 'visualizer' ) );
255 self::_renderSectionEnd();
256
257 self::_renderSectionStart( esc_html__( 'Title', 'visualizer' ), false );
258 $this->_renderChartTitleSettings();
259 self::_renderSectionEnd();
260
261 self::_renderSectionStart( esc_html__( 'Font Styles', 'visualizer' ), false );
262 echo '<div class="viz-section-item">';
263 echo '<a class="more-info" href="javascript:;">[?]</a>';
264 echo '<b>', esc_html__( 'Family And Size', 'visualizer' ), '</b>';
265
266 echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
267 echo '<tr>';
268 echo '<td class="viz-section-table-column">';
269 echo '<select name="fontName" class="control-select">';
270 echo '<option></option>';
271 foreach ( self::$_fontFamilies as $font => $label ) {
272 echo '<option value="', $font, '"', selected( $font, $this->fontName, false ), '>';
273 echo $label;
274 echo '</option>';
275 }
276 echo '</select>';
277 echo '</td>';
278 echo '<td class="viz-section-table-column">';
279 echo '<select name="fontSize" class="control-select">';
280 echo '<option></option>';
281 for ( $i = 7; $i <= 20; $i++ ) {
282 echo '<option value="', $i, '"', selected( $i, $this->fontSize, false ), '>', $i, '</option>';
283 }
284 echo '</select>';
285 echo '</td>';
286 echo '</tr>';
287 echo '</table>';
288
289 echo '<p class="viz-section-description">';
290 esc_html_e( 'The default font family and size for all text in the chart.', 'visualizer' );
291 echo '</p>';
292 echo '</div>';
293 self::_renderSectionEnd();
294
295 self::_renderSectionStart( esc_html__( 'Legend', 'visualizer' ), false );
296 self::_renderSelectItem(
297 esc_html__( 'Position', 'visualizer' ),
298 'legend[position]',
299 $this->legend['position'],
300 $this->_legendPositions,
301 esc_html__( 'Determines where to place the legend, compared to the chart area.', 'visualizer' )
302 );
303
304 self::_renderSelectItem(
305 esc_html__( 'Alignment', 'visualizer' ),
306 'legend[alignment]',
307 $this->legend['alignment'],
308 $this->_alignments,
309 esc_html__( 'Determines the alignment of the legend.', 'visualizer' )
310 );
311
312 self::_renderColorPickerItem(
313 esc_html__( 'Font Color', 'visualizer' ),
314 'legend[textStyle][color]',
315 isset( $this->legend['textStyle']['color'] ) ? $this->legend['textStyle']['color'] : null,
316 '#000'
317 );
318 self::_renderSectionEnd();
319
320 self::_renderSectionStart( esc_html__( 'Tooltip', 'visualizer' ), false );
321 $this->_renderTooltipSettigns();
322 self::_renderSectionEnd();
323
324 $this->_renderAnimationSettings();
325
326 self::_renderGroupEnd();
327 }
328
329 /**
330 * Renders animation settings section.
331 *
332 * @access protected
333 */
334 protected function _renderAnimationSettings() {
335 if ( ! $this->_supportsAnimation ) {
336 return;
337 }
338
339 self::_renderSectionStart( esc_html__( 'Animation', 'visualizer' ), false );
340
341 self::_renderCheckboxItem(
342 esc_html__( 'Animate on startup', 'visualizer' ),
343 'animation[startup]',
344 $this->animation['startup'],
345 true,
346 esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' )
347 );
348
349 self::_renderTextItem(
350 esc_html__( 'Duration', 'visualizer' ),
351 'animation[duration]',
352 isset( $this->animation['duration'] ) ? $this->animation['duration'] : 0,
353 esc_html__( 'The duration of the animation, in milliseconds', 'visualizer' ),
354 0,
355 'number'
356 );
357
358 self::_renderSelectItem(
359 esc_html__( 'Easing', 'visualizer' ),
360 'animation[easing]',
361 isset( $this->animation['easing'] ) ? $this->animation['easing'] : null,
362 array(
363 'linear' => esc_html__( 'Constant speed', 'visualizer' ),
364 'in' => esc_html__( 'Start slow and speed up', 'visualizer' ),
365 'out' => esc_html__( 'Start fast and slow down', 'visualizer' ),
366 'inAndOut' => esc_html__( 'Start slow, speed up, then slow down', 'visualizer' ),
367 ),
368 esc_html__( 'The easing function applied to the animation.', 'visualizer' )
369 );
370
371 self::_renderSectionEnd();
372
373 }
374
375 /**
376 * Renders tooltip settings section.
377 *
378 * @since 1.4.0
379 *
380 * @access protected
381 */
382 protected function _renderTooltipSettigns() {
383 self::_renderSelectItem(
384 esc_html__( 'Trigger', 'visualizer' ),
385 'tooltip[trigger]',
386 isset( $this->tooltip['trigger'] ) ? $this->tooltip['trigger'] : null,
387 array(
388 '' => '',
389 'focus' => esc_html__( 'The tooltip will be displayed when the user hovers over an element', 'visualizer' ),
390 'selection' => esc_html__( 'The tooltip will be displayed when the user selects an element', 'visualizer' ),
391 'none' => esc_html__( 'The tooltip will not be displayed', 'visualizer' ),
392 ),
393 esc_html__( 'Determines the user interaction that causes the tooltip to be displayed.', 'visualizer' )
394 );
395
396 self::_renderSelectItem(
397 esc_html__( 'Show Color Code', 'visualizer' ),
398 'tooltip[showColorCode]',
399 isset( $this->tooltip['showColorCode'] ) ? $this->tooltip['showColorCode'] : null,
400 $this->_yesno,
401 esc_html__( 'If set to yes, will show colored squares next to the slice information in the tooltip.', 'visualizer' )
402 );
403 }
404
405 /**
406 * Renders chart view settings group.
407 *
408 * @since 1.0.0
409 *
410 * @access protected
411 */
412 protected function _renderViewSettings() {
413 self::_renderGroupStart( esc_html__( 'Layout & Chart Area', 'visualizer' ) );
414 self::_renderSectionStart( esc_html__( 'Layout', 'visualizer' ), false );
415 self::_renderSectionDescription( esc_html__( 'Configure the total size of the chart. Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.', 'visualizer' ) );
416
417 echo '<div class="viz-section-item">';
418 echo '<a class="more-info" href="javascript:;">[?]</a>';
419 echo '<b>', esc_html__( 'Width And Height Of Chart', 'visualizer' ), '</b>';
420
421 echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
422 echo '<tr>';
423 echo '<td class="viz-section-table-column">';
424 echo '<input type="text" name="width" class="control-text" value="', esc_attr( $this->width ), '" placeholder="100%">';
425 echo '</td>';
426 echo '<td class="viz-section-table-column">';
427 echo '<input type="text" name="height" class="control-text" value="', esc_attr( $this->height ), '" placeholder="400">';
428 echo '</td>';
429 echo '</tr>';
430 echo '</table>';
431
432 echo '<p class="viz-section-description">';
433 esc_html_e( 'Determines the total width and height of the chart.', 'visualizer' );
434 echo '</p>';
435 echo '</div>';
436
437 echo '<div class="viz-section-delimiter"></div>';
438
439 self::_renderSectionDescription( esc_html__( 'Configure the background color for the main area of the chart and the chart border width and color.', 'visualizer' ) );
440
441 self::_renderTextItem(
442 esc_html__( 'Stroke Width', 'visualizer' ),
443 'backgroundColor[strokeWidth]',
444 isset( $this->backgroundColor['strokeWidth'] ) ? $this->backgroundColor['strokeWidth'] : null,
445 esc_html__( 'The chart border width in pixels.', 'visualizer' ),
446 '0'
447 );
448
449 self::_renderColorPickerItem(
450 esc_html__( 'Stroke Color', 'visualizer' ),
451 'backgroundColor[stroke]',
452 ! empty( $this->backgroundColor['stroke'] ) ? $this->backgroundColor['stroke'] : null,
453 '#666'
454 );
455
456 $background_color = ! empty( $this->backgroundColor['fill'] ) ? $this->backgroundColor['fill'] : null;
457 self::_renderColorPickerItem(
458 esc_html__( 'Background Color', 'visualizer' ),
459 'backgroundColor[fill]',
460 $background_color,
461 '#fff'
462 );
463
464 echo '<div class="viz-section-item">';
465 echo '<label>';
466 echo '<input type="checkbox" class="control-checkbox" name="backgroundColor[fill]" value="transparent"', checked( $background_color, 'transparent', false ), '> ';
467 esc_html_e( 'Transparent background', 'visualizer' );
468 echo '</label>';
469 echo '</div>';
470 self::_renderSectionEnd();
471
472 self::_renderSectionStart( esc_html__( 'Chart Area', 'visualizer' ), false );
473 self::_renderSectionDescription( esc_html__( 'Configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends). Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.', 'visualizer' ) );
474
475 echo '<div class="viz-section-item">';
476 echo '<a class="more-info" href="javascript:;">[?]</a>';
477 echo '<b>', esc_html__( 'Left And Top Margins', 'visualizer' ), '</b>';
478
479 echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
480 echo '<tr>';
481 echo '<td class="viz-section-table-column">';
482 echo '<input type="text" name="chartArea[left]" class="control-text" value="', $this->chartArea['left'] || $this->chartArea['left'] === '0' ? esc_attr( $this->chartArea['left'] ) : '', '" placeholder="20%">';
483 echo '</td>';
484 echo '<td class="viz-section-table-column">';
485 echo '<input type="text" name="chartArea[top]" class="control-text" value="', $this->chartArea['top'] || $this->chartArea['top'] === '0' ? esc_attr( $this->chartArea['top'] ) : '', '" placeholder="20%">';
486 echo '</td>';
487 echo '</tr>';
488 echo '</table>';
489
490 echo '<p class="viz-section-description">';
491 esc_html_e( 'Determines how far to draw the chart from the left and top borders.', 'visualizer' );
492 echo '</p>';
493 echo '</div>';
494
495 echo '<div class="viz-section-item">';
496 echo '<a class="more-info" href="javascript:;">[?]</a>';
497 echo '<b>', esc_html__( 'Width And Height Of Chart Area', 'visualizer' ), '</b>';
498
499 echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
500 echo '<tr>';
501 echo '<td class="viz-section-table-column">';
502 echo '<input type="text" name="chartArea[width]" class="control-text" value="', ! empty( $this->chartArea['width'] ) ? esc_attr( $this->chartArea['width'] ) : '', '" placeholder="60%">';
503 echo '</td>';
504 echo '<td class="viz-section-table-column">';
505 echo '<input type="text" name="chartArea[height]" class="control-text" value="', ! empty( $this->chartArea['height'] ) ? esc_attr( $this->chartArea['height'] ) : '', '" placeholder="60%">';
506 echo '</td>';
507 echo '</tr>';
508 echo '</table>';
509
510 echo '<p class="viz-section-description">';
511 esc_html_e( 'Determines the width and hight of the chart area.', 'visualizer' );
512 echo '</p>';
513 echo '</div>';
514 self::_renderSectionEnd();
515 self::_renderGroupEnd();
516 }
517
518 /**
519 * Renders select item.
520 *
521 * @since 1.0.0
522 *
523 * @static
524 * @access public
525 * @param string $title The title of the select item.
526 * @param string $name The name of the select item.
527 * @param string $value The actual value of the select item.
528 * @param array $options The array of select options.
529 * @param string $desc The description of the select item.
530 * @param bool $multiple Is this a multiple select box.
531 * @param array $classes Any additional classes.
532 * @param array $attributes Custom attributes.
533 */
534 public static function _renderSelectItem( $title, $name, $value, array $options, $desc, $multiple = false, $classes = array(), $attributes = array() ) {
535 $atts = '';
536 if ( $attributes ) {
537 foreach ( $attributes as $k => $v ) {
538 $atts .= ' data-visualizer-' . $k . '=' . esc_attr( $v );
539 }
540 }
541 echo '<div class="viz-section-item">';
542 echo '<a class="more-info" href="javascript:;">[?]</a>';
543 echo '<b>', $title, '</b>';
544 echo '<select class="control-select ', implode( ' ', $classes ) , '" name="', $name, '" ', ( $multiple ? 'multiple' : '' ), ' ' , $atts, '>';
545 foreach ( $options as $key => $label ) {
546 $extra = $multiple && is_array( $value ) ? ( in_array( $key, $value ) ? 'selected' : '' ) : selected( $key, $value, false );
547 echo '<option value="', $key, '"', $extra, '>';
548 echo $label;
549 echo '</option>';
550 }
551 echo '</select>';
552 echo '<p class="viz-section-description">', $desc, '</p>';
553 echo '</div>';
554 }
555
556 /**
557 * Renders color picker item.
558 *
559 * @since 1.0.0
560 *
561 * @static
562 * @access protected
563 * @param string $title The title of the select item.
564 * @param string $name The name of the select item.
565 * @param string $value The actual value of the select item.
566 * @param string $default The default value of the color picker.
567 */
568 protected static function _renderColorPickerItem( $title, $name, $value, $default ) {
569 echo '<div class="viz-section-item">';
570 echo '<b>', $title, '</b>';
571 echo '<div>';
572 echo '<input type="text" class="color-picker-hex" name="', $name, '" maxlength="7" placeholder="', esc_attr__( 'Hex Value', 'visualizer' ), '" value="', is_null( $value ) ? $default : esc_attr( $value ), '" data-default-color="', $default, '">';
573 echo '</div>';
574 echo '</div>';
575 }
576
577 /**
578 * Renders text item.
579 *
580 * @since 1.0.0
581 *
582 * @static
583 * @access protected
584 * @param string $title The title of the select item.
585 * @param string $name The name of the select item.
586 * @param string $value The actual value of the select item.
587 * @param string $desc The description of the select item.
588 * @param string $placeholder The placeholder for the input.
589 * @param string $type The type for the input (out of number, email, tel etc., default is text).
590 * @param array $custom_attributes The custom attributes.
591 */
592 protected static function _renderTextItem( $title, $name, $value, $desc, $placeholder = '', $type = 'text', $custom_attributes = array() ) {
593 $attributes = '';
594 if ( $custom_attributes ) {
595 foreach ( $custom_attributes as $k => $v ) {
596 $attributes .= ' ' . $k . '="' . esc_attr( $v ) . '"';
597 }
598 }
599 echo '<div class="viz-section-item">';
600 echo '<a class="more-info" href="javascript:;">[?]</a>';
601 echo '<b>', $title, '</b>';
602 echo '<input type="', $type, '" class="control-text" ', $attributes, ' name="', $name, '" value="', esc_attr( $value ), '" placeholder="', $placeholder, '">';
603 echo '<p class="viz-section-description">', $desc, '</p>';
604 echo '</div>';
605 }
606
607 /**
608 * Renders the beginning of a group.
609 *
610 * @since 1.0.0
611 *
612 * @static
613 * @access public
614 * @param string $title The title of this group.
615 * @param string $html Any additional HTML.
616 * @param string $class Any additional classes.
617 */
618 public static function _renderGroupStart( $title, $html = '', $class = '' ) {
619 echo '<li class="viz-group ' . $class . '">';
620 echo '<h3 class="viz-group-title">', $title, '</h3>';
621 echo $html;
622 echo '<ul class="viz-group-content">';
623 }
624
625 /**
626 * Renders the ending of a group.
627 *
628 * @since 1.0.0
629 *
630 * @static
631 * @access public
632 */
633 public static function _renderGroupEnd() {
634 echo '</ul>';
635 echo '</li>';
636 }
637
638 /**
639 * Renders the beginning of a section.
640 *
641 * @since 1.0.0
642 *
643 * @static
644 * @access public
645 * @param string $title The title of this section. If the title is empty, no title will be displayed.
646 * @param boolean $open Determines whether the section items block has to be expanded or collapsed.
647 */
648 public static function _renderSectionStart( $title = false, $open = true ) {
649
650 if ( ! empty( $title ) ) {
651 echo '<li class="viz-subsection">';
652 echo '<span class="viz-section-title">', $title, '</span>';
653 } else {
654 echo '<li class=" ">';
655 }
656 echo '<div class="viz-section-items section-items', $open ? ' open' : '', '">';
657 }
658
659 /**
660 * Renders the ending of a section.
661 *
662 * @since 1.0.0
663 *
664 * @public
665 * @access protected
666 * @param string $html Any addition HTML to add.
667 */
668 public static function _renderSectionEnd( $html = '' ) {
669 echo '</div>';
670 echo $html;
671 echo '</li>';
672 }
673
674 /**
675 * Renders section description block.
676 *
677 * @since 1.0.0
678 *
679 * @static
680 * @access public
681 * @param string $description The description text.
682 */
683 public static function _renderSectionDescription( $description ) {
684 echo '<div class="viz-section-item">';
685 echo '<div class="viz-section-description">', $description, '</div>';
686 echo '</div>';
687 }
688
689 /**
690 * Renders format field according to series type.
691 *
692 * @since 1.3.0
693 *
694 * @access protected
695 * @param int $index The index of the series.
696 */
697 protected function _renderFormatField( $index = 0 ) {
698 switch ( $this->__series[ $index + 1 ]['type'] ) {
699 case 'number':
700 self::_renderTextItem(
701 esc_html__( 'Number Format', 'visualizer' ),
702 'series[' . $index . '][format]',
703 isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '',
704 sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU pattern set%2$s. Use something like #,### to get 1,234 as output, or $# to add dollar sign before digits. Pay attention that if you use &#37; percentage format then your values will be multiplied by 100.', 'visualizer' ), '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">', '</a>' ),
705 '#,###.##'
706 );
707 break;
708 case 'date':
709 case 'datetime':
710 case 'timeofday':
711 self::_renderTextItem(
712 esc_html__( 'Date Format', 'visualizer' ),
713 'series[' . $index . '][format]',
714 isset( $this->series[ $index ]['format'] ) ? $this->series[ $index ]['format'] : '',
715 sprintf( esc_html__( 'Enter custom format pattern to apply to this series value, similar to the %1$sICU date and time format%2$s.', 'visualizer' ), '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">', '</a>' ),
716 'eeee, dd LLLL yyyy'
717 );
718 break;
719 }
720 }
721
722 /**
723 * Render a checkbox item
724 */
725 protected static function _renderCheckboxItem( $title, $name, $value, $default, $desc, $disabled = false ) {
726 echo '<div class="viz-section-item">';
727 echo '<a class="more-info" href="javascript:;">[?]</a>';
728 echo '<b>', $title, '</b>';
729 echo '<input type="checkbox" class="control-check" value="', $default, '" name="', $name, '" ', ( $value == $default ? 'checked' : '' ), ' ', ( $disabled ? 'disabled=disabled' : '' ), '>';
730 echo '<p class="viz-section-description">', $desc, '</p>';
731 echo '</div>';
732 }
733
734 /**
735 * Render a textarea item.
736 */
737 protected static function _renderTextAreaItem( $title, $name, $value, $desc, $placeholder = '', $custom_attributes = array() ) {
738 $attributes = '';
739 if ( $custom_attributes ) {
740 foreach ( $custom_attributes as $k => $v ) {
741 $attributes .= ' ' . $k . '="' . esc_attr( $v ) . '"';
742 }
743 }
744 echo '<div class="viz-section-item">';
745 echo '<a class="more-info" href="javascript:;">[?]</a>';
746 echo '<b>', $title, '</b>';
747 echo '<textarea class="control-text" ', $attributes, ' name="', $name, '" placeholder="', $placeholder, '">', $value, '</textarea>';
748 echo '<p class="viz-section-description">', $desc, '</p>';
749 echo '</div>';
750 }
751
752 }
753