Skip to content

Commit

Permalink
Merge pull request #65 from Codeinwp/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
selul committed Feb 11, 2016
2 parents 8fecee9 + 7478dde commit 0217149
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 56 deletions.
79 changes: 74 additions & 5 deletions classes/Visualizer/Module/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,9 @@ public function renderChartPages() {
// dispatch pages
$this->_chart = $chart;
switch ( filter_input( INPUT_GET, 'tab' ) ) {
case 'data':
$this->_handleDataPage();
break;
case 'settings':
$this->_handleSettingsPage();
// changed by Ash/Upwork
$this->_handleDataAndSettingsPage();
break;
case 'type':
default:
Expand Down Expand Up @@ -294,7 +292,8 @@ private function _handleTypesPage() {
}

// redirect to next tab
wp_redirect( add_query_arg( 'tab', 'data' ) );
// changed by Ash/Upwork
wp_redirect( add_query_arg( 'tab', 'settings' ) );
return;
}
}
Expand Down Expand Up @@ -411,6 +410,76 @@ private function _handleSettingsPage() {
wp_iframe( array( $render, 'render') );
}


// changed by Ash/Upwork
private function _handleDataAndSettingsPage(){
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ) ) ) {
if ( $this->_chart->post_status == 'auto-draft' ) {
$this->_chart->post_status = 'publish';
wp_update_post( $this->_chart->to_array() );
}

update_post_meta( $this->_chart->ID, Visualizer_Plugin::CF_SETTINGS, $_POST );

$render = new Visualizer_Render_Page_Send();
$render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID );

wp_iframe( array( $render, 'render') );
return;
}

$data = $this->_getChartArray();

$sidebar = '';
$sidebar_class = 'Visualizer_Render_Sidebar_Type_' . ucfirst( $data['type'] );
if ( class_exists( $sidebar_class, true ) ) {
$sidebar = new $sidebar_class( $data['settings'] );
$sidebar->__series = $data['series'];
$sidebar->__data = $data['data'];
}

unset( $data['settings']['width'], $data['settings']['height'] );

wp_enqueue_style( 'visualizer-frame' );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'visualizer-frame' );

wp_enqueue_script( 'visualizer-preview' );
wp_enqueue_script( 'visualizer-render' );
wp_localize_script( 'visualizer-render', 'visualizer', array(
'l10n' => array(
'remotecsv_prompt' => esc_html__( 'Please, enter the URL of CSV file:', Visualizer_Plugin::NAME ),
'invalid_source' => esc_html__( 'You have entered invalid URL. Please, insert proper URL.', Visualizer_Plugin::NAME ),
),
'charts' => array(
'canvas' => $data,
),
) );

$render = new Visualizer_Render_Page_Data();
$render->chart = $this->_chart;
$render->type = $data['type'];

$render->sidebar = $sidebar;
if ( filter_input( INPUT_GET, 'library', FILTER_VALIDATE_BOOLEAN ) ) {
$render->button = filter_input( INPUT_GET, 'action' ) == Visualizer_Plugin::ACTION_EDIT_CHART
? esc_html__( 'Save Chart', Visualizer_Plugin::NAME )
: esc_html__( 'Create Chart', Visualizer_Plugin::NAME );
} else {
$render->button = esc_attr__( 'Insert Chart', Visualizer_Plugin::NAME );
}

if( defined( 'Visualizer_Pro' ) ){
global $Visualizer_Pro;
$Visualizer_Pro->_enqueueScriptsAndStyles($data);
}

$this->_addAction( 'admin_head', 'renderFlattrScript' );

wp_iframe( array( $render, 'render') );
}
// changed by Ash/Upwork

/**
* Renders flattr script in the iframe <head>
*
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class Visualizer_Plugin {

const NAME = 'visualizer';
const VERSION = '1.5';
const VERSION = '1.5.2';

// custom post types
const CPT_VISUALIZER = 'visualizer';
Expand Down
39 changes: 26 additions & 13 deletions classes/Visualizer/Render/Page/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,11 @@ protected function _renderSidebarContent() {
'chart' => $this->chart->ID,
), admin_url( 'admin-ajax.php' ) );

echo '<li class="group open">';
echo '<h3 class="group-title">', esc_html__( 'Upload CSV File', Visualizer_Plugin::NAME ), '</h3>';
echo '<div class="group-content">';
echo '<input type="button" name="back_button" class="return-settings-btn preview-btn hidden-setting" value="&laquo; Back">';
echo '<div class="initial-screen">';
echo '<iframe id="thehole" name="thehole"></iframe>';

echo '<p class="group-description">';
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 );
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 );
echo '</p>';

echo '<p class="group-description">';
Expand All @@ -89,7 +87,7 @@ protected function _renderSidebarContent() {
esc_attr_e( 'From Computer', Visualizer_Plugin::NAME );
echo '</div>';

echo '<a id="" class="button from-web from-web-btn" href="javascript:;">', esc_html__( 'From Web', Visualizer_Plugin::NAME ), '</a>';
echo '<a id="remote-file" class="button from-web from-web-btn" href="javascript:;">', esc_html__( 'From Web', Visualizer_Plugin::NAME ), '</a>';
// Added by Ash/Upwork
if( defined( 'Visualizer_Pro' ) ){
global $Visualizer_Pro;
Expand All @@ -107,16 +105,27 @@ protected function _renderSidebarContent() {
$Visualizer_Pro->_addEditorElements();
}else{
?>
<a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL;?>" title="<?php echo Visualizer_Plugin::PRO_TEASER_TITLE;?>" target="_new">
<a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL;?>" title="<?php echo Visualizer_Plugin::PRO_TEASER_TITLE;?>" class="check-pro-btn" target="_new">
<input type="button" class="button preview preview-btn" id="existing-chart-free" value="<?php esc_attr_e( 'Check PRO Version ', Visualizer_Plugin::NAME );?>">
</a>


<?php
}

echo'<input type="button" name="advanced_button" class="advanced-settings-btn preview-btn" value="'. __( 'Advanced', Visualizer_Plugin::NAME ).' &raquo;">';
// Added by Ash/Upwork

echo '</div>';
echo '</div>';
echo '</li>';

// changed by Ash/Upwork
echo '<div class= "second-screen hidden-setting">';
echo '<form id="settings-form" action="', add_query_arg( 'nonce', wp_create_nonce() ), '" method="post">';
echo $this->sidebar;
echo '</form>';
echo '</div>';
// changed by Ash/Upwork
}

/**
Expand All @@ -127,12 +136,16 @@ protected function _renderSidebarContent() {
* @access protected
*/
protected function _renderToolbar() {
echo '<a class="button button-large" href="', add_query_arg( 'tab', false ), '">';
// changed by Ash/Upwork
echo '<div class="toolbar-div">';
echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
esc_html_e( 'Back', Visualizer_Plugin::NAME );
echo '</a>';
echo '<a class="button button-large button-primary push-right" href="', add_query_arg( 'tab', 'settings' ), '">';
esc_html_e( 'Next', Visualizer_Plugin::NAME );
echo '</a>';
echo '</div>';
echo '</div>';


echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
}

}
}
Loading

0 comments on commit 0217149

Please sign in to comment.