Skip to content

Commit

Permalink
gis_visualization.lib.php renamed as tbl_gis_visualization.lib.php. P…
Browse files Browse the repository at this point in the history
…MA_getHtmlForGisVisualization, PMA_getHtmlForOptionsList methods added to the tbl_gis_visualization.lib.php
  • Loading branch information
scnakandala committed Jun 24, 2013
1 parent a0a25c5 commit 7e9d7a8
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 112 deletions.
Expand Up @@ -185,4 +185,153 @@ function PMA_GIS_saveToFile($data, $visualizationSettings, $format, $fileName)
}
}
}

/**
* Function to get html for the options lists
*
* @param array $options array of options
* @param String $select the item that shoul be selected by default
*
* @return string $html the html for the options lists
*/
function PMA_getHtmlForOptionsList($options, $select)
{
$html = '';
foreach ($options as $option) {
$html .= '<option value="' . htmlspecialchars($option) . '"';
if ($option == $select) {
$html .= ' selected="selected"';
}
$html .= '>' . htmlspecialchars($option) . '</option>';
}

return $html;
}

/**
* 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 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 style="width: 400px; float: left;">';
$html .= '<form method="post" action="tbl_gis_visualization.php">';
$html .= PMA_generate_common_hidden_inputs($url_params);
$html .= '<table class="gis_table">';
$html .= '<tr><td><label for="labelColumn">' . __("Label column")
. '</label></td>';
$html .= '<td><select name="visualizationSettings[labelColumn]" id="labelColumn">';
$html .= '<option value="">' . __("-- None --") . '</option>';
$html .= PMA_getHtmlForOptionsList(
$labelCandidates, $visualizationSettings['labelColumn']
);
$html .= '</select></td>';
$html .= '</tr>';

$html .= '<tr><td><label for="spatial Column">';
$html .= __("Spatial column");
$html .= '</label></td>';
$html .= '<td><select name="visualizationSettings[spatialColumn]" id="spatialColumn">';
$html .= PMA_getHtmlForOptionsList(
$spatialCandidates, $visualizationSettings['spatialColumn']
);
$html .= '</select></td>';
$html .= '</tr>';

$html .= '<tr><td></td>';
$html .= '<td class="button"><input type="submit" name="displayVisualizationBtn" value="';
$html .= __('Redraw');
$html .= '" /></td></tr>';

if (! $GLOBALS['PMA_Config']->isHttps()) {
$html .= '<tr><td class="choice" colspan="2">';
$html .= '<input type="checkbox" name="visualizationSettings[choice]"'
. 'id="choice" value="useBaseLayer"';
if (isset($visualizationSettings['choice'])) {
$html .= ' checked="checked"';
}
$html .= '/>';
$html .= '<label for="choice">';
$html .= __("Use OpenStreetMaps as Base Layer");
$html .= '</label>';
$html .= '</td></tr>';
}
$html .= '</table>';
$html .= '<input type="hidden" name="displayVisualization" value="redraw">';
$html .= '<input type="hidden" name="sql_query" value="';
$html .= htmlspecialchars($sql_query) . '" />';
$html .= '</form>';
$html .= '</div>';

$html .= '<div style="float:left;">';
$html .= '<form method="post" class="disableAjax" action="tbl_gis_visualization.php">';
$html .= PMA_generate_common_hidden_inputs($url_params);
$html .= '<table class="gis_table">';
$html .= '<tr><td><label for="fileName">';
$html .= __("File name") . '</label></td>';
$html .= '<td><input type="text" name="fileName" id="fileName" /></td></tr>';

$html .= '<tr><td><label for="fileFormat">';
$html .= __("Format") . '</label></td>';
$html .= '<td><select name="fileFormat" id="fileFormat">';
$html .= '<option value="png">PNG</option>';
$html .= '<option value="pdf">PDF</option>';

if ($svg_support) {
$html .= '<option value="svg" selected="selected">SVG</option>';
}
$html .= '</select></td></tr>';

$html .= '<tr><td></td>';
$html .= '<td class="button"><input type="submit" name="saveToFileBtn" value="';
$html .= __('Download') . '" /></td></tr>';
$html .= '</table>';

$html .= '<input type="hidden" name="saveToFile" value="download">';
$html .= '<input type="hidden" name="sql_query" value="';
$html .= htmlspecialchars($sql_query) . '" />';
$html .= '</form>';
$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;
}
?>
122 changes: 10 additions & 112 deletions tbl_gis_visualization.php
Expand Up @@ -14,7 +14,7 @@
$url_params['back'] = 'sql.php';

// Import visualization functions
require_once 'libraries/gis_visualization.lib.php';
require_once 'libraries/tbl_gis_visualization.lib.php';

$response = PMA_Response::getInstance();
// Throw error if no sql query is set
Expand Down Expand Up @@ -107,114 +107,12 @@
/**
* Displays the page
*/
?>
<!-- Display visualization options -->
<div id="div_view_options">
<fieldset>
<legend><?php echo __('Display GIS Visualization'); ?></legend>
<div style="width: 400px; float: left;">
<form method="post" action="tbl_gis_visualization.php">
<?php echo PMA_generate_common_hidden_inputs($url_params); ?>
<table class="gis_table">
<tr><td><label for="labelColumn"><?php echo __("Label column"); ?></label></td>
<td><select name="visualizationSettings[labelColumn]" id="labelColumn">
<option value=""><?php echo __("-- None --"); ?></option>
<?php

