/**
 * Function to generate HTML for the GIS visualization page
 *
 * @param array   $url_params            url parameters
 * @param array   $labelCandidates       list of candidates for the label
 * @param array   $spatialCandidates     list of candidates for the spatial column
 * @param array   $visualizationSettings visualization settings
 * @param String  $sql_query             the sql query
 * @param String  $visualization         HTML and js code for the visualization
 * @param boolean $svg_support           whether svg download format is supported
 * @param array   $data                  array of visualizing data
 *
 * @return string HTML code for the GIS visualization
 */
function PMA_getHtmlForGisVisualization($url_params, $labelCandidates, $spatialCandidates, $visualizationSettings, $sql_query, $visualization, $svg_support, $data)
{
    $html = '<div id="div_view_options">';
    $html .= '<fieldset>';
    $html .= '<legend>' . __('Display GIS Visualization') . '</legend>';
    $html .= '<div id="gis_div" style="position:relative;">';
    $html .= '<form method="post" action="tbl_gis_visualization.php">';
    $html .= PMA_URL_getHiddenInputs($url_params);
    $html .= PMA_getHtmlForSelect("labelColumn", $labelCandidates, $visualizationSettings);
    $html .= PMA_getHtmlForSelect("spatialColumn", $spatialCandidates, $visualizationSettings);
    $html .= '<input type="hidden" name="displayVisualization" value="redraw">';
    if (!$GLOBALS['PMA_Config']->isHttps()) {
        $isSelected = isset($visualizationSettings['choice']) ? true : false;
        $html .= PMA_getHtmlForUseOpenStreetMaps($isSelected);
    }
    $html .= PMA_Util::getStartAndNumberOfRowsPanel($sql_query);
    $html .= '</form>';
    $html .= '<div class="pma_quick_warp" style="width: 50px; position: absolute;' . ' right: 0; top: 0; cursor: pointer;">';
    $html .= '<div class="drop_list">';
    $html .= '<span class="drop_button" style="padding: 0; border: 0;">';
    $html .= PMA_Util::getImage('b_saveimage', __('Save'));
    $html .= '</span>';
    $url_params['sql_query'] = $sql_query;
    $url_params['saveToFile'] = 'download';
    $url = 'tbl_gis_visualization.php' . PMA_URL_getCommon($url_params);
    $html .= '<ul>';
    $html .= PMA_getHtmlForGisDownloadLink($url, 'png', 'PNG');
    $html .= PMA_getHtmlForGisDownloadLink($url, 'pdf', 'PDF');
    if ($svg_support) {
        $html .= PMA_getHtmlForGisDownloadLink($url, 'svg', 'SVG');
    }
    $html .= '</ul>';
    $html .= '</div></div>';
    $html .= '</div>';
    $html .= '<div style="clear:both;">&nbsp;</div>';
    $html .= '<div id="placeholder" style="width:';
    $html .= htmlspecialchars($visualizationSettings['width']) . 'px;height:';
    $html .= htmlspecialchars($visualizationSettings['height']) . 'px;">';
    $html .= $visualization;
    $html .= '</div>';
    $html .= '<div id="openlayersmap"></div>';
    $html .= '<input type="hidden" id="pmaThemeImage" value="';
    $html .= $GLOBALS['pmaThemeImage'] . '" />';
    $html .= '<script language="javascript" type="text/javascript">';
    $html .= 'function drawOpenLayers()';
    $html .= '{';
    if (!$GLOBALS['PMA_Config']->isHttps()) {
        $html .= PMA_GIS_visualizationResults($data, $visualizationSettings, 'ol');
    }
    $html .= '}';
    $html .= '</script>';
    $html .= '</fieldset>';
    $html .= '</div>';
    return $html;
}
 /**
  * Tests for PMA_getHtmlForTableChartDisplay() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForTableChartDisplay()
 {
     $_SESSION[' PMA_token '] = "PMA_token";
     $_SESSION['tmpval']['pos'] = "pos";
     $_SESSION['tmpval']['max_rows'] = "all";
     $GLOBALS['cfg']['MaxRows'] = 10;
     $url_query = "url_query";
     $url_params = array("url" => "url_params");
     $keys = array("x1" => "value1", "x2" => "value2");
     $fields_meta = array("x1" => new Mock_Meta("type1"), "x2" => new Mock_Meta("type3"));
     $numeric_types = array("type1", "type2");
     $numeric_column_count = 2;
     $sql_query = "sql_query";
     $yaxis = null;
     $html = PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys, $fields_meta, $numeric_types, $numeric_column_count, $sql_query);
     //case 1: PMA_getHtmlForPmaTokenAndUrlQuery
     $this->assertContains(PMA_getHtmlForPmaTokenAndUrlQuery($url_query), $html);
     //case 2: PMA_getHtmlForPmaTokenAndUrlQuery
     $this->assertContains(PMA_URL_getHiddenInputs($url_params), $html);
     //case 3: options
     $this->assertContains(PMA_getHtmlForChartTypeOptions(), $html);
     $this->assertContains(PMA_getHtmlForStackedOption(), $html);
     //case 4: options
     $this->assertContains(__('Chart title'), $html);
     //case 5: options
     $this->assertContains(PMA_getHtmlForChartXAxisOptions($keys, $yaxis), $html);
     $this->assertContains(PMA_getHtmlForChartSeriesOptions($keys, $fields_meta, $numeric_types, $yaxis, $numeric_column_count), $html);
     //case 6: PMA_getHtmlForDateTimeCols
     $this->assertContains(PMA_getHtmlForDateTimeCols($keys, $fields_meta), $html);
     $this->assertContains(PMA_getHtmlForTableAxisLabelOptions($yaxis, $keys), $html);
     $this->assertContains(PMA_Util::getStartAndNumberOfRowsPanel($sql_query), $html);
     $this->assertContains(PMA_getHtmlForChartAreaDiv(), $html);
 }
/**
 * Function to get html for displaying table chart
 *
 * @param string $url_query            url query
 * @param array  $url_params           url parameters
 * @param array  $keys                 keys
 * @param array  $fields_meta          fields meta
 * @param array  $numeric_types        numeric types
 * @param int    $numeric_column_count numeric column count
 * @param string $sql_query            sql query
 *
 * @return string
 */
