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

260 lines 12.6 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 * Renders chart data setup page.
24 *
25 * @category Visualizer
26 * @package Render
27 * @subpackage Page
28 *
29 * @since 1.0.0
30 */
31 class Visualizer_Render_Page_Data extends Visualizer_Render_Page {
32
33 /**
34 * Renders page content.
35 *
36 * @since 1.0.0
37 *
38 * @access protected
39 */
40 protected function _renderContent() {
41 // Added by Ash/Upwork
42 if ( VISUALIZER_PRO ) {
43 global $Visualizer_Pro;
44 $Visualizer_Pro->_addEditor();
45 }
46 // Added by Ash/Upwork
47 echo '<div id="canvas">';
48 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
49 echo '</div>';
50 }
51
52 /**
53 * Renders sidebar content.
54 *
55 * @since 1.0.0
56 *
57 * @access protected
58 */
59 protected function _renderSidebarContent() {
60 $upload_link = add_query_arg( array(
61 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
62 'nonce' => wp_create_nonce(),
63 'chart' => $this->chart->ID,
64 ), admin_url( 'admin-ajax.php' ) );
65
66 ?>
67 <iframe id="thehole" name="thehole"></iframe>
68 <ul class="group-wrapper full-height">
69 <li class="group group-category open" id="vz-chart-source">
70 <div class="group-header">
71 <h2 class="group-title main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
72 </div>
73 <ul class="group-content">
74 <ul class="group-wrapper">
75 <li class="group">
76 <h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
77 <div class="group-content">
78 <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>
79 <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>
80 <form id="vz-csv-file-form" action="<?php echo $upload_link ?>" method="post"
81 target="thehole" enctype="multipart/form-data">
82 <input type="hidden" id="remote-data" name="remote_data">
83 <div class="">
84 <input type="file" id="csv-file" name="local_data">
85 </div>
86 <input type="button" class="button button-primary" id="vz-import-file"
87 value="<?php _e( 'Import', 'visualizer' ); ?>">
88 </form>
89 </div>
90 </li>
91 <li class="group visualizer-import-url">
92 <h2 class="group-title sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
93 <ul class="group-content">
94 <li class="subsection">
95 <span class="section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
96
97 <div class="section-items">
98 <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>
99 <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>
100 <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>
101 <form id="vz-one-time-import" action="<?php echo $upload_link ?>" method="post"
102 target="thehole" enctype="multipart/form-data">
103 <div class="remote-file-section">
104 <input type="url" id="remote-data" name="remote_data"
105 placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
106 class="visualizer-input">
107
108 </div>
109 <input type="button" id="view-remote-file" class="button button-primary"
110 value="<?php _e( 'Import', 'visualizer' ); ?>">
111 </form>
112 </div>
113 </li>
114 <li class="subsection <?php echo apply_filters( 'visualizer_pro_upsell_class','only-pro-feature', 'schedule-chart' ); ?>">
115 <span class="section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?><span
116 class="dashicons dashicons-lock"></span></span>
117 <div class="section-items">
118 <p class="group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
119 <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>
120 <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>
121 <form id="vz-schedule-import" action="<?php echo $upload_link ?>" method="post"
122 target="thehole" enctype="multipart/form-data">
123 <div class="remote-file-section">
124 <input type="url" id="vz-schedule-url" name="remote_data" value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true );?>"
125 placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
126 class="visualizer-input visualizer-remote-url">
127 <p class="group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
128 <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
129 <?php
130 $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
131 $schedules = array(
132 '1' => __( 'Each hour', 'visualizer' ),
133 '12' => __( 'Each 12 hours', 'visualizer' ),
134 '24' => __( 'Each day', 'visualizer' ),
135 '36' => __( 'Each 3 days', 'visualizer' ),
136 );
137 foreach ( $schedules as $num => $name ) {
138 $extra = $num == $hours ? 'selected' : '';
139 ?>
140 <option value="<?php echo $num;?>" <?php echo $extra;?>><?php echo $name;?></option>
141 <?php
142 }
143 ?>
144 </select>
145 </div>
146 <input type="button" id="vz-save-schedule" class="button button-primary"
147 value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
148
149
150 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
151 </form>
152 </div>
153 </li>
154 </ul>
155 </li>
156 <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class','only-pro-feature' ); ?> ">
157 <h2 class="group-title sub-group"
158 data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
159 class="dashicons dashicons-lock"></span></h2>
160 <div class="group-content edit-data-content">
161 <div>
162 <p class="group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
163 <form>
164 <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
165 <?php
166 $fetch_link = add_query_arg( array(
167 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
168 'nonce' => wp_create_nonce(),
169 ), admin_url( 'admin-ajax.php' ) );
170
171 $query_args_charts = array(
172 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
173 'posts_per_page' => 300,
174 'no_found_rows' => true,
175 );
176 $charts = array();
177 $query = new WP_Query( $query_args_charts );
178 while ( $query->have_posts() ) {
179 $chart = $query->next_post();
180 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
181 ?>
182 <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
183 <?php
184 }
185 ?>
186
187 </select>
188 </form>
189 <input type="button" id="existing-chart" class="button button-primary"
190 value="<?php _e( 'Import Chart', 'visualizer' ); ?>" data-viz-link="<?php echo $fetch_link;?>">
191 <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
192 </div>
193 </div>
194 </li>
195 <li class="group <?php echo apply_filters( 'visualizer_pro_upsell_class','only-pro-feature' ); ?>">
196 <h2 class="group-title sub-group visualizer-editor-tab"
197 data-current="chart"><?php _e( 'Edit current data', 'visualizer' ); ?><span
198 class="dashicons dashicons-lock"></span></h2>
199 <form id="editor-form" action="<?php echo $upload_link?>" method="post" target="thehole">
200 <input type="hidden" id="chart-data" name="chart_data">
201 </form>
202
203 <div class="group-content edit-data-content">
204 <div>
205 <p class="group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p>
206 <input type="button" id="editor-chart-button" class="button button-primary "
207 value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart" data-t-editor="<?php _e( 'Show Chart', 'visualizer' );?>" data-t-chart="<?php _e( 'View Editor', 'visualizer' );?>">
208
209 <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
210 </div>
211 </div>
212 </li>
213 </ul>
214 </li>
215 </ul>
216 <li class="group group-category bottom-fixed " id="vz-chart-settings">
217 <h2><?php _e( 'Advanced Settings', 'visualizer' ); ?></h2>
218 <div class="group-header">
219 <button class="customize-section-back" tabindex="0"></button>
220 <h3 class="group-title main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3>
221 </div>
222 <ul class="group-content">
223 <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>"
224 method="post">
225 <?php echo $this->sidebar; ?>
226 </form>
227 </ul>
228 </li>
229 <li class=" group bottom-fixed" id="vz-chart-review">
230 <a href="https://wordpress.org/support/plugin/visualizer/reviews/?filter=5#new-post"
231 target="_blank"><?php _e( 'Rate our plugin', 'visualizer' ); ?></a>
232 </li>
233 <li class="group bottom-fixed" id="vz-chart-copyright">Visualizer &copy; 2014</li>
234 </ul>
235 <?php
236 // changed by Ash/Upwork
237 }
238
239 /**
240 * Renders toolbar content.
241 *
242 * @since 1.0.0
243 *
244 * @access protected
245 */
246 protected function _renderToolbar() {
247 // changed by Ash/Upwork
248 echo '<div class="toolbar-div">';
249 echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
250 esc_html_e( 'Back', 'visualizer' );
251 echo '</a>';
252 echo '</div>';
253 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
254
255 echo '</div>';
256
257 }
258
259 }
260