Merge pull request #448 from scnakandala/gsoc_2013
refactoring tbl_gis_visualization.php
This commit is contained in:
commit
ba390cdf02
@ -185,4 +185,190 @@ 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 get html for the lebel column and spatial column
|
||||
*
|
||||
* @param String $column the column type. i.e either "labelColumn"
|
||||
* or "spatialColumn"
|
||||
* @param array $columnCandidates the list of select options
|
||||
* @param array $visualizationSettings visualization settings
|
||||
* @return String $html
|
||||
*/
|
||||
function PMA_getHtmlForColumn($column, $columnCandidates, $visualizationSettings)
|
||||
{
|
||||
$html = '<tr><td><label for="labelColumn">';
|
||||
$html .= ($column=="labelColumn") ? __("Label column") : __("Spatial column");;
|
||||
$html .= '</label></td>';
|
||||
|
||||
$html .= '<td><select name="visualizationSettings[' . $column . ']" id="'
|
||||
. $column . '">';
|
||||
|
||||
if ($column == "labelColumn") {
|
||||
$html .= '<option value="">' . __("-- None --") . '</option>';
|
||||
}
|
||||
|
||||
$html .= PMA_getHtmlForOptionsList(
|
||||
$columnCandidates, $visualizationSettings[$column]
|
||||
);
|
||||
|
||||
$html .= '</select></td>';
|
||||
$html .= '</tr>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the option of using oprn street maps
|
||||
*
|
||||
* @param boolean $isSelected the default value
|
||||
*
|
||||
* @return string $html
|
||||
*/
|
||||
function PMA_getHtmlForUseOpenStreetMaps($isSelected)
|
||||
{
|
||||
$html = '<tr><td class="choice" colspan="2">';
|
||||
$html .= '<input type="checkbox" name="visualizationSettings[choice]"'
|
||||
. 'id="choice" value="useBaseLayer"';
|
||||
if ($isSelected) {
|
||||
$html .= ' checked="checked"';
|
||||
}
|
||||
$html .= '/>';
|
||||
$html .= '<label for="choice">';
|
||||
$html .= __("Use OpenStreetMaps as Base Layer");
|
||||
$html .= '</label>';
|
||||
$html .= '</td></tr>';
|
||||
|
||||
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 .= PMA_getHtmlForColumn("labelColumn", $labelCandidates,
|
||||
$visualizationSettings
|
||||
);
|
||||
|
||||
$html .= PMA_getHtmlForColumn("spatialColumn", $spatialCandidates,
|
||||
$visualizationSettings
|
||||
);
|
||||
|
||||
$html .= '<tr><td></td>';
|
||||
$html .= '<td class="button"><input type="submit" name="displayVisualizationBtn" value="';
|
||||
$html .= __('Redraw');
|
||||
$html .= '" /></td></tr>';
|
||||
|
||||
if (! $GLOBALS['PMA_Config']->isHttps()) {
|
||||
$isSelected = isset($visualizationSettings['choice']) ? true : false;
|
||||
$html .= PMA_getHtmlForUseOpenStreetMaps($isSelected);
|
||||
}
|
||||
|
||||
$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;"> </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;
|
||||
}
|
||||
?>
|
||||
@ -14,7 +14,7 @@ $url_params['goto'] = $cfg['DefaultTabDatabase'];
|
||||
$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
|
||||
@ -107,114 +107,12 @@ $visualization = PMA_GIS_visualizationResults(
|
||||
/**
|
||||
* 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>
|
||||
$html = PMA_getHtmlForGisVisualization($url_params, $labelCandidates,
|
||||
$spatialCandidates, $visualizationSettings, $sql_query,$visualization,
|
||||
$svg_support, $data
|
||||
);
|
||||
|
||||
<tr><td><label for="spatial Column"><?php echo __("Spatial column"); ?></label></td>
|
||||
<td><select name="visualizationSettings[spatialColumn]" id="spatialColumn">
|
||||
<?php
|
||||
$response->addHTML($html);
|
||||
|
||||
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;"> </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>
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user