PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.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
visualizer / classes / Visualizer / Render / Page / Data.php

Data.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 2.2.0, at classes/Visualizer/Render/Page/Data.php

285 lines 14.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // +----------------------------------------------------------------------+
3 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
4 // +----------------------------------------------------------------------+
5 // | This program is free software; you can redistribute it and/or modify |
6 // | it under the terms of the GNU General Public License, version 2, as |
7 // | published by the Free Software Foundation. |
8 // | |
9 // | This program is distributed in the hope that it will be useful, |
10 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 // | GNU General Public License for more details. |
13 // | |
14 // | You should have received a copy of the GNU General Public License |
15 // | along with this program; if not, write to the Free Software |
16 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
17 // | MA 02110-1301 USA |
18 // +----------------------------------------------------------------------+
19 // | Author: Eugene Manuilov <eugene@manuilov.org> |
20 // +----------------------------------------------------------------------+
21 /**
22 * Renders chart data setup page.
23 *
24 * @category Visualizer
25 * @package Render
26 * @subpackage Page
27 *
28 * @since 1.0.0
29 */
30 class Visualizer_Render_Page_Data extends Visualizer_Render_Page {
31
32 /**
33 * Renders page content.
34 *
35 * @since 1.0.0
36 *
37 * @access protected
38 */
39 protected function _renderContent() {
40 // Added by Ash/Upwork
41 if ( VISUALIZER_PRO ) {
42 global $Visualizer_Pro;
43 $Visualizer_Pro->_addEditor( $this->chart->ID );
44 if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) {
45 $Visualizer_Pro->_addFilterWizard( $this->chart->ID );
46 }
47 }
48 // Added by Ash/Upwork
49 echo '<div id="canvas">';
50 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
51 echo '</div>';
52 }
53
54 /**
55 * Renders sidebar content.
56 *
57 * @since 1.0.0
58 *
59 * @access protected
60 */
61 protected function _renderSidebarContent() {
62 $upload_link = add_query_arg(
63 array(
64 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
65 'nonce' => wp_create_nonce(),
66 'chart' => $this->chart->ID,
67 ), admin_url( 'admin-ajax.php' )
68 );
69 ?>
70 <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>"></span>
71 <iframe id="thehole" name="thehole"></iframe>
72 <ul class="group-wrapper full-height">
73 <li class="group group-category open" id="vz-chart-source">
74 <div class="group-header">
75 <h2 class="group-title main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
76 </div>
77 <ul class="group-content">
78 <ul class="group-wrapper">
79 <li class="group">
80 <h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
81 <div class="group-content">
82 <p class="group-description"><?php esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p>
83 <p class="group-description"><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p>
84 <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
85 target="thehole" enctype="multipart/form-data">
86 <input type="hidden" id="remote-data" name="remote_data">
87 <div class="">
88 <input type="file" id="csv-file" name="local_data">
89 </div>
90 <input type="button" class="button button-primary" id="vz-import-file"
91 value="<?php _e( 'Import', 'visualizer' ); ?>">
92 </form>
93 </div>
94 </li>
95 <li class="group visualizer-import-url">
96 <h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
97 <ul class="group-content">
98 <li class="subsection">
99 <span class="section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
100
101 <div class="section-items">
102 <p class="group-description"><?php _e( 'You can use this to import data from a remote CSV file. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?> </p>
103 <p class="group-description"><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p>
104 <p class="group-description"> <?php _e( 'You can also import data from Google Spreadsheet, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
105 <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
106 target="thehole" enctype="multipart/form-data">
107 <div class="remote-file-section">
108 <input type="url" id="remote-data" name="remote_data"
109 placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
110 class="visualizer-input">
111
112 </div>
113 <input type="button" id="view-remote-file" class="button button-primary"
114 value="<?php _e( 'Import', 'visualizer' ); ?>">
115 </form>
116 </div>
117 </li>
118 <li class="subsection <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?>">
119 <span class="section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?>
120 <span
121 class="dashicons dashicons-lock"></span></span>
122 <div class="section-items">
123 <p class="group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
124 <p class="group-description"> <?php _e( 'You can also synchronize with your Google Spreadsheet file, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
125 <p class="group-description"> <?php _e( 'We will update the chart data based on your time interval preference by overwritting the current data with the one from the URL.', 'visualizer' ); ?></p>
126 <form id="vz-schedule-import" action="<?php echo $upload_link; ?>" method="post"
127 target="thehole" enctype="multipart/form-data">
128 <div class="remote-file-section">
129 <input type="url" id="vz-schedule-url" name="remote_data"
130 value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>"
131 placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
132 class="visualizer-input visualizer-remote-url">
133 <p class="group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
134 <select name="vz-import-time" id="vz-import-time"
135 class="visualizer-select">
136 <?php
137 $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
138 $schedules = array(
139 '1' => __( 'Each hour', 'visualizer' ),
140 '12' => __( 'Each 12 hours', 'visualizer' ),
141 '24' => __( 'Each day', 'visualizer' ),
142 '36' => __( 'Each 3 days', 'visualizer' ),
143 );
144 foreach ( $schedules as $num => $name ) {
145 $extra = $num == $hours ? 'selected' : '';
146 ?>
147 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
148 <?php
149 }
150 ?>
151 </select>
152 </div>
153 <input type="button" id="vz-save-schedule" class="button button-primary"
154 value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
155
156 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
157 </form>
158 </div>
159 </li>
160 </ul>
161 </li>
162 <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class', '' ); ?> ">
163 <h2 class="group-title sub-group"
164 data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
165 class="dashicons dashicons-lock"></span></h2>
166 <div class="group-content edit-data-content">
167 <div>
168 <p class="group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
169 <form>
170 <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
171 <?php
172 $fetch_link = add_query_arg(
173 array(
174 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
175 'nonce' => wp_create_nonce(),
176 ), admin_url( 'admin-ajax.php' )
177 );
178 $query_args_charts = array(
179 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
180 'posts_per_page' => 300,
181 'no_found_rows' => true,
182 );
183 $charts = array();
184 $query = new WP_Query( $query_args_charts );
185 while ( $query->have_posts() ) {
186 $chart = $query->next_post();
187 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
188 ?>
189 <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
190 <?php
191 }
192 ?>
193
194 </select>
195 </form>
196 <input type="button" id="existing-chart" class="button button-primary"
197 value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
198 data-viz-link="<?php echo $fetch_link; ?>">
199 <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
200 </div>
201 </div>
202 </li>
203
204 <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
205 <h2 class="group-title sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
206 class="dashicons dashicons-lock"></span></h2>
207 <div class="group-content edit-data-content">
208 <div>
209 <p class="group-description"><?php _e( 'You can import here data from WordPress', 'visualizer' ); ?></p>
210 <input type="button" id="filter-chart-button" class="button button-primary "
211 value="<?php _e( 'Create Filters', 'visualizer' ); ?>" data-current="chart"
212 data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
213 data-t-chart="<?php _e( 'Create Filters', 'visualizer' ); ?>">
214 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
215 </div>
216 </div>
217 </li>
218
219 <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
220 <h2 class="group-title sub-group visualizer-editor-tab"
221 data-current="chart"><?php _e( 'Add data manually', 'visualizer' ); ?><span
222 class="dashicons dashicons-lock"></span></h2>
223 <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
224 <input type="hidden" id="chart-data" name="chart_data">
225 </form>
226
227 <div class="group-content edit-data-content">
228 <div>
229 <p class="group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p>
230 <input type="button" id="editor-chart-button" class="button button-primary "
231 value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
232 data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
233 data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>">
234
235 <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
236 </div>
237 </div>
238 </li>
239 </ul>
240 </li>
241 </ul>
242 <li class="group group-category bottom-fixed " id="vz-chart-settings">
243 <h2><?php _e( 'Advanced Settings', 'visualizer' ); ?></h2>
244 <div class="group-header">
245 <button class="customize-section-back" tabindex="0"></button>
246 <h3 class="group-title main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3>
247 </div>
248 <ul class="group-content">
249 <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>"
250 method="post">
251 <?php echo $this->sidebar; ?>
252 </form>
253 </ul>
254 </li>
255 <li class=" group bottom-fixed" id="vz-chart-review">
256 <a href="https://wordpress.org/support/plugin/visualizer/reviews/?filter=5#new-post"
257 target="_blank"><?php _e( 'Rate our plugin', 'visualizer' ); ?></a>
258 </li>
259 <li class="group bottom-fixed" id="vz-chart-copyright">Visualizer &copy; <?php echo date( 'Y', current_time( 'timestamp' ) ); ?></li>
260 </ul>
261 <?php
262 // changed by Ash/Upwork
263 }
264
265 /**
266 * Renders toolbar content.
267 *
268 * @since 1.0.0
269 *
270 * @access protected
271 */
272 protected function _renderToolbar() {
273 // changed by Ash/Upwork
274 echo '<div class="toolbar-div">';
275 echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
276 esc_html_e( 'Back', 'visualizer' );
277 echo '</a>';
278 echo '</div>';
279 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
280 echo '</div>';
281
282 }
283
284 }
285