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