| @@ -1,157 +1,151 @@ | ||
| 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_Module::can_show_feature( 'simple-editor' ) ) { | |
| 42 | - Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID ); | |
| 43 | - } | |
| 44 | - | |
| 45 | - if ( Visualizer_Module::is_pro() ) { | |
| 46 | - do_action( 'visualizer_add_editor_etc', $this->chart->ID ); | |
| 47 | - | |
| 48 | - if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) { | |
| 49 | - global $Visualizer_Pro; | |
| 50 | - $Visualizer_Pro->_addEditor( $this->chart->ID ); | |
| 51 | - if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) { | |
| 52 | - $Visualizer_Pro->_addFilterWizard( $this->chart->ID ); | |
| 53 | - } | |
| 54 | - } | |
| 55 | - } | |
| 56 | - | |
| 57 | - $this->add_additional_content(); | |
| 58 | - | |
| 59 | - // Added by Ash/Upwork | |
| 60 | - if ( Visualizer_Module::is_pro() ) { | |
| 61 | - echo '<div id="chart_wrapper_canvas">'; | |
| 62 | - echo '<div id="control_wrapper_canvas"></div>'; | |
| 63 | - } | |
| 64 | - echo '<div id="canvas">'; | |
| 65 | - echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">'; | |
| 66 | - echo '</div>'; | |
| 67 | - if ( Visualizer_Module::is_pro() ) { | |
| 68 | - echo '</div>'; | |
| 69 | - } | |
| 70 | - echo $this->custom_css; | |
| 71 | - } | |
| 72 | - | |
| 73 | - /** | |
| 74 | - * Renders sidebar content. | |
| 75 | - * | |
| 76 | - * @since 1.0.0 | |
| 77 | - * | |
| 78 | - * @access protected | |
| 79 | - */ | |
| 80 | - protected function _renderSidebarContent() { | |
| 81 | - | |
| 82 | - $chartSettings = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); | |
| 83 | - $hasTitle = isset( $chartSettings['backend-title'] ) && '' !== $chartSettings['backend-title']; | |
| 84 | - | |
| 85 | - ?> | |
| 86 | - <div class="viz-info-panel"> | |
| 87 | - <div class="viz-info-item"> | |
| 88 | - <label for="viz-shortcode"><?php _e( 'Shortcode', 'visualizer' ); ?></label> | |
| 89 | - <div class="viz-info-row"> | |
| 90 | - <input type="text" id="viz-shortcode" value="[visualizer id="<?php echo $this->chart->ID; ?>" class='']" readonly> | |
| 91 | - <button class="button" id="viz-copy-shortcode"><?php _e( 'Copy', 'visualizer' ); ?></button> | |
| 92 | - </div> | |
| 93 | - </div> | |
| 94 | - <div class="viz-info-item"> | |
| 95 | - <label for="viz-backend-name"><?php _e( 'Backend chart title for internal usage', 'visualizer' ); ?></label> | |
| 96 | - <input type="text" id="viz-backend-name" value="<?php echo $hasTitle ? $chartSettings['backend-title'] : ( '#' . esc_attr( $this->chart->ID ) ); ?>"> | |
| 97 | - </div> | |
| 98 | - </div> | |
| 99 | - <div id="viz-tabs"> | |
| 100 | - <ul> | |
| 101 | - <li><a href="#viz-tab-basic-content" id="viz-tab-basic"><?php _e( 'Source', 'visualizer' ); ?></a></li> | |
| 102 | - <li><a href="#viz-tab-advanced-content" id="viz-tab-advanced"><?php _e( 'Settings', 'visualizer' ); ?></a></li> | |
| 103 | - <li><a href="#viz-tab-help-content" id="viz-tab-help"><?php _e( 'Help', 'visualizer' ); ?></a></li> | |
| 104 | - </ul> | |
| 105 | - <div id="viz-tab-basic-content"><?php Visualizer_Render_Layout::show( 'tab-basic', $this->chart->ID ); ?></div> | |
| 106 | - <div id="viz-tab-advanced-content"><?php Visualizer_Render_Layout::show( 'tab-advanced', $this->chart->ID, $this->sidebar ); ?></div> | |
| 107 | - <div id="viz-tab-help-content"><?php Visualizer_Render_Layout::show( 'tab-help', $this->chart->ID ); ?></div> | |
| 108 | - </div> | |
| 109 | - | |
| 110 | - <li class="viz-group bottom-fixed" id="vz-chart-copyright"> | |
| 111 | - <?php _e( 'Hate it? Love it?', 'visualizer' ); ?> <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank"><?php _e( 'Rate it!', 'visualizer' ); ?></a> | |
| 112 | - <?php | |
| 113 | - // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested | |
| 114 | - echo date( 'Y', current_time( 'timestamp' ) ); | |
| 115 | - ?> | |
| 116 | - </li> | |
| 117 | - <?php | |
| 118 | - } | |
| 119 | - | |
| 120 | - /** | |
| 121 | - * Renders toolbar content. | |
| 122 | - * | |
| 123 | - * @since 1.0.0 | |
| 124 | - * | |
| 125 | - * @access protected | |
| 126 | - */ | |
| 127 | - protected function _renderToolbar() { | |
| 128 | - // don't show back button at all. | |
| 129 | - // NOTE: We can't be selective on the post_status here because when a new chart reaches the settings screen, its status changes to publish. | |
| 130 | - if ( ! VISUALIZER_SKIP_CHART_TYPE_PAGE ) { | |
| 131 | - echo '<div class="toolbar-div">'; | |
| 132 | - echo '<a class="button button-large" href="', esc_url( add_query_arg( 'tab', 'types' ) ), '">'; | |
| 133 | - esc_html_e( 'Back', 'visualizer' ); | |
| 134 | - echo '</a>'; | |
| 135 | - echo '</div>'; | |
| 136 | - } | |
| 137 | - echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">'; | |
| 138 | - if ( isset( $this->cancel_button ) ) { | |
| 139 | - echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-right" value="', $this->cancel_button, '">'; | |
| 140 | - } | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * Renders the additional content. | |
| 145 | - * | |
| 146 | - * @access private | |
| 147 | - */ | |
| 148 | - private function add_additional_content() { | |
| 149 | - $source = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) ); | |
| 150 | - $query = ''; | |
| 151 | - if ( 'visualizer_source_query' === $source ) { | |
| 152 | - $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true ); | |
| 153 | - } | |
| 154 | - Visualizer_Render_Layout::show( 'db-query', $query, $this->chart->ID ); | |
| 155 | - Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID ); | |
| 156 | - } | |
| 157 | -} | |
| 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 | +/** | |
| 24 | + * Renders chart data setup page. | |
| 25 | + * | |
| 26 | + * @category Visualizer | |
| 27 | + * @package Render | |
| 28 | + * @subpackage Page | |
| 29 | + * | |
| 30 | + * @since 1.0.0 | |
| 31 | + */ | |
| 32 | +class Visualizer_Render_Page_Data extends Visualizer_Render_Page { | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * Renders page content. | |
| 36 | + * | |
| 37 | + * @since 1.0.0 | |
| 38 | + * | |
| 39 | + * @access protected | |
| 40 | + */ | |
| 41 | + protected function _renderContent() { | |
| 42 | + // Added by Ash/Upwork | |
| 43 | + if( defined( 'Visualizer_Pro' ) ){ | |
| 44 | + global $Visualizer_Pro; | |
| 45 | + $Visualizer_Pro->_addEditor(); | |
| 46 | + } | |
| 47 | + // Added by Ash/Upwork | |
| 48 | + | |
| 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 | + echo '<input type="button" name="back_button" class="return-settings-btn preview-btn hidden-setting" value="« Back">'; | |
| 69 | + echo '<div class="initial-screen">'; | |
| 70 | + echo '<iframe id="thehole" name="thehole"></iframe>'; | |
| 71 | + echo '<p class="group-description">'; | |
| 72 | + 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_Plugin::NAME ); | |
| 73 | + echo '</p>'; | |
| 74 | + | |
| 75 | + echo '<p class="group-description">'; | |
| 76 | + esc_html_e( 'If you are unsure about how to format your data CSV then please take a look at this sample:', Visualizer_Plugin::NAME ); | |
| 77 | + echo ' <a href="', VISUALIZER_ABSURL, 'samples/', $this->type, '.csv" target="_blank">', $this->type, '.csv</a> '; | |
| 78 | + printf( esc_html__( 'or read how you can add Google spreadsheet in following %sarticle%s.', Visualizer_Plugin::NAME ), '<a href="https://github.com/madpixelslabs/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank">', '</a>' ); | |
| 79 | + echo '</p>'; | |
| 80 | + | |
| 81 | + echo '<div>'; | |
| 82 | + echo '<form id="csv-form" action="', $upload_link, '" method="post" target="thehole" enctype="multipart/form-data">'; | |
| 83 | + echo '<input type="hidden" id="remote-data" name="remote_data">'; | |
| 84 | + echo '<div class="form-inline">'; | |
| 85 | + echo '<div class="button button-primary file-wrapper computer-btn">'; | |
| 86 | + echo '<input type="file" id="csv-file" class="file" name="local_data">'; | |
| 87 | + esc_attr_e( 'From Computer', Visualizer_Plugin::NAME ); | |
| 88 | + echo '</div>'; | |
| 89 | + | |
| 90 | + echo '<a id="remote-file" class="button from-web from-web-btn" href="javascript:;">', esc_html__( 'From Web', Visualizer_Plugin::NAME ), '</a>'; | |
| 91 | + // Added by Ash/Upwork | |
| 92 | + if( defined( 'Visualizer_Pro' ) ){ | |
| 93 | + global $Visualizer_Pro; | |
| 94 | + $Visualizer_Pro->_addFormElements(); | |
| 95 | + }else{ | |
| 96 | + // Added by Ash/Upwork | |
| 97 | + echo '<div class="just-on-pro"> </div>'; | |
| 98 | + } | |
| 99 | + echo '</div>'; | |
| 100 | + echo '</form>'; | |
| 101 | + | |
| 102 | + // added by Ash/Upwork | |
| 103 | + if( defined( 'Visualizer_Pro' ) ){ | |
| 104 | + global $Visualizer_Pro; | |
| 105 | + $Visualizer_Pro->_addEditorElements(); | |
| 106 | + }else{ | |
| 107 | +?> | |
| 108 | + <a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL;?>" title="<?php echo Visualizer_Plugin::PRO_TEASER_TITLE;?>" class="check-pro-btn" target="_new"> | |
| 109 | + <input type="button" class="button preview preview-btn" id="existing-chart-free" value="<?php esc_attr_e( 'Check PRO Version ', Visualizer_Plugin::NAME );?>"> | |
| 110 | + </a> | |
| 111 | + | |
| 112 | + | |
| 113 | +<?php | |
| 114 | + } | |
| 115 | + | |
| 116 | + echo'<input type="button" name="advanced_button" class="advanced-settings-btn preview-btn" value="'. __( 'Advanced', Visualizer_Plugin::NAME ).' »">'; | |
| 117 | + // Added by Ash/Upwork | |
| 118 | + | |
| 119 | + echo '</div>'; | |
| 120 | + echo '</div>'; | |
| 121 | + | |
| 122 | + // changed by Ash/Upwork | |
| 123 | + echo '<div class= "second-screen hidden-setting">'; | |
| 124 | + echo '<form id="settings-form" action="', add_query_arg( 'nonce', wp_create_nonce() ), '" method="post">'; | |
| 125 | + echo $this->sidebar; | |
| 126 | + echo '</form>'; | |
| 127 | + echo '</div>'; | |
| 128 | + // changed by Ash/Upwork | |
| 129 | + } | |
| 130 | + | |
| 131 | + /** | |
| 132 | + * Renders toolbar content. | |
| 133 | + * | |
| 134 | + * @since 1.0.0 | |
| 135 | + * | |
| 136 | + * @access protected | |
| 137 | + */ | |
| 138 | + protected function _renderToolbar() { | |
| 139 | + // changed by Ash/Upwork | |
| 140 | + echo '<div class="toolbar-div">'; | |
| 141 | + echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">'; | |
| 142 | + esc_html_e( 'Back', Visualizer_Plugin::NAME ); | |
| 143 | + echo '</a>'; | |
| 144 | + echo '</div>'; | |
| 145 | + echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">'; | |
| 146 | + echo '</div>'; | |
| 147 | + | |
| 148 | + | |
| 149 | + } | |
| 150 | + | |
| 151 | +} | |