/** * 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">'; $html .= '<input type="hidden" name="sql_query" value="'; $html .= htmlspecialchars($sql_query) . '" />'; $html .= '</form>'; if (!$GLOBALS['PMA_Config']->isHttps()) { $isSelected = isset($visualizationSettings['choice']) ? true : false; $html .= PMA_getHtmlForUseOpenStreetMaps($isSelected); } $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;"> </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_getHtmlForGisVisualization() method. * * @return void * @test */ public function testPMAGetHtmlForGisVisualization() { $url_params = array("url_params"); $labelCandidates = array("option1", "option2"); $spatialCandidates = array("option2", "option3"); $visualizationSettings = array('width' => 10, 'height' => 12, 'labelColumn' => 'labelColumn', 'spatialColumn' => 'spatialColumn', 'choice' => 'choice'); $sql_query = "sql_query"; $visualization = "visualization"; $svg_support = array(); $data = array(); $html = PMA_getHtmlForGisVisualization($url_params, $labelCandidates, $spatialCandidates, $visualizationSettings, $sql_query, $visualization, $svg_support, $data); $this->assertContains('<legend>' . __('Display GIS Visualization') . '</legend>', $html); $this->assertContains(PMA_URL_getHiddenInputs($url_params), $html); $output = PMA_getHtmlForSelect("labelColumn", $labelCandidates, $visualizationSettings); $this->assertContains($output, $html); $output = PMA_getHtmlForSelect("spatialColumn", $spatialCandidates, $visualizationSettings); $this->assertContains($output, $html); $this->assertContains(htmlspecialchars($sql_query), $html); $this->assertContains('>PNG</a>', $html); $this->assertContains('>PDF</a>', $html); $this->assertContains(htmlspecialchars($visualizationSettings['width']), $html); $this->assertContains(htmlspecialchars($visualizationSettings['height']), $html); $this->assertContains($visualization, $html); }