foreach ($labelCandidates as $labelCandidate) {
echo('<option value="' . htmlspecialchars($labelCandidate) . '"');
if ($labelCandidate == $visualizationSettings['labelColumn']) {
echo(' selected="selected"');
}
echo('>' . htmlspecialchars($labelCandidate) . '</option>');
}
?>
</select></td>
</tr>

<tr><td><label for="spatial Column"><?php echo __("Spatial column"); ?></label></td>
<td><select name="visualizationSettings[spatialColumn]" id="spatialColumn">
<?php

foreach ($spatialCandidates as $spatialCandidate) {
echo('<option value="' . htmlspecialchars($spatialCandidate) . '"');
if ($spatialCandidate == $visualizationSettings['spatialColumn']) {
echo(' selected="selected"');
}
echo('>' . htmlspecialchars($spatialCandidate) . '</option>');
}
?>
</select></td>
</tr>
<tr><td></td>
<td class="button"><input type="submit" name="displayVisualizationBtn" value="<?php echo __('Redraw'); ?>" /></td>
</tr>
<?php
if (! $GLOBALS['PMA_Config']->isHttps()) {
?>
<tr><td class="choice" colspan="2">
<input type="checkbox" name="visualizationSettings[choice]" id="choice" value="useBaseLayer"
<?php
if (isset($visualizationSettings['choice'])) {
echo(' checked="checked"');
}
?>
/>
<label for="choice"><?php echo __("Use OpenStreetMaps as Base Layer"); ?></label>
</td></tr>
<?php
}
?>
</table>
<input type="hidden" name="displayVisualization" value="redraw">
<input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
</form>
</div>

<div style="float:left;">
<form method="post" class="disableAjax" action="tbl_gis_visualization.php">
<?php echo PMA_generate_common_hidden_inputs($url_params); ?>
<table class="gis_table">
<tr><td><label for="fileName"><?php echo __("File name"); ?></label></td>
<td><input type="text" name="fileName" id="fileName" /></td>
</tr>
<tr><td><label for="fileFormat"><?php echo __("Format"); ?></label></td>
<td><select name="fileFormat" id="fileFormat">
<option value="png">PNG</option>
<option value="pdf">PDF</option>
<?php

if ($svg_support) {
echo ('<option value="svg" selected="selected">SVG</option>');
}
?>
</select></td>
</tr>
<tr><td></td>
<td class="button"><input type="submit" name="saveToFileBtn" value="<?php echo __('Download'); ?>" /></td>
</tr>
</table>
<input type="hidden" name="saveToFile" value="download">
<input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
</form>
</div>

<div style="clear:both;">&nbsp;</div>

<div id="placeholder" style="width:<?php echo htmlspecialchars($visualizationSettings['width']); ?>px;height:<?php echo htmlspecialchars($visualizationSettings['height']); ?>px;">
<?php echo $visualization; ?>
</div>
<div id="openlayersmap"></div>
<input type="hidden" id="pmaThemeImage" value="<?php echo($GLOBALS['pmaThemeImage']); ?>" />
<script language="javascript" type="text/javascript">
function drawOpenLayers()
{
<?php
if (! $GLOBALS['PMA_Config']->isHttps()) {
echo (PMA_GIS_visualizationResults($data, $visualizationSettings, 'ol'));
}
?>
}
</script>
</fieldset>
</div>

$html = PMA_getHtmlForGisVisualization($url_params, $labelCandidates,
$spatialCandidates, $visualizationSettings, $sql_query,$visualization,
$svg_support, $data
);

$response->addHTML($html);

?>

0 comments on commit 7e9d7a8

Please sign in to comment.