function PMA_getHtmlForTableChartDisplay($url_query, $url_params, $keys, $fields_meta, $numeric_types, $numeric_column_count, $sql_query)
{
    // pma_token/url_query needed for chart export
    $htmlString = PMA_getHtmlForPmaTokenAndUrlQuery($url_query);
    $htmlString .= '<!-- Display Chart options -->' . '<div id="div_view_options">' . '<form method="post" id="tblchartform" action="tbl_chart.php" ' . 'class="ajax">' . PMA_URL_getHiddenInputs($url_params) . '<fieldset>' . '<legend>' . __('Display chart') . '</legend>' . '<div style="float:left; width:420px;">';
    $htmlString .= PMA_getHtmlForChartTypeOptions();
    $htmlString .= PMA_getHtmlForStackedOption();
    $htmlString .= '<input type="text" name="chartTitle" value="' . __('Chart title') . '">' . '</div>';
    $xaxis = null;
    $htmlString .= PMA_getHtmlForChartXAxisOptions($keys, $xaxis);
    $htmlString .= PMA_getHtmlForChartSeriesOptions($keys, $fields_meta, $numeric_types, $xaxis, $numeric_column_count);
    $htmlString .= PMA_getHtmlForDateTimeCols($keys, $fields_meta);
    $htmlString .= PMA_getHtmlForNumericCols($keys, $fields_meta, $numeric_types);
    $htmlString .= '</div>';
    $htmlString .= PMA_getHtmlForTableAxisLabelOptions($xaxis, $keys);
    $htmlString .= PMA_getHtmlForAlternativeDataFormat($keys, $fields_meta, $numeric_types, $xaxis);
    $htmlString .= PMA_Util::getStartAndNumberOfRowsPanel($sql_query);
    $htmlString .= PMA_getHtmlForChartAreaDiv();
    $htmlString .= '</fieldset>' . '</form>' . '</div>';
    return $htmlString;
}