PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.0
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
← All changes | classes/Visualizer/Render/Layout.php +294 -26 3.1.03.2.0 View file →
@@ -48,17 +48,8 @@
48 48 return call_user_func( array( __CLASS__, '_render' . str_replace( ' ', '', ucwords( str_replace( '-', ' ', $layout ) ) ) ), func_get_args() );
49 49 }
50 50
51 51 /**
52 - * Show the fake editor (just an empty div).
53 - *
54 - * @access public
55 - */
56 - public static function _renderFauxEditor( $args ) {
57 - echo '<div id="chart-lhs" class="visualizer-editor-lhs" style="display: none"></div>';
58 - }
59 -
60 - /**
61 52 * Show the DB query box.
62 53 *
63 54 * @access public
64 55 */
@@ -63,9 +54,9 @@
63 54 * @access public
64 55 */
65 56 public static function _renderDbQuery( $args ) {
66 57 $query = $args[1];
67 - ?>
58 + ?>
68 59 <div id='visualizer-db-query' style="display: none">
69 60 <div class="visualizer-db-query-form">
70 61 <div>
71 62 <form id='db-query-form'>
@@ -85,9 +76,9 @@
85 76 </div>
86 77 <div class='db-wizard-results'></div>
87 78
88 79 </div>
89 - <?php
80 + <?php
90 81 }
91 82
92 83 /**
93 84 * Show the DB wizard's results table.
@@ -97,33 +88,310 @@
97 88 public static function _renderDbWizardResults( $args ) {
98 89 $headers = $args[1];
99 90 $results = $args[2];
100 91 ob_start();
101 - ?>
92 + ?>
102 93 <table cellspacing="0" width="100%" id="results">
103 94 <thead>
104 95 <tr>
105 - <?php
106 - foreach ( $headers as $header ) {
107 - echo '<th>' . $header['label'] . '</th>';
108 - }
109 - ?>
96 + <?php
97 + foreach ( $headers as $header ) {
98 + echo '<th>' . $header['label'] . '</th>';
99 + }
100 + ?>
110 101 </tr>
111 102 </thead>
112 103 <tfoot>
113 104 </tfoot>
114 105 <tbody>
115 - <?php
116 - foreach ( $results as $result ) {
117 - echo '<tr>';
118 - foreach ( $result as $r ) {
119 - echo '<td>' . $r . '</td>';
106 + <?php
107 + foreach ( $results as $result ) {
108 + echo '<tr>';
109 + foreach ( $result as $r ) {
110 + echo '<td>' . $r . '</td>';
111 + }
112 + echo '</tr>';
120 113 }
121 - echo '</tr>';
114 + ?>
115 + </tbody>
116 + </table>
117 + <?php
118 + return ob_get_clean();
122 119 }
123 - ?>
120 +
121 + /**
122 + * Show the JSON/REST parameters boxes.
123 + *
124 + * @access public
125 + */
126 + public static function _renderJsonScreen( $args ) {
127 + $id = $args[1];
128 + $action = add_query_arg(
129 + array(
130 + 'action' => Visualizer_Plugin::ACTION_JSON_SET_DATA,
131 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_DATA . Visualizer_Plugin::VERSION ),
132 + 'chart' => $id,
133 + ),
134 + admin_url( 'admin-ajax.php' )
135 + );
136 +
137 + $url = get_post_meta( $id, Visualizer_Plugin::CF_JSON_URL, true );
138 + $root = get_post_meta( $id, Visualizer_Plugin::CF_JSON_ROOT, true );
139 + $paging = get_post_meta( $id, Visualizer_Plugin::CF_JSON_PAGING, true );
140 +
141 + ?>
142 + <div id="visualizer-json-screen" style="display: none">
143 + <div class="visualizer-json-form">
144 + <h3 class="viz-step step1"><?php _e( 'STEP 1: Specify the JSON endpoint/URL', 'visualizer' ); ?></h3>
145 + <div>
146 + <form id="json-endpoint-form">
147 + <div class="json-wizard-hints">
148 + <ul class="info">
149 + <li><?php echo sprintf( __( 'If you want to add authentication, add headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">', '</a>' ); ?></li>
150 + </ul>
151 + </div>
152 +
153 + <input
154 + type="url"
155 + id="vz-import-json-url"
156 + name="url"
157 + value="<?php echo $url; ?>"
158 + placeholder="<?php esc_html_e( 'Please enter the URL', 'visualizer' ); ?>"
159 + class="visualizer-input">
160 + <button class="button button-secondary button-small" id="visualizer-json-fetch"><?php esc_html_e( 'Fetch Endpoint', 'visualizer' ); ?></button>
161 + </form>
162 + </div>
163 + <h3 class="viz-step step2 <?php echo empty( $url ) ? 'ui-state-disabled' : ''; ?> json-root-form"><?php _e( 'STEP 2: Choose the JSON root', 'visualizer' ); ?></h3>
164 + <div>
165 + <form id="json-root-form">
166 + <input type="hidden" name="chart" value="<?php echo $id; ?>">
167 + <select name="root" id="vz-import-json-root">
168 + <?php
169 + if ( ! empty( $root ) ) {
170 + ?>
171 + <option value="<?php echo $root; ?>"><?php echo str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $root ); ?></option>
172 + <?php
173 + }
174 + ?>
175 + </select>
176 + <input type="hidden" name="url" value="<?php echo $url; ?>">
177 + <button class="button button-secondary button-small" id="visualizer-json-parse"><?php esc_html_e( 'Parse Endpoint', 'visualizer' ); ?></button>
178 + </form>
179 + </div>
180 + <h3 class="viz-step step3 <?php echo empty( $root ) ? 'ui-state-disabled' : ''; ?>"><?php _e( 'STEP 3: Specify miscellaneous parameters', 'visualizer' ); ?></h3>
181 + <div>
182 + <form id="json-conclude-form-helper">
183 + <div class="<?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
184 + <div class="json-pagination">
185 + <select name="paging" id="vz-import-json-paging" class="json-form-element" data-template='<?php echo sprintf( 'Get first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), '?' ); ?>'>
186 + <option value="0" class="static"><?php _e( 'Don\'t use pagination', 'visualizer' ); ?></option>
187 + <?php
188 + if ( ! empty( $paging ) ) {
189 + ?>
190 + <option value="<?php echo $paging; ?>"><?php echo sprintf( 'Get first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $paging ) ); ?></option>
191 + <?php
192 + }
193 + ?>
194 + </select>
195 + <?php
196 + if ( ! VISUALIZER_PRO ) {
197 + ?>
198 + <br/>
199 + <br/>
200 + <br/>
201 + <br/>
202 + <?php
203 + }
204 + ?>
205 + <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
206 + </div>
207 + </div>
208 + </form>
209 + </div>
210 + <h3 class="viz-step step4 ui-state-disabled"><?php _e( 'STEP 4: Select the data to display in the chart', 'visualizer' ); ?></h3>
211 + <div>
212 + <form id="json-conclude-form" action="<?php echo $action; ?>" method="post" target="thehole">
213 + <input type="hidden" name="url">
214 + <input type="hidden" name="root">
215 + <input type="hidden" name="chart" value="<?php echo $id; ?>">
216 +
217 + <div class="json-wizard-hints html-table-editor-hints">
218 + <ul class="info">
219 + <li><?php _e( 'Select whether to include the data in the chart. Each column selected will form one series.', 'visualizer' ); ?></li>
220 + <li><?php _e( 'If a column is selected to be included, specify its data type.', 'visualizer' ); ?></li>
221 + <li><?php _e( 'You can use drag/drop to reorder the columns but this column position is not saved. So when you reload the table, you may have to reorder again.', 'visualizer' ); ?></li>
222 + <li><?php _e( 'You can select any number of columns but the chart type selected will determine how many will display in the chart.', 'visualizer' ); ?></li>
223 + </ul>
224 + </div>
225 + <div class="json-table"></div>
226 + <button class="button button-primary" id="visualizer-json-conclude"><?php esc_html_e( 'Save &amp; Show Chart', 'visualizer' ); ?></button>
227 + </form>
228 + </div>
229 + </div>
230 + </div>
231 + <?php
232 + }
233 +
234 + /**
235 + * Show the simple editor(s).
236 + *
237 + * @access public
238 + */
239 + public static function _renderSimpleEditorScreen( $args ) {
240 + $chart_id = $args[1];
241 + $action = add_query_arg(
242 + array(
243 + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
244 + 'nonce' => wp_create_nonce(),
245 + 'chart' => $chart_id,
246 + ),
247 + admin_url( 'admin-ajax.php' )
248 + );
249 + ?>
250 + <div class="viz-simple-editor">
251 + <div class="viz-simple-editor-type viz-table-editor">
252 + <form id="table-editor-form" action="<?php echo $action; ?>" method="post" target="thehole">
253 + <div class="html-table-editor-hints">
254 + <ul class="info">
255 + <li><?php _e( 'Select whether to include the data in the chart. Each column selected will form one series.', 'visualizer' ); ?></li>
256 + <li><?php _e( 'If a column is selected to be included, specify its data type.', 'visualizer' ); ?></li>
257 + <li><?php _e( 'You can use drag/drop to reorder the columns but this column position is not saved. So when you reload the table, you may have to reorder again.', 'visualizer' ); ?></li>
258 + <li><?php _e( 'You can select any number of columns but the chart type selected will determine how many will display in the chart.', 'visualizer' ); ?></li>
259 + </ul>
260 + </div>
261 + <div class="viz-html-table">
262 + <?php Visualizer_Render_Layout::show( 'editor-table', null, $chart_id, 'viz-html-table', true, true ); ?>
263 + </div>
264 + <input type="hidden" name="table_data" value="yes">
265 + <button class="button button-primary" id="visualizer-save-html-table"><?php esc_html_e( 'Save &amp; Show Chart', 'visualizer' ); ?></button>
266 + </form>
267 + </div>
268 +
269 + <?php Visualizer_Render_Layout::show( 'text-editor', $chart_id ); ?>
270 +
271 + </div>
272 + <?php
273 +
274 + }
275 +
276 + /**
277 + * Show the text area editor.
278 + *
279 + * @access public
280 + */
281 + public static function _renderTextEditor( $args ) {
282 + $chart_id = $args[1];
283 + $csv = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, array(), $chart_id, 'csv' );
284 + $data = '';
285 + if ( ! empty( $csv ) && isset( $csv['string'] ) ) {
286 + $data = str_replace( PHP_EOL, "\n", $csv['string'] );
287 + }
288 + ?>
289 + <div class="viz-simple-editor-type viz-text-editor">
290 + <textarea id="edited_text"><?php echo $data; ?></textarea>
291 + <button id="viz-text-editor-button" class="button button-primary"><?php _e( 'Save &amp; Show Chart', 'visualizer' ); ?></button>
292 + </div>
293 + <?php
294 + }
295 +
296 + /**
297 + * Show the JSON endpoint's parsed table.
298 + *
299 + * @access public
300 + */
301 + public static function _renderEditorTable( $args ) {
302 + $data = $args[1];
303 + $chart_id = $args[2];
304 + $class = $args[3];
305 + $echo = $args[4];
306 + $editable_data = $args[5];
307 + $series = get_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, true );
308 + $headers = array();
309 +
310 + if ( is_null( $data ) ) {
311 + foreach ( $series as $column ) {
312 + $headers[] = $column['label'];
313 + }
314 + $chart = get_post( $chart_id );
315 + $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
316 + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $type );
317 + } else {
318 + $headers = array_keys( $data[0] );
319 + }
320 +
321 + $classes = implode( ' ', array( 'viz-editor-table', $class ) );
322 +
323 + if ( $series ) {
324 + $temp = $series;
325 + $series = array();
326 + foreach ( $temp as $array ) {
327 + $series[ $array['label'] ] = $array['type'];
328 + }
329 + }
330 + if ( ! $echo ) {
331 + ob_start();
332 + }
333 + ?>
334 + <table cellspacing="0" width="100%" class="results cell-border stripe <?php echo $classes; ?>">
335 + <thead>
336 + <tr>
337 + <th><?php _e( 'Label', 'visualizer' ); ?></th>
338 + <?php
339 + foreach ( $headers as $header ) {
340 + if ( $editable_data ) {
341 + echo '<th><input type="text" name="header[]" value="' . esc_attr( $header ) . '"></th>';
342 + } else {
343 + echo '<th>' . $header . '</th>';
344 + }
345 + }
346 + ?>
347 + </tr>
348 + </thead>
349 + <tbody>
350 + <tr>
351 + <th><?php _e( 'Data Type', 'visualizer' ); ?></th>
352 + <?php
353 + $index = 0;
354 + foreach ( $headers as $header ) {
355 + echo '<td>';
356 + if ( $editable_data ) {
357 + echo '<select name="type[]">';
358 + } else {
359 + echo '<input name="header[]" type="hidden" value="' . $header . '">';
360 + echo '<select name="type[' . $header . ']">';
361 + }
362 + echo '<option value="" title="' . __( 'Exclude from chart', 'visualizer' ) . '">' . __( 'Exclude', 'visualizer' ) . '</option>';
363 + echo '<option value="0" disabled title="' . __( 'Include in chart and select data type', 'visualizer' ) . '">--' . __( 'OR', 'visualizer' ) . '--</option>';
364 +
365 + foreach ( Visualizer_Source::getAllowedTypes() as $type ) {
366 + $selected = array_key_exists( $header, $series ) && $type === $series[ $header ] ? 'selected' : '';
367 + echo '<option value="' . $type . '" ' . $selected . '>' . $type . '</option>';
368 + }
369 +
370 + echo '</select></td>';
371 + }
372 + ?>
373 + </tr>
374 + <?php
375 + foreach ( $data as $row ) {
376 + echo '<tr>';
377 + echo '<th>' . __( 'Value', 'visualizer' ) . '</th>';
378 + $index = 0;
379 + foreach ( array_values( $row ) as $value ) {
380 + if ( $editable_data ) {
381 + echo '<td><input type="text" name="data' . $index++ . '[]" value="' . esc_attr( $value ) . '"></td>';
382 + } else {
383 + echo '<td>' . $value . '</td>';
384 + }
385 + }
386 +
387 + echo '</tr>';
388 + }
389 + ?>
124 390 </tbody>
125 391 </table>
126 - <?php
127 - return ob_get_clean();
392 + <?php
393 + if ( ! $echo ) {
394 + return ob_get_clean();
395 + }
128 396 }
129 397 }