function wpbi_mce_tag($atts, $content = null) { global $wpbi_url, $template_site, $wpdb, $wpbi_sql; // remove_filter('the_content', 'wpautop'); $template_site->set_filenames(array('iframe' => $wpbi_url['tpl']['root-path'] . $wpbi_url['tpl']['iframe'])); extract(shortcode_atts(array('type' => 'table', 'id' => NULL, 'iframe' => 'n'), $atts)); $code = ''; if ($type == 'table') { if ($iframe == 'y') { //Get Key $vo_table = new vo_table($id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); $dao_table = new dao_table($wpdb, $wpbi_sql['tname']['tables']); $vo_table = $dao_table->select($vo_table); $vo_table = $vo_table[0]; $table_key = $vo_table->table_key; //Prepare output $template_site->assign_vars(array('IFRAME_JS_AUTOHEIGHT' => $wpbi_url['jquery']['iframe-auto-height'], 'IFRAME_SRC' => $wpbi_url['iframe']['src'] . '?t=' . $table_key, 'IFRAME_WIDTH' => '100%')); ob_start(); $template_site->pparse('iframe'); $iframe_output = ob_get_contents(); ob_end_clean(); $code = $iframe_output; } else { $code = get_html_4_table($id); } } else { if ($type == 'chart') { if ($iframe == 'y') { //Get Key $selected_charts = $id; $vo_chart = new vo_chart(NULL); $vo_chart->set_chart_id($selected_charts); $vo_chart->set_chart_key($selected_charts); $dao_chart = new dao_chart($wpdb, $wpbi_sql['tname']['charts']); $vo_chart = $dao_chart->select($vo_chart); $vo_chart = $vo_chart[0]; $chart_key = $vo_chart->chart_key; //Prepare output $template_site->assign_vars(array('IFRAME_JS_AUTOHEIGHT' => $wpbi_url['jquery']['iframe-auto-height'], 'IFRAME_SRC' => $wpbi_url['iframe']['src'] . '?c=' . $chart_key, 'IFRAME_WIDTH' => is_numeric($vo_chart->width) ? $vo_chart->width . 'px' : '800px')); ob_start(); $template_site->pparse('iframe'); $iframe_output = ob_get_contents(); ob_end_clean(); $code = $iframe_output; } else { $code = get_html_4_chart($id); } } } return $code; }
ob_start(); $template_site->pparse('nvd3chart'); $test_chart_output = ob_get_contents(); ob_end_clean(); $template_site->assign_vars(array('PG_TITLE' => $wpbi_dialog['page']['charts']['title'], 'PG_DESCRIPTION' => sprintf($wpbi_dialog['chart']['saved']['edit'], $vo_chart->chart_name, htmlentities($current_qy->statement)), 'CH_EDIT_PICKER_JS' => $picker_js, 'CH_EDIT_BASIC_SETTINGS' => $wpbi_dialog['form']['label']['basic-settings'], 'CH_EDIT_NAME' => $wpbi_dialog['form']['label']['chart-name'], 'P_CH_NAME' => $wpbi_settings['parameter']['ch-name'], 'V_CH_NAME' => isset($_POST[$wpbi_settings['parameter']['ch-name']]) ? $_POST[$wpbi_settings['parameter']['ch-name']] : $vo_chart->chart_name, 'P_CH_BGCOLOR' => $wpbi_settings['parameter']['ch-bgcolor'], 'V_CH_BGCOLOR' => isset($_POST[$wpbi_settings['parameter']['ch-bgcolor']]) ? $_POST[$wpbi_settings['parameter']['ch-bgcolor']] : $vo_chart->chart_bg_color, 'CH_EDIT_WIDTH' => $wpbi_dialog['form']['label']['chart-width'], 'V_CH_WIDTH_CHECKED' => isset($_POST[$wpbi_settings['parameter']['ch-width-percent']]) || $_POST[$wpbi_settings['parameter']['action']] != $wpbi_settings['value']['edit-test'] && $vo_chart->chart_width_percent ? 'checked' : '', 'P_CH_WIDTH_PERCENT' => $wpbi_settings['parameter']['ch-width-percent'], 'P_CH_WIDTH' => $wpbi_settings['parameter']['ch-width'], 'V_CH_WIDTH' => is_numeric($_POST[$wpbi_settings['parameter']['ch-width']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-width']])) : $vo_chart->chart_width, 'CH_EDIT_X_AXIS_SETTINGS' => $wpbi_dialog['form']['label']['x-settings'], 'CH_EDIT_Y_AXIS_SETTINGS' => $wpbi_dialog['form']['label']['y-settings'], 'CH_EDIT_HEIGHT' => $wpbi_dialog['form']['label']['chart-height'], 'CH_EDIT_X_PRECISION' => $wpbi_dialog['form']['label']['chart-x-precision'], 'CH_EDIT_Y_PRECISION' => $wpbi_dialog['form']['label']['chart-y-precision'], 'CH_EDIT_Y_RANGE' => $wpbi_dialog['form']['label']['chart-y-range'], 'CH_EDIT_Y_LABEL' => $wpbi_dialog['form']['label']['chart-y-label'], 'CH_EDIT_X_LABEL' => $wpbi_dialog['form']['label']['chart-x-label'], 'CH_EDIT_Y_CURRENCY' => $wpbi_dialog['form']['label']['chart-y-currency'], 'CH_EDIT_SNAPSHOT' => $wpbi_dialog['form']['label']['chart-snapshot'], 'CH_EDIT_STACKED' => $wpbi_dialog['form']['label']['chart-stacked'], 'V_CH_HEIGHT_CHECKED' => isset($_POST[$wpbi_settings['parameter']['ch-height-percent']]) || $_POST[$wpbi_settings['parameter']['action']] != $wpbi_settings['value']['edit-test'] && $vo_chart->chart_height_percent ? 'checked' : '', 'V_CH_SNAPSHOT_CHECKED' => isset($_POST[$wpbi_settings['parameter']['ch-snapshot']]) || $_POST[$wpbi_settings['parameter']['action']] != $wpbi_settings['value']['edit-test'] && $vo_chart->chart_snapshot == 1 ? 'checked' : '', 'V_CH_STACKED_CHECKED' => isset($_POST[$wpbi_settings['parameter']['ch-stacked']]) || $_POST[$wpbi_settings['parameter']['action']] != $wpbi_settings['value']['edit-test'] && $vo_chart->chart_stacked == 1 ? 'checked' : '', 'P_CH_HEIGHT_PERCENT' => $wpbi_settings['parameter']['ch-height-percent'], 'P_CH_HEIGHT' => $wpbi_settings['parameter']['ch-height'], 'P_CH_X_PRECISION' => $wpbi_settings['parameter']['ch-x-precision'], 'P_CH_Y_PRECISION' => $wpbi_settings['parameter']['ch-y-precision'], 'P_CH_Y_RANGE' => $wpbi_settings['parameter']['ch-y-range'], 'P_CH_Y_LABEL' => $wpbi_settings['parameter']['ch-y-label'], 'P_CH_X_LABEL' => $wpbi_settings['parameter']['ch-x-label'], 'P_CH_SNAPSHOT' => $wpbi_settings['parameter']['ch-snapshot'], 'P_CH_STACKED' => $wpbi_settings['parameter']['ch-stacked'], 'P_CH_Y_CURRENCY' => $wpbi_settings['parameter']['ch-y-currency'], 'V_CH_HEIGHT' => is_numeric($_POST[$wpbi_settings['parameter']['ch-height']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-height']])) : $vo_chart->chart_height, 'V_CH_X_PRECISION' => is_numeric($_POST[$wpbi_settings['parameter']['ch-x-precision']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-x-precision']])) : $vo_chart->chart_x_axis_precision, 'CH_EDIT_X_LEGEND' => $wpbi_dialog['form']['label']['ch-x-legend'], 'V_CH_X_LEGEND' => isset($_POST[$wpbi_settings['parameter']['ch-x-legend']]) ? $_POST[$wpbi_settings['parameter']['ch-x-legend']] : $vo_chart->chart_x_legend, 'P_CH_X_LEGEND' => $wpbi_settings['parameter']['ch-x-legend'], 'CH_EDIT_X_LEGEND_SIZE' => $wpbi_dialog['form']['label']['ch-x-legend-size'], 'P_CH_X_LEGEND_SIZE' => $wpbi_settings['parameter']['ch-x-legend-size'], 'V_CH_X_LEGEND_SIZE' => is_numeric($_POST[$wpbi_settings['parameter']['ch-x-legend-size']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-x-legend-size']])) : $vo_chart->chart_x_legend_size, 'CH_EDIT_X_AXIS_THICK' => $wpbi_dialog['form']['label']['ch-x-axis-thick'], 'P_CH_X_AXIS_THICK' => $wpbi_settings['parameter']['ch-x-axis-thick'], 'V_CH_X_AXIS_THICK' => is_numeric($_POST[$wpbi_settings['parameter']['ch-x-axis-thick']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-x-axis-thick']])) : $vo_chart->chart_x_thickness, 'CH_EDIT_X_LEGEND_COLOR' => $wpbi_dialog['form']['label']['ch-x-legend-color'], 'P_CH_X_LEGEND_COLOR' => $wpbi_settings['parameter']['ch-x-legend-color'], 'V_CH_X_LEGEND_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-x-legend-color']]) ? $_POST[$wpbi_settings['parameter']['ch-x-legend-color']] : $vo_chart->chart_x_legend_color, 'CH_EDIT_X_LABEL_SIZE' => $wpbi_dialog['form']['label']['ch-x-label-size'], 'P_CH_X_LABEL_SIZE' => $wpbi_settings['parameter']['ch-x-label-size'], 'V_CH_X_LABEL_SIZE' => is_numeric($_POST[$wpbi_settings['parameter']['ch-x-label-size']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-x-label-size']])) : $vo_chart->chart_x_labels_size, 'CH_EDIT_X_LABEL_ROTATION' => $wpbi_dialog['form']['label']['ch-x-label-rotation'], 'P_CH_X_LABEL_ROTATION' => $wpbi_settings['parameter']['ch-x-label-rotation'], 'V_CH_X_LABEL_ROTATION' => is_numeric($_POST[$wpbi_settings['parameter']['ch-x-label-rotation']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-x-label-rotation']])) : $vo_chart->chart_x_labels_rotation, 'CH_EDIT_X_LABEL_COLOR' => $wpbi_dialog['form']['label']['ch-x-label-color'], 'P_CH_X_LABEL_COLOR' => $wpbi_settings['parameter']['ch-x-label-color'], 'V_CH_X_LABEL_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-x-label-color']]) ? $_POST[$wpbi_settings['parameter']['ch-x-label-color']] : $vo_chart->chart_x_labels_color, 'CH_EDIT_X_AXIS_COLOR' => $wpbi_dialog['form']['label']['ch-x-axis-color'], 'P_CH_X_AXIS_COLOR' => $wpbi_settings['parameter']['ch-x-axis-color'], 'V_CH_X_AXIS_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-x-axis-color']]) ? $_POST[$wpbi_settings['parameter']['ch-x-axis-color']] : $vo_chart->chart_x_color, 'CH_EDIT_X_GRID_COLOR' => $wpbi_dialog['form']['label']['ch-x-grid-color'], 'P_CH_X_GRID_COLOR' => $wpbi_settings['parameter']['ch-x-grid-color'], 'V_CH_X_GRID_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-x-grid-color']]) ? $_POST[$wpbi_settings['parameter']['ch-x-grid-color']] : $vo_chart->chart_x_grid_color, 'CH_EDIT_X_GRID_STEP' => $wpbi_dialog['form']['label']['ch-x-grid-step'], 'P_CH_X_GRID_STEP' => $wpbi_settings['parameter']['ch-x-grid-step'], 'V_CH_X_GRID_STEP' => is_numeric($_POST[$wpbi_settings['parameter']['ch-x-grid-step']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-x-grid-step']])) : $vo_chart->chart_x_grid_lines, 'V_CH_Y_PRECISION' => is_numeric($_POST[$wpbi_settings['parameter']['ch-y-precision']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-y-precision']])) : $vo_chart->chart_y_axis_precision, 'V_CH_Y_RANGE' => isset($_POST[$wpbi_settings['parameter']['ch-y-range']]) ? $_POST[$wpbi_settings['parameter']['ch-y-range']] : $vo_chart->chart_y_axis_range, 'V_CH_Y_LABEL' => isset($_POST[$wpbi_settings['parameter']['ch-y-label']]) ? $_POST[$wpbi_settings['parameter']['ch-y-label']] : $vo_chart->chart_y_axis_label, 'V_CH_X_LABEL' => isset($_POST[$wpbi_settings['parameter']['ch-x-label']]) ? $_POST[$wpbi_settings['parameter']['ch-x-label']] : $vo_chart->chart_x_axis_label, 'V_CH_Y_CURRENCY' => isset($_POST[$wpbi_settings['parameter']['ch-y-currency']]) ? $_POST[$wpbi_settings['parameter']['ch-y-currency']] : $vo_chart->chart_y_axis_currency, 'CH_EDIT_Y_LEGEND' => $wpbi_dialog['form']['label']['ch-y-legend'], 'V_CH_Y_LEGEND' => isset($_POST[$wpbi_settings['parameter']['ch-y-legend']]) ? $_POST[$wpbi_settings['parameter']['ch-y-legend']] : $vo_chart->chart_y_legend, 'P_CH_Y_LEGEND' => $wpbi_settings['parameter']['ch-y-legend'], 'CH_EDIT_Y_LEGEND_SIZE' => $wpbi_dialog['form']['label']['ch-y-legend-size'], 'P_CH_Y_LEGEND_SIZE' => $wpbi_settings['parameter']['ch-y-legend-size'], 'V_CH_Y_LEGEND_SIZE' => is_numeric($_POST[$wpbi_settings['parameter']['ch-y-legend-size']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-y-legend-size']])) : $vo_chart->chart_y_legend_size, 'CH_EDIT_Y_LABEL_SIZE' => $wpbi_dialog['form']['label']['ch-y-label-size'], 'P_CH_Y_LABEL_SIZE' => $wpbi_settings['parameter']['ch-y-label-size'], 'V_CH_Y_LABEL_SIZE' => is_numeric($_POST[$wpbi_settings['parameter']['ch-y-label-size']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-y-label-size']])) : $vo_chart->chart_y_labels_size, 'CH_EDIT_Y_LABEL_ROTATION' => $wpbi_dialog['form']['label']['ch-y-label-rotation'], 'P_CH_Y_LABEL_ROTATION' => $wpbi_settings['parameter']['ch-y-label-rotation'], 'V_CH_Y_LABEL_ROTATION' => is_numeric($_POST[$wpbi_settings['parameter']['ch-y-label-rotation']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-y-label-rotation']])) : $vo_chart->chart_y_labels_rotation, 'CH_EDIT_Y_LABEL_COLOR' => $wpbi_dialog['form']['label']['ch-y-label-color'], 'P_CH_Y_LABEL_COLOR' => $wpbi_settings['parameter']['ch-y-label-color'], 'V_CH_Y_LABEL_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-y-label-color']]) ? $_POST[$wpbi_settings['parameter']['ch-y-label-color']] : $vo_chart->chart_y_labels_color, 'CH_EDIT_Y_LEGEND_COLOR' => $wpbi_dialog['form']['label']['ch-y-legend-color'], 'P_CH_Y_LEGEND_COLOR' => $wpbi_settings['parameter']['ch-y-legend-color'], 'V_CH_Y_LEGEND_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-y-legend-color']]) ? $_POST[$wpbi_settings['parameter']['ch-y-legend-color']] : $vo_chart->chart_y_legend_color, 'CH_EDIT_Y_AXIS_COLOR' => $wpbi_dialog['form']['label']['ch-y-axis-color'], 'P_CH_Y_AXIS_COLOR' => $wpbi_settings['parameter']['ch-y-axis-color'], 'V_CH_Y_AXIS_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-y-axis-color']]) ? $_POST[$wpbi_settings['parameter']['ch-y-axis-color']] : $vo_chart->chart_y_color, 'CH_EDIT_Y_GRID_COLOR' => $wpbi_dialog['form']['label']['ch-y-grid-color'], 'P_CH_Y_GRID_COLOR' => $wpbi_settings['parameter']['ch-y-grid-color'], 'V_CH_Y_GRID_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-y-grid-color']]) ? $_POST[$wpbi_settings['parameter']['ch-y-grid-color']] : $vo_chart->chart_y_grid_color, 'CH_EDIT_Y_GRID_STEP' => $wpbi_dialog['form']['label']['ch-y-grid-step'], 'P_CH_Y_GRID_STEP' => $wpbi_settings['parameter']['ch-y-grid-step'], 'V_CH_Y_GRID_STEP' => is_numeric($_POST[$wpbi_settings['parameter']['ch-y-grid-step']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-y-grid-step']])) : $vo_chart->chart_y_grid_lines, 'CH_EDIT_Y_AXIS_THICK' => $wpbi_dialog['form']['label']['ch-y-axis-thick'], 'P_CH_Y_AXIS_THICK' => $wpbi_settings['parameter']['ch-y-axis-thick'], 'V_CH_Y_AXIS_THICK' => is_numeric($_POST[$wpbi_settings['parameter']['ch-y-axis-thick']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-y-axis-thick']])) : $vo_chart->chart_y_thickness, 'CH_EDIT_BGCOLOR' => $wpbi_dialog['form']['label']['chart-bgcolor'], 'CH_EDIT_TIME_FORMAT' => $wpbi_dialog['form']['label']['chart-time-format'], 'CH_EDIT_TITLE' => $wpbi_dialog['form']['label']['chart-title'], 'P_CH_TITLE' => $wpbi_settings['parameter']['ch-title'], 'V_CH_TITLE' => isset($_POST[$wpbi_settings['parameter']['ch-title']]) ? $_POST[$wpbi_settings['parameter']['ch-title']] : $vo_chart->chart_title, 'P_CH_TIME_FORMAT' => $wpbi_settings['parameter']['ch-time-format'], 'V_CH_TIME_FORMAT' => isset($_POST[$wpbi_settings['parameter']['ch-time-format']]) ? $_POST[$wpbi_settings['parameter']['ch-time-format']] : $vo_chart->chart_time_format, 'CH_EDIT_TITLE_COLOR' => $wpbi_dialog['form']['label']['chart-title-color'], 'P_CH_TITLE_COLOR' => $wpbi_settings['parameter']['ch-title-color'], 'V_CH_TITLE_COLOR' => isset($_POST[$wpbi_settings['parameter']['ch-title-color']]) ? $_POST[$wpbi_settings['parameter']['ch-title-color']] : $vo_chart->chart_title_color, 'CH_EDIT_TITLE_SIZE' => $wpbi_dialog['form']['label']['chart-title-size'], 'P_CH_TITLE_SIZE' => $wpbi_settings['parameter']['ch-title-size'], 'V_CH_TITLE_SIZE' => is_numeric($_POST[$wpbi_settings['parameter']['ch-title-size']]) ? abs(intval($_POST[$wpbi_settings['parameter']['ch-title-size']])) : $vo_chart->chart_title_size, 'CH_EDIT_TYPE' => $wpbi_dialog['form']['label']['chart-type'], 'SELECTED_' . (isset($_POST[$wpbi_settings['parameter']['ch-type']]) ? $_POST[$wpbi_settings['parameter']['ch-type']] : $vo_chart->chart_type) => 'selected', 'P_CH_TYPE' => $wpbi_settings['parameter']['ch-type'], 'P_CH_TX_COLUMN_TF' => $wpbi_settings['parameter']['ch-tx-column-tf'], 'CH_EDIT_COLUMNS' => $wpbi_dialog['form']['label']['chart-col'], 'CH_EDIT_COL_VALUE' => $wpbi_dialog['form']['label']['chart-col-value'], 'CH_EDIT_COL_LABEL' => $wpbi_dialog['form']['label']['chart-col-label'], 'CH_EDIT_COL_COLOR' => $wpbi_dialog['form']['label']['chart-col-color'], 'CH_EDIT_COL_RENAME' => $wpbi_dialog['form']['label']['chart-col-rename'], 'CH_EDIT_COL_ISTIME' => $wpbi_dialog['form']['label']['chart-col-istime'], 'LBL_BTN_EDIT' => $wpbi_dialog['button']['label']['save'], 'LBL_BTN_TEST' => $wpbi_dialog['button']['label']['test'], 'P_CH_QY' => $wpbi_settings['parameter']['qy_id'], 'P_CH_TX_COLUMN_TF' => $wpbi_settings['parameter']['ch-tx-column-tf'], 'V_CH_QY' => isset($_POST[$wpbi_settings['parameter']['qy_id']]) ? $_POST[$wpbi_settings['parameter']['qy_id']] : $vo_chart->query_id, 'P_CH_ID' => $wpbi_settings['parameter']['ch-id'], 'V_CH_ID' => isset($_POST[$wpbi_settings['parameter']['ch-id']]) ? $_POST[$wpbi_settings['parameter']['ch-id']] : $vo_chart->chart_id, 'P_CH_ACTION' => $wpbi_settings['parameter']['action'], 'V_EDIT_ACTION' => $wpbi_settings['value']['edit'], 'V_TEST_ACTION' => $wpbi_settings['value']['edit-test'], 'CH_TEST_RESULT' => $test_output, 'CH_EDIT_STYLE_DEFAULT_OPT' => $wpbi_dialog['form']['option']['table-style-default'], 'CH_EDIT_TYPE_LINE' => $wpbi_dialog['charts']['type']['line'], 'CH_EDIT_TYPE_LINE_AREA' => $wpbi_dialog['charts']['type']['line-area'], 'CH_EDIT_TYPE_BAR' => $wpbi_dialog['charts']['type']['bar'], 'CH_EDIT_TYPE_BAR_FILLED' => $wpbi_dialog['charts']['type']['bar-filled'], 'CH_EDIT_TYPE_BAR_GLASS' => $wpbi_dialog['charts']['type']['bar-glass'], 'CH_EDIT_TYPE_BAR_3D' => $wpbi_dialog['charts']['type']['bar-3d'], 'CH_EDIT_TYPE_BAR_SKETCH' => $wpbi_dialog['charts']['type']['bar-sketch'], 'CH_EDIT_TYPE_BAR_CYLINDER' => $wpbi_dialog['charts']['type']['bar-cylinder'], 'CH_EDIT_TYPE_BAR_CYLINDER_OUTLINE' => $wpbi_dialog['charts']['type']['bar-cylinder-outline'], 'CH_EDIT_TYPE_BAR_ROUNDED_GLASS' => $wpbi_dialog['charts']['type']['bar-rounded-glass'], 'CH_EDIT_TYPE_BAR_DOME' => $wpbi_dialog['charts']['type']['bar-dome'], 'CH_EDIT_TYPE_BAR_ROUND_3D' => $wpbi_dialog['charts']['type']['bar-round-3d'], 'CH_EDIT_TYPE_BAR_HORIZONTAL' => $wpbi_dialog['charts']['type']['bar-horizontal'], 'CH_EDIT_TYPE_BAR_STACKED' => $wpbi_dialog['charts']['type']['bar-stacked'], 'CH_EDIT_TYPE_PIE' => $wpbi_dialog['charts']['type']['pie'], 'CH_EDIT_TYPE_DONUT' => $wpbi_dialog['charts']['type']['donut'], 'CH_EDIT_TYPE_SCATTER' => $wpbi_dialog['charts']['type']['scatter'], 'CH_EDIT_TYPE_SCATTER_LINE' => $wpbi_dialog['charts']['type']['scatter-line'], 'CH_EDIT_TYPE_CUMULATIVE_LINE' => $wpbi_dialog['charts']['type']['cumulative-line'], 'CH_EDIT_TYPE_LINE_AND_BAR' => $wpbi_dialog['charts']['type']['line-and-bar'], 'CH_EDIT_TYPE_MULTI_LINE_FOCUS' => $wpbi_dialog['charts']['type']['multi-line-focus'], 'CH_EDIT_TYPE_STACKED_AREA' => $wpbi_dialog['charts']['type']['stacked-area'], 'CH_EDIT_TYPE_RADAR' => $wpbi_dialog['charts']['type']['radar'], 'CH_EDIT_COLUMNS_OPTIONS' => $columns_html, 'CH_EDIT_CHART_TEST' => $test_chart_output, 'CH_EDIT_FORM_ACTION' => substr(substr(strrchr($_SERVER['REQUEST_URI'], '/'), 1), 0, strpos(substr(strrchr($_SERVER['REQUEST_URI'], '/'), 1), '&')))); //Parse tpl $template_site->pparse('header'); $template_site->pparse('charts-edit-2'); } /**** Edit chart: save modifications ***/ if ($_POST[$wpbi_settings['parameter']['action']] == $wpbi_settings['value']['edit'] && isset($_POST[$wpbi_settings['parameter']['ch-id']])) { //set chart metadata $vo_new_chart = new vo_chart(NULL); $vo_new_chart->set_chart_id($_POST[$wpbi_settings['parameter']['ch-id']]); $vo_new_chart->set_query_id($_POST[$wpbi_settings['parameter']['qy_id']]); $vo_new_chart->set_chart_key(md5(date('YmdHis') . rand(100))); $vo_new_chart->set_chart_name($_POST[$wpbi_settings['parameter']['ch-name']]); $vo_new_chart->set_chart_type($_POST[$wpbi_settings['parameter']['ch-type']]); $vo_new_chart->set_chart_title($_POST[$wpbi_settings['parameter']['ch-title']]); $vo_new_chart->set_chart_title_size($_POST[$wpbi_settings['parameter']['ch-title-size']]); $vo_new_chart->set_chart_title_color($_POST[$wpbi_settings['parameter']['ch-title-color']]); $vo_new_chart->set_chart_time_format($_POST[$wpbi_settings['parameter']['ch-time-format']]); $vo_new_chart->set_chart_bg_color($_POST[$wpbi_settings['parameter']['ch-bgcolor']]); $vo_new_chart->set_chart_width($_POST[$wpbi_settings['parameter']['ch-width']]); $vo_new_chart->set_chart_width_percent(isset($_POST[$wpbi_settings['parameter']['ch-width-percent']]) ? 1 : 0); $vo_new_chart->set_chart_height($_POST[$wpbi_settings['parameter']['ch-height']]); $vo_new_chart->set_chart_height_percent(isset($_POST[$wpbi_settings['parameter']['ch-height-percent']]) ? 1 : 0); $vo_new_chart->set_chart_snapshot(isset($_POST[$wpbi_settings['parameter']['ch-snapshot']]) ? 1 : 0); $vo_new_chart->set_chart_stacked(isset($_POST[$wpbi_settings['parameter']['ch-stacked']]) ? 1 : 0); $vo_new_chart->set_chart_x_color($_POST[$wpbi_settings['parameter']['ch-x-axis-color']]); $vo_new_chart->set_chart_x_precision($_POST[$wpbi_settings['parameter']['ch-x-precision']]);
function get_html_4_chart($id) { global $wpdb, $qy_table_databases, $qy_table_queries, $wpbi_sql, $wpbi_settings, $wpbi_url, $wpbi_dialog, $lng, $language, $template_site; $template_site->set_filenames(array('chart' => $wpbi_url['tpl']['root-path'] . $wpbi_url['tpl']['nvd3chart'])); $chart_id = $id; //id or key $search_by_key = false; if (!is_numeric($chart_id)) { if (strlen($chart_id) == 32 && strpos($chart_id, ' ') === false) { $search_by_key = true; } else { return '<p>Could not create table. Wrong ID provided.</p>'; } } $test_output = ''; //Store the test output //Get chart metadata $selected_charts = $chart_id; $vo_chart = new vo_chart(NULL); $vo_chart->set_chart_id($selected_charts); $vo_chart->set_chart_key($selected_charts); $dao_chart = new dao_chart($wpdb, $wpbi_sql['tname']['charts']); $vo_chart = $search_by_key ? $dao_chart->select_by_key($vo_chart) : $dao_chart->select($vo_chart); $vo_chart = $vo_chart[0]; //Get cols metadata $vo_ch_cols = new vo_ch_cols(); $vo_ch_cols->set_ch_id($vo_chart->chart_id); $dao_ch_cols = new dao_ch_cols($wpdb, $wpbi_sql['tname']['chart-cols']); $vo_ch_cols = $dao_ch_cols->select($vo_ch_cols); //Get selected query $dao_query = new dao_query($wpdb, $wpbi_sql['tname']['queries']); $tgt_query = new vo_query($vo_chart->query_id, NULL, NULL, NULL, NULL); $vo_query = $dao_query->select($tgt_query); $vo_query = $vo_query[0]; //Select associated db $dao_database = new dao_database($wpdb, $wpbi_sql['tname']['databases']); $tgt_database = new vo_database($vo_query->db_id, NULL, NULL, NULL, NULL); $vo_database = $dao_database->select($tgt_database); $vo_database = $vo_database[0]; //Create wpdb object and execute the query $my_test_db = new wpdb($vo_database->user, $vo_database->pass, $vo_database->name, $vo_database->host); $query = new query($vo_query->statement, $wpdb, $wpbi_sql['tname']['vars']); $total_rows = $my_test_db->get_results($query->count_qy_results(), 'ARRAY_N'); if (count($total_rows) == 0) { return "<div style='padding:40px;'><h1 style='color: red;'>The query returned no data</h1>" . "<p>Please check the DB connectivity or your SQL query syntax</p></div>"; } $total_rows = intval($total_rows[0][0]); //get query resultset $my_test_rows = $my_test_db->get_results($query->stmt, 'ARRAY_N'); //get columns $x_label_cols = array(); $color_cols = array(); $tx_label_cols = array(); $values_cols = array(); $istime_cols = array(); $stacked_label_cols = array(); $stacked_label_cols_color = array(); $col_idx = 0; foreach ($vo_ch_cols as $vo_ch_col) { array_push($tx_label_cols, $vo_ch_col->col_label); array_push($color_cols, $vo_ch_col->col_color); if ($vo_ch_col->is_label) { array_push($x_label_cols, $col_idx); } if ($vo_ch_col->is_value) { array_push($values_cols, $col_idx); array_push($stacked_label_cols, $vo_ch_col->col_label); array_push($stacked_label_cols_color, $vo_ch_col->col_color); } if ($vo_ch_col->is_time) { array_push($istime_cols, $col_idx); } $col_idx++; } //Create chart $wpbi_chart = new chart($my_test_rows); $wpbi_chart->set_name($vo_chart->chart_name); $wpbi_chart->set_tooltip($vo_chart->chart_tooltip); $wpbi_chart->set_width($vo_chart->chart_width . ($vo_chart->chart_width_percent ? '%' : '')); $wpbi_chart->set_height($vo_chart->chart_height . ($vo_chart->chart_height_percent ? '%' : '')); $wpbi_chart->set_bg_colour($vo_chart->chart_bg_color); $wpbi_chart->set_title($vo_chart->chart_title); $wpbi_chart->set_title_color($vo_chart->chart_title_color); $wpbi_chart->set_title_size($vo_chart->chart_title_size); $wpbi_chart->set_type($vo_chart->chart_type); $wpbi_chart->set_x_axis_step_percent($vo_chart->chart_x_grid_lines); $wpbi_chart->set_y_axis_step_percent($vo_chart->chart_y_grid_lines); $wpbi_chart->set_time_format($vo_chart->chart_time_format); //Get values, labels, colors $label_color = array(); $stacked_label_color = array(); $row_idx = 0; $label_tmp_x = ""; foreach ($my_test_rows as $my_test_row) { for ($col_idx = 0; $col_idx < sizeof($my_test_row); $col_idx++) { //Colors $label_color[$tx_label_cols[$col_idx]] = $color_cols[$col_idx]; if (in_array($col_idx, $values_cols)) { $stacked_label_color[$tx_label_cols[$col_idx]] = $color_cols[$col_idx]; } if (in_array($col_idx, $values_cols)) { //create different array of values for each selected column $current_value = is_string($my_test_row[$col_idx]) ? $my_test_row[$col_idx] : floatval($my_test_row[$col_idx]); if (isset($data[$tx_label_cols[$col_idx]])) { array_push($data[$tx_label_cols[$col_idx]], $current_value); } else { $data[$tx_label_cols[$col_idx]] = array(); array_push($data[$tx_label_cols[$col_idx]], $current_value); } } if (in_array($col_idx, $values_cols)) { //create different array of values for each selected column (for stacked bar chart) $current_value = floatval($my_test_row[$col_idx]); if (isset($data_stacked[$row_idx])) { array_push($data_stacked[$row_idx], $current_value); } else { $data_stacked[$row_idx] = array(); array_push($data_stacked[$row_idx], $current_value); } } if (in_array($col_idx, $x_label_cols)) { //Concatenate selected columns $label_tmp_x = $label_tmp_x == '' ? $my_test_row[$col_idx] : $label_tmp_x . $wpbi_dialog['charts']['x-label']['concat-string'] . $my_test_row[$col_idx]; } } if ($label_tmp_x != NULL) { $label_x[] = $label_tmp_x; $label_tmp_x = ''; } $row_idx++; } //Assign values and labels switch ($wpbi_chart->type) { case chart::DONUT: case chart::PIE: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $vo_chart->chart_x_labels_size, $vo_chart->chart_x_labels_color); } foreach ($data as $key => $value) { //Overwrite data value for pie chart in order to show labels (via pie_value object) if (sizeof($label_x) > 0) { for ($idx = 0; $idx < sizeof($value); $idx++) { $value[$idx] = new pie_value($value[$idx], $label_x[$idx]); } } $wpbi_chart->set_tooltip($wpbi_dialog['charts']['pie']['tooltip']); $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colours($wpbi_settings['pie-chart']['color-set']); } break; case chart::BAR_STACKED: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $_POST[$wpbi_settings['parameter']['ch-x-label-size']], $_POST[$wpbi_settings['parameter']['ch-x-label-color']]); $wpbi_chart->x_axis_istime = sizeof($istime_cols) > 0; if ($wpbi_chart->x_axis_istime) { $wpbi_chart->x_axis_labels->labels = $wpbi_chart->convert_to_time($wpbi_chart->x_axis_labels->labels); } } $wpbi_chart->set_y_axis_labels_color($_POST[$wpbi_settings['parameter']['ch-y-label-color']]); $wpbi_chart->set_y_axis_labels_size($_POST[$wpbi_settings['parameter']['ch-y-label-size']]); foreach ($data_stacked as $key => $value) { $wpbi_chart->create_element('BAR_STACKED', $value); $wpbi_chart->elements['BAR_STACKED']->set_colours($stacked_label_color); } break; case chart::STACKED_AREA: case chart::LINE_AREA: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $vo_chart->chart_x_labels_size, $vo_chart->chart_x_labels_color); } $wpbi_chart->set_y_axis_labels_color($vo_chart->chart_y_labels_color); $wpbi_chart->set_y_axis_labels_size($vo_chart->chart_y_labels_size); foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); $wpbi_chart->elements[$key]->set_fill_colour($label_color[$key]); $wpbi_chart->elements[$key]->set_fill_alpha(0.5); } break; case chart::RADAR: if (sizeof($label_x) > 0) { $wpbi_chart->set_y_axis_labels($label_x, $vo_chart->chart_y_labels_size, $vo_chart->chart_y_labels_color); } foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); } break; case chart::BAR_HORIZONTAL: if (sizeof($label_x) > 0) { $wpbi_chart->set_y_axis_labels($label_x, $vo_chart->chart_y_labels_size, $vo_chart->chart_y_labels_color); } $wpbi_chart->set_x_axis_labels_color($vo_chart->chart_x_labels_color); $wpbi_chart->set_x_axis_labels_size($vo_chart->chart_x_labels_size); foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); } break; default: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $vo_chart->chart_x_labels_size, $vo_chart->chart_x_labels_color, sizeof($istime_cols) > 0); $wpbi_chart->x_axis_istime = sizeof($istime_cols) > 0; } else { $wpbi_chart->set_x_axis_labels_color($vo_chart->chart_x_labels_color); $wpbi_chart->set_x_axis_labels_size($vo_chart->chart_x_labels_size); } $wpbi_chart->set_y_axis_labels_color($vo_chart->chart_y_labels_color); $wpbi_chart->set_y_axis_labels_size($vo_chart->chart_y_labels_size); foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); } break; } //Set legends $wpbi_chart->set_y_legend($vo_chart->chart_y_legend, $vo_chart->chart_y_legend_size, $vo_chart->chart_y_legend_color); $wpbi_chart->set_x_legend($vo_chart->chart_x_legend, $vo_chart->chart_x_legend_size, $vo_chart->chart_x_legend_color); $wpbi_chart->set_x_label($vo_chart->chart_x_axis_label); $wpbi_chart->set_x_axis_labels_rotation($vo_chart->chart_x_labels_rotation); $wpbi_chart->set_y_axis_labels_rotation($vo_chart->chart_y_labels_rotation); $wpbi_chart->set_y_axis_color($vo_chart->chart_y_color); $wpbi_chart->set_y_axis_grid_color($vo_chart->chart_y_grid_color); $wpbi_chart->set_y_axis_thickness($vo_chart->chart_y_thickness); $wpbi_chart->set_x_axis_color($vo_chart->chart_x_color); $wpbi_chart->set_x_axis_grid_color($vo_chart->chart_x_grid_color); $wpbi_chart->set_x_axis_thickness($vo_chart->chart_x_thickness); $wpbi_chart->set_x_precision($vo_chart->chart_x_axis_precision); $wpbi_chart->set_y_precision($vo_chart->chart_y_axis_precision); $wpbi_chart->set_y_range($vo_chart->chart_y_axis_range); $wpbi_chart->set_y_label($vo_chart->chart_y_axis_label); $wpbi_chart->set_y_currency($vo_chart->chart_y_axis_currency); $wpbi_chart->set_snapshot($vo_chart->chart_snapshot == 1); $wpbi_chart->set_stacked($vo_chart->chart_stacked == 1); //Main legend for stacked chart if ($wpbi_chart->type == chart::BAR_STACKED) { $stacked_keys = array(); for ($i = 0; $i < sizeof($stacked_label_cols_color); $i++) { array_push($stacked_keys, new bar_stack_key($stacked_label_cols_color[$i], $stacked_label_cols[$i], 10)); } $wpbi_chart->elements['BAR_STACKED']->set_keys($stacked_keys); } $wpbi_chart->build(); //Import scripts echo ' <link rel="stylesheet" href="' . $wpbi_url['nvd3']['css'] . '" type="text/css" /> <script type="text/javascript" src="' . $wpbi_url['nvd3']['d3js'] . '"></script> <script type="text/javascript" src="' . $wpbi_url['nvd3']['nvd3'] . '"></script> '; //Set template variables $template_site->assign_vars(array('CH_NEW_CHART_NAME' => $selected_charts, 'CH_NEW_CHART_WIDTH' => $wpbi_chart->width, 'CH_NEW_CHART_HEIGHT' => $wpbi_chart->height, 'CH_NEW_CHART_RESIZE' => 'chart_resize', 'CH_NEW_CHART_JSON' => $wpbi_chart->get_json_code(), 'CH_NEW_CHART_NVD3_CODE' => $wpbi_chart->get_nvd3_chart_code(), 'CH_NEW_CHART_NVD3_HTML' => $wpbi_chart->get_nvd3_chart_html(), 'CH_NEW_CHART_NVD3_DATA' => $wpbi_chart->get_nvd3_chart_data(), 'CH_NEW_CHART_NVD3_PLACEHOLDER' => $wpbi_chart->get_nvd3_chart_placeholder())); ob_start(); $template_site->pparse('chart'); $chart_output = ob_get_contents(); ob_end_clean(); return $chart_output; }