2010-02-15 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_gis.php: add the function "getMapConnection" get the row
	of connection for id connection, "updateMap" function update the all data in
	the DB, "validateMapData" function validate the map data previous update or
	save in the database and if it's invalid, write the css code for set colors
	and other styles, "getMapData" return all data about map for id map,
	"addConectionMapsInForm" tranlate the map connection array to html code and
	javascript for to write in the form when edit, "addLayerList" translate the
	layer array to html code and javascript for write in the form when edit.  
	
	* operation/gis_maps/render_view.php: fix the link to edit map.
	
	* godmode/gis_maps/configure_gis_map.php: change many parts of the source
	code for add the method the edit in the form and add more usability
	to form.
	
	* godmode/gis_maps/index.php: fix the links to edit and view map.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2370 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-02-16 15:28:07 +00:00
parent 3ea775dd8f
commit 23af6b04ff
5 changed files with 568 additions and 86 deletions

View File

@ -1,3 +1,22 @@
2010-02-15 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_gis.php: add the function "getMapConnection" get the row
of connection for id connection, "updateMap" function update the all data in
the DB, "validateMapData" function validate the map data previous update or
save in the database and if it's invalid, write the css code for set colors
and other styles, "getMapData" return all data about map for id map,
"addConectionMapsInForm" tranlate the map connection array to html code and
javascript for to write in the form when edit, "addLayerList" translate the
layer array to html code and javascript for write in the form when edit.
* operation/gis_maps/render_view.php: fix the link to edit map.
* godmode/gis_maps/configure_gis_map.php: change many parts of the source
code for add the method the edit in the form and add more usability
to form.
* godmode/gis_maps/index.php: fix the links to edit and view map.
2010-02-15 Pablo de la Concepción <pablo.concepcion@artica.es> 2010-02-15 Pablo de la Concepción <pablo.concepcion@artica.es>
* extras/pandoradb_migrate_v3.0_to_v3.1.sql: Added cusstom colums ( * extras/pandoradb_migrate_v3.0_to_v3.1.sql: Added cusstom colums (
@ -6,6 +25,7 @@
parameters that were missing. Reordering a bit. And fixed a missplaced ';' parameters that were missing. Reordering a bit. And fixed a missplaced ';'
2010-02-15 Eric Ross <eric.ross.c@gmail.com> 2010-02-15 Eric Ross <eric.ross.c@gmail.com>
First batch of changes to implement the new log4x data type. First batch of changes to implement the new log4x data type.
Modified files to show the new data type: Modified files to show the new data type:

View File

@ -20,12 +20,66 @@ check_login ();
require_once ('include/functions_gis.php'); require_once ('include/functions_gis.php');
require_javascript_file('openlayers.pandora'); require_javascript_file('openlayers.pandora');
//Global vars for javascript and scripts.
?>
<script type="text/javascript">
var connectionMaps = Array();
var agentList = Array();
var countAgentList = 0;
var countLayer = 0;
var layerList = Array();
function isInt(x) {
var y=parseInt(x);
if (isNaN(y)) return false;
return x==y && x.toString()==y.toString();
}
function updateArrowLayers() {
var count = 0;
var lastIndex = null;
for (var index in layerList) {
//int because in the object array there are method as string
if (isInt(index)) {
numLayer = layerList[index];
layerObj = $("#layer_item_" + numLayer);
//First element
if (count == 0) {
$('.up_arrow', layerObj).html('');
}
else {
$('.up_arrow', layerObj).html('<a class="up_arrow" href="javascript: upLayer(' + numLayer + ');"><?php print_image ("images/up.png"); ?></a>');
}
$('.down_arrow', layerObj).html('<a class="down_arrow" href="javascript: downLayer(' + numLayer + ');"><?php print_image ("images/down.png"); ?></a>');
count++;
lastIndex = index;
}
}
//Last element
if (lastIndex != null) {
numLayer = layerList[lastIndex];
layerObj = $("#layer_item_" + numLayer);
$('.down_arrow', layerObj).html('');
}
}
</script>
<?php
if (! give_acl ($config['id_user'], 0, "IW")) { if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access map builder"); audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access map builder");
require ("general/noaccess.php"); require ("general/noaccess.php");
return; return;
} }
//debugPrint($_POST); //debugPrint($_POST);
$action = get_parameter('action', 'new_map'); $action = get_parameter('action', 'new_map');
@ -46,29 +100,56 @@ switch ($action) {
$map_group_id = get_parameter('map_group_id'); $map_group_id = get_parameter('map_group_id');
$map_connection_list_temp = explode(",",get_parameter('map_connection_list')); $map_connection_list_temp = explode(",",get_parameter('map_connection_list'));
foreach ($map_connection_list_temp as $index => $value) {
$cleanValue = trim($value);
if ($cleanValue == '') {
unset($map_connection_list_temp[$index]);
}
}
$layer_list = explode(",",get_parameter('layer_list')); $layer_list = explode(",",get_parameter('layer_list'));
foreach ($layer_list as $index => $value) {
$cleanValue = trim($value);
if ($cleanValue == '') {
unset($layer_list[$index]);
}
}
$map_connection_default = get_parameter('map_connection_default'); $map_connection_default = get_parameter('map_connection_default');
$map_connection_list = array(); $map_connection_list = array();
foreach ($map_connection_list_temp as $idMapConnection) { foreach ($map_connection_list_temp as $idMapConnection) {
$default = false; $default = 0;
if ($map_connection_default == $idMapConnection) if ($map_connection_default == $idMapConnection)
$default = true; $default = 1;
$map_connection_list[] = array('id_conection' => $idMapConnection, 'default' => $default); $map_connection_list[] = array('id_conection' => $idMapConnection, 'default' => $default);
} }
$arrayLayers = array(); $arrayLayers = array();
foreach ($layer_list as $layerID) { foreach ($layer_list as $layerID) {
$arrayLayers[] = JSON_decode($_POST['layer_values_' . $layerID], true); $arrayLayers[] = JSON_decode($_POST['layer_values_' . $layerID], true);
} }
$invalidFields = validateMapData($map_name, $map_zoom_level,
$map_initial_longitude, $map_initial_latitude, $map_initial_altitude,
$map_default_longitude, $map_default_latitude, $map_default_altitude,
$map_connection_list);
if (empty($invalidFields)) {
saveMap($map_name, $map_initial_longitude, $map_initial_latitude, saveMap($map_name, $map_initial_longitude, $map_initial_latitude,
$map_initial_altitude, $map_zoom_level, $map_background, $map_initial_altitude, $map_zoom_level, $map_background,
$map_default_longitude, $map_default_latitude, $map_default_altitude, $map_default_longitude, $map_default_latitude, $map_default_altitude,
$map_group_id, $map_connection_list, $arrayLayers); $map_group_id, $map_connection_list, $arrayLayers);
$mapCreatedOk = true;
}
else {
print_input_hidden('action', 'save_new');
$mapCreatedOk = false;
}
$layer_list = $arrayLayers;
print_result_message ($mapCreatedOk, __('Successfully created'),
__('Could not be created'));
break; break;
case 'new_map': case 'new_map':
print_input_hidden('action', 'save_new'); print_input_hidden('action', 'save_new');
@ -84,6 +165,114 @@ switch ($action) {
$map_default_latitude = ''; $map_default_latitude = '';
$map_default_altitude = ''; $map_default_altitude = '';
$map_group_id = ''; $map_group_id = '';
$map_connection_list = Array();
$layer_list = Array();
break;
case 'edit_map':
$idMap = get_parameter('map_id');
print_input_hidden('action', 'update_saved');
print_input_hidden('map_id', $idMap);
$mapData = getMapData($idMap);
$map_name = $mapData['map']['map_name'];
$map_group_id = $mapData['map']['group_id'];
$map_zoom_level = $mapData['map']['zoom_level'];
$map_background = $mapData['map']['map_background'];
$map_initial_longitude = $mapData['map']['initial_longitude'];
$map_initial_latitude = $mapData['map']['initial_latitude'];
$map_initial_altitude = $mapData['map']['initial_altitude'];
$map_default_longitude = $mapData['map']['default_longitude'];
$map_default_latitude = $mapData['map']['default_latitude'];
$map_default_altitude = $mapData['map']['default_altitude'];
$map_connection_list = $mapData['connections'];
$layer_list = array();
foreach ($mapData['layers'] as $layer) {
$layerAgentList = array();
foreach($layer['layer_agent_list'] as $layerAgent) {
$layerAgentList[] = $layerAgent['nombre'];
}
$layer_list[] = array(
'layer_name' => $layer['layer_name'],
'layer_group' => $layer['layer_group'],
'layer_visible' => $layer['layer_visible'],
'layer_agent_list' => $layerAgentList
);
}
break;
case 'update_saved':
$idMap = get_parameter('map_id');
$map_name = get_parameter('map_name');
$map_initial_longitude = get_parameter('map_initial_longitude');
$map_initial_latitude = get_parameter('map_initial_latitude');
$map_initial_altitude = get_parameter('map_initial_altitude');
$map_zoom_level = get_parameter('map_zoom_level');
$map_background = ''; //TODO
$map_default_longitude = get_parameter('map_default_longitude');
$map_default_latitude = get_parameter('map_default_latitude');
$map_default_altitude = get_parameter('map_default_altitude');
$map_group_id = get_parameter('map_group_id');
$map_connection_list_temp = explode(",",get_parameter('map_connection_list'));
foreach ($map_connection_list_temp as $index => $value) {
$cleanValue = trim($value);
if ($cleanValue == '') {
unset($map_connection_list_temp[$index]);
}
}
$layer_list = explode(",",get_parameter('layer_list'));
foreach ($layer_list as $index => $value) {
$cleanValue = trim($value);
if ($cleanValue == '') {
unset($layer_list[$index]);
}
}
$map_connection_default = get_parameter('map_connection_default');
$map_connection_list = array();
foreach ($map_connection_list_temp as $idMapConnection) {
$default = 0;
if ($map_connection_default == $idMapConnection)
$default = 1;
$map_connection_list[] = array('id_conection' => $idMapConnection, 'default' => $default);
}
$arrayLayers = array();
foreach ($layer_list as $layerID) {
$arrayLayers[] = JSON_decode($_POST['layer_values_' . $layerID], true);
}
$invalidFields = validateMapData($map_name, $map_zoom_level,
$map_initial_longitude, $map_initial_latitude, $map_initial_altitude,
$map_default_longitude, $map_default_latitude, $map_default_altitude,
$map_connection_list);
if (empty($invalidFields)) {
//TODO
updateMap($idMap, $map_name, $map_initial_longitude, $map_initial_latitude,
$map_initial_altitude, $map_zoom_level, $map_background,
$map_default_longitude, $map_default_latitude, $map_default_altitude,
$map_group_id, $map_connection_list, $arrayLayers);
$mapCreatedOk = true;
}
else {
print_input_hidden('action', 'update_saved');
$mapCreatedOk = false;
}
$layer_list = $arrayLayers;
print_result_message ($mapCreatedOk, __('Successfully update'),
__('Could not be update'));
print_input_hidden('action', 'update_saved');
print_input_hidden('map_id', $idMap);
break; break;
} }
@ -93,6 +282,14 @@ $table->data = array ();
$table->data[0][0] = __('Name') . ':'; $table->data[0][0] = __('Name') . ':';
$table->data[0][1] = print_input_text ('map_name', $map_name, '', 30, 60, true); $table->data[0][1] = print_input_text ('map_name', $map_name, '', 30, 60, true);
$table->rowspan[0][2] = 9; $table->rowspan[0][2] = 9;
$iconError = '';
if (isset($invalidFields['map_connection_list'])) {
if ($invalidFields['map_connection_list']) {
$iconError = '<img src="images/dot_red.png" />';
}
}
$table->data[0][2] = "<table class='databox' border='0' id='map_connection'> $table->data[0][2] = "<table class='databox' border='0' id='map_connection'>
<tr> <tr>
<td colspan='3'><div id='map' style='width: 300px; height: 300px; border: 1px solid black;'></div></td> <td colspan='3'><div id='map' style='width: 300px; height: 300px; border: 1px solid black;'></div></td>
@ -101,7 +298,7 @@ $table->data[0][2] = "<table class='databox' border='0' id='map_connection'>
<td colspan='3'><a href=''>" . __("Refresh map view") . "</a></td> <td colspan='3'><a href=''>" . __("Refresh map view") . "</a></td>
</tr> </tr>
<tr> <tr>
<td>" . __("Add Map connection") . ":</td> <td>" . __("Add Map connection") . ": " . $iconError . "</td>
<td> <td>
" . print_select_from_sql('SELECT id_tmap_connection, conection_name FROM tgis_map_connection', 'map_connection', '', '', '', '0', true) ." " . print_select_from_sql('SELECT id_tmap_connection, conection_name FROM tgis_map_connection', 'map_connection', '', '', '', '0', true) ."
</td> </td>
@ -110,7 +307,7 @@ $table->data[0][2] = "<table class='databox' border='0' id='map_connection'>
<input type='hidden' name='map_connection_list' value='' id='map_connection_list' /> <input type='hidden' name='map_connection_list' value='' id='map_connection_list' />
<input type='hidden' name='layer_list' value='' id='layer_list' /> <input type='hidden' name='layer_list' value='' id='layer_list' />
</td> </td>
</tr> </tr> " . addConectionMapsInForm($map_connection_list) . "
</table>"; </table>";
$table->data[1][0] = __('Group') . ':'; $table->data[1][0] = __('Group') . ':';
@ -119,13 +316,13 @@ $table->data[1][1] = print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo'
$table->data[2][0] = __('Zoom level') . ':'; $table->data[2][0] = __('Zoom level') . ':';
$table->data[2][1] = print_input_text ('map_zoom_level', $map_zoom_level, '', 2, 4, true); $table->data[2][1] = print_input_text ('map_zoom_level', $map_zoom_level, '', 2, 4, true);
$table->data[3][0] = __('Initial Longitude') . ':'; $table->data[3][0] = __('Center Longitude') . ':';
$table->data[3][1] = print_input_text ('map_initial_longitude', $map_initial_longitude, '', 4, 8, true); $table->data[3][1] = print_input_text ('map_initial_longitude', $map_initial_longitude, '', 4, 8, true);
$table->data[4][0] = __('Initial Latitude') . ':'; $table->data[4][0] = __('Center Latitude') . ':';
$table->data[4][1] = print_input_text ('map_initial_latitude', $map_initial_latitude, '', 4, 8, true); $table->data[4][1] = print_input_text ('map_initial_latitude', $map_initial_latitude, '', 4, 8, true);
$table->data[5][0] = __('Initial Altitude') . ':'; $table->data[5][0] = __('Center Altitude') . ':';
$table->data[5][1] = print_input_text ('map_initial_altitude', $map_initial_altitude, '', 4, 8, true); $table->data[5][1] = print_input_text ('map_initial_altitude', $map_initial_altitude, '', 4, 8, true);
$table->data[6][0] = __('Default Longitude') . ':'; $table->data[6][0] = __('Default Longitude') . ':';
@ -146,10 +343,13 @@ $table->data = array ();
$table->valign[0] = 'top'; $table->valign[0] = 'top';
$table->valign[1] = 'top'; $table->valign[1] = 'top';
$table->data[0][0] = print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub new"', true); $table->data[0][0] = "<h4>List of layers</h4>";
$table->data[0][1] = "<h4>List of layers</h4>"; $table->data[0][1] = '<div style="text-align: right;">' . print_button(__('New layer'), 'new_layer', false, 'newLayer();', 'class="sub new"', true) . '</div>';
$table->data[1][0] = '<div id="form_layer"> $table->data[1][0] = '<table class="databox" border="0" cellpadding="4" cellspacing="4" id="list_layers">' .
addLayerList($layer_list) .
'</table>';
$table->data[1][1] = '<div id="form_layer">
<table id="form_layer_table" class="databox" border="0" cellpadding="4" cellspacing="4" style="visibility: hidden;"> <table id="form_layer_table" class="databox" border="0" cellpadding="4" cellspacing="4" style="visibility: hidden;">
<tr> <tr>
<td>' . __('Layer name') . ':</td> <td>' . __('Layer name') . ':</td>
@ -158,9 +358,12 @@ $table->data[1][0] = '<div id="form_layer">
<td>' . print_checkbox('layer_visible_form', 1, true, true) . '</td> <td>' . print_checkbox('layer_visible_form', 1, true, true) . '</td>
</tr> </tr>
<tr> <tr>
<td>' . __('Group') . ':</td> <td>' . __('Show agents from group') . ':</td>
<td colspan="3">' . print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo', 'layer_group_form', '', '', __('None'), '0', true) . '</td> <td colspan="3">' . print_select_from_sql('SELECT id_grupo, nombre FROM tgrupo', 'layer_group_form', '', '', __('None'), '0', true) . '</td>
</tr> </tr>
<tr>
<td colspan="4"><hr /></td>
</tr>
<tr> <tr>
<td>' . __('Agent') . ':</td> <td>' . __('Agent') . ':</td>
<td colspan="3"> <td colspan="3">
@ -185,14 +388,26 @@ $table->data[1][0] = '<div id="form_layer">
</tr> </tr>
</table> </table>
</div>'; </div>';
$table->data[1][1] = '<table class="databox" border="0" cellpadding="4" cellspacing="4" id="list_layers">
</table>';
print_table($table); print_table($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';
switch ($action) {
case 'save_new':
case 'edit_map':
case 'update_saved':
if (!empty($invalidFields)) {
print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"'); print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"');
}
else {
print_submit_button(_('Update map'), 'update_button', false, 'class="sub update"');
}
break;
case 'new_map':
print_submit_button(_('Save map'), 'save_button', false, 'class="sub save"');
break;
}
echo '</div>'; echo '</div>';
echo "</form>"; echo "</form>";
@ -226,10 +441,13 @@ echo "</form>";
<table style="visibility: hidden;"> <table style="visibility: hidden;">
<tbody id="chuck_layer_item"> <tbody id="chuck_layer_item">
<tr> <tr>
<td class="col1"><a href='javascript: editLayer(none);'>XXXXXXXXXXXXXXXXXX</a></td> <td class="col1">XXXXXXXXXXXXXXXXXX</td>
<td class="up_arrow"><a id="up_arrow" href="javascript: upLayer();"><img src="images/up.png" alt=""></a></td> <td class="up_arrow"><a id="up_arrow" href="javascript: upLayer();"><img src="images/up.png" alt=""></a></td>
<td class="down_arrow"><a id="down_arrow" href="javascript: downLayer();"><img src="images/down.png" alt=""></a></td> <td class="down_arrow"><a id="down_arrow" href="javascript: downLayer();"><img src="images/down.png" alt=""></a></td>
<td class="col3"> <td class="col3">
<a id="edit_layer" href="javascript: editLayer(none);"><img src="images/config.png" alt="" /></a>
</td>
<td class="col4">
<input type="hidden" name="layer_values" id="layer_values" /> <input type="hidden" name="layer_values" id="layer_values" />
<a id="delete_row" href="none"><img src="images/cross.png" alt=""></a> <a id="delete_row" href="none"><img src="images/cross.png" alt=""></a>
</td> </td>
@ -247,13 +465,6 @@ require_jquery_file ('autocomplete');
require_jquery_file ('json'); require_jquery_file ('json');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var connectionMaps = Array();
var agentList = Array();
var countAgentList = 0;
var countLayer = 0;
var layerList = Array();
$("#text_id_agent").autocomplete( $("#text_id_agent").autocomplete(
"ajax.php", "ajax.php",
{ {
@ -284,12 +495,6 @@ $("#text_id_agent").result (
} }
); );
function isInt(x) {
var y=parseInt(x);
if (isNaN(y)) return false;
return x==y && x.toString()==y.toString();
}
function loadAgents(agent_list) { function loadAgents(agent_list) {
if (agent_list != null) { if (agent_list != null) {
for (index in agent_list) { for (index in agent_list) {
@ -325,6 +530,17 @@ function deleteLayer(idRow) {
} }
updateArrowLayers(); updateArrowLayers();
//If delete the layer in edit progress, must clean the form.
if ($("#hidden-layer_edit_id_form").val() == idRow) {
$("#form_layer_table").css('visibility', 'hidden');
agentList = Array();
countAgentList = 0;
setFieldsFormLayer('', 0, true, null);
$("#hidden-layer_edit_id_form").val('');
$("input[name=save_layer]").val('<?php echo __("Save Layer"); ?>');
}
} }
function newLayer() { function newLayer() {
@ -334,6 +550,7 @@ function newLayer() {
setFieldsFormLayer('', 0, true, null); setFieldsFormLayer('', 0, true, null);
$("#form_layer_table").css('visibility', 'visible'); $("#form_layer_table").css('visibility', 'visible');
$("#hidden-layer_edit_id_form").val(''); $("#hidden-layer_edit_id_form").val('');
$("input[name=save_layer]").val('<?php echo __("Save Layer"); ?>');
} }
function serializeForm() { function serializeForm() {
@ -348,7 +565,7 @@ function serializeForm() {
for (var index2 in agentList) { for (var index2 in agentList) {
if (isInt(index2)) { if (isInt(index2)) {
layer.layer_agent_list[index2] = $("#name_agent_" + index2).val(); layer.layer_agent_list[index2] = $("#name_agent_" + agentList[index2]).val();
} }
} }
@ -364,7 +581,27 @@ function editLayer(indexLayer) {
setFieldsFormLayer(layer.layer_name, layer.layer_group, layer.layer_visible, layer.layer_agent_list); setFieldsFormLayer(layer.layer_name, layer.layer_group, layer.layer_visible, layer.layer_agent_list);
$("#hidden-layer_edit_id_form").val(indexLayer); $("#hidden-layer_edit_id_form").val(indexLayer);
$("input[name=save_layer]").val('<?php echo __("Edit Layer"); ?>');
$("#form_layer_table").css('visibility', 'visible'); $("#form_layer_table").css('visibility', 'visible');
hightlightRow(indexLayer);
}
function hightlightRow(idLayer) {
row = $("#layer_item_" + idLayer);
$(".col1").css('background', '');
$(".up_arrow").css('background', '');
$(".down_arrow").css('background', '');
$(".col3").css('background', '');
$(".col4").css('background', '');
$(".col1", row).css('background', '#E9F3D2');
$(".up_arrow", row).css('background', '#E9F3D2');
$(".down_arrow", row).css('background', '#E9F3D2');
$(".col3", row).css('background', '#E9F3D2');
$(".col4", row).css('background', '#E9F3D2');
} }
function saveLayer() { function saveLayer() {
@ -382,12 +619,12 @@ function saveLayer() {
tableRow = $("#layer_item_" + id); tableRow = $("#layer_item_" + id);
} }
$(".col1", tableRow).html("<a href='javascript: editLayer(" + id + ");'>" + $("#text-layer_name_form").val() + "</a>"); $(".col1", tableRow).html($("#text-layer_name_form").val());
$("#edit_layer", tableRow).attr("href", "javascript: editLayer(" + id + ");");
$("#delete_row", tableRow).attr("href", "javascript: deleteLayer(" + id + ")"); $("#delete_row", tableRow).attr("href", "javascript: deleteLayer(" + id + ")");
$("#up_arrow", tableRow).attr("href", "javascript: upLayer(" + id + ")"); $("#up_arrow", tableRow).attr("href", "javascript: upLayer(" + id + ")");
$("#down_arrow", tableRow).attr("href", "javascript: downLayer(" + id + ")"); $("#down_arrow", tableRow).attr("href", "javascript: downLayer(" + id + ")");
$("#layer_values_" + id, tableRow).val(serializeForm()); $("#layer_values_" + id, tableRow).val(serializeForm());
if (layer_id == '') { if (layer_id == '') {
@ -398,14 +635,16 @@ function saveLayer() {
} }
updateArrowLayers(); updateArrowLayers();
$("#form_layer_table").css('visibility', 'hidden'); hightlightRow(id);
editLayer(id);
$("input[name=save_layer]").val('<?php echo __("Edit Layer"); ?>');
} }
function deleteAgentLayer(idRow) { function deleteAgentLayer(idRow) {
$("#agent_" + idRow).remove(); $("#agent_" + idRow).remove();
for (var index in agentList) { for (var index in agentList) {
//int because in the object array there are method as string //int because in the object array there are method as string
if (isInt(index)) { if (isInt(index)) {
if (agentList[index] == idRow) { if (agentList[index] == idRow) {
@ -416,26 +655,24 @@ function deleteAgentLayer(idRow) {
} }
function addAgentLayer(agent_name) { function addAgentLayer(agent_name) {
agent_name = typeof(agent_name) != 'undefined' ? agent_name : null; //default value if (typeof(agent_name) == 'undefined')
agent_name = $("#text_id_agent").val(); //default value
tableRow = $("#chuck_agent").clone(); tableRow = $("#chuck_agent").clone();
tableRow.attr('id','agent_' + countAgentList); tableRow.attr('id','agent_' + countAgentList);
agentList.push(countAgentList); agentList.push(countAgentList);
if (agent_name == null)
$(".col1", tableRow).html($("#text_id_agent").val());
else
$(".col1", tableRow).html(agent_name); $(".col1", tableRow).html(agent_name);
$("#delete_row", tableRow).attr("href", 'javascript: deleteAgentLayer(' + countAgentList + ')'); $("#delete_row", tableRow).attr("href", 'javascript: deleteAgentLayer(' + countAgentList + ')');
$("#name_agent", tableRow).val($("#text_id_agent").val()); $("#name_agent", tableRow).val(agent_name);
$("#name_agent", tableRow).attr("name", "name_agent_" + countAgentList); $("#name_agent", tableRow).attr("name", "name_agent_" + countAgentList);
$("#name_agent", tableRow).attr("id", "name_agent_" + countAgentList); $("#name_agent", tableRow).attr("id", "name_agent_" + countAgentList);
countAgentList++; countAgentList++;
$("#list_agents").append(tableRow); $("#list_agents").append(tableRow);
$("#button-add_agent").attr('disabled', true);
} }
function deleteConnectionMap(idConnectionMap) { function deleteConnectionMap(idConnectionMap) {
@ -534,43 +771,6 @@ function fillOrderField() {
$('#layer_list').val(layerList.toString()); $('#layer_list').val(layerList.toString());
} }
function updateArrowLayers() {
var count = 0;
var lastIndex = null;
for (var index in layerList) {
//int because in the object array there are method as string
if (isInt(index)) {
numLayer = layerList[index];
layerObj = $("#layer_item_" + numLayer);
//First element
if (count == 0) {
$('.up_arrow', layerObj).html('');
}
else {
$('.up_arrow', layerObj).html('<a class="up_arrow" href="javascript: upLayer(' + numLayer + ');"><?php print_image ("images/up.png"); ?></a>');
}
$('.down_arrow', layerObj).html('<a class="down_arrow" href="javascript: downLayer(' + numLayer + ');"><?php print_image ("images/down.png"); ?></a>');
count++;
lastIndex = index;
}
}
//Last element
if (lastIndex != null) {
numLayer = layerList[lastIndex];
layerObj = $("#layer_item_" + numLayer);
$('.down_arrow', layerObj).html('');
}
}
function upLayer(idLayer) { function upLayer(idLayer) {
var toUpIndex = null var toUpIndex = null
var toDownIndex = null; var toDownIndex = null;

View File

@ -82,7 +82,7 @@ if ($maps !== false) {
$defaultMapId = $map['id_tgis_map']; $defaultMapId = $map['id_tgis_map'];
} }
$table->data[] = array('<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$map['id_tgis_map'].'&amp;action=edit_map">' . $map['map_name'] . '</a>', $table->data[] = array('<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&map_id='.$map['id_tgis_map'].'&amp;action=edit_map">' . $map['map_name'] . '</a>',
print_group_icon ($map['group_id'], true), print_group_icon ($map['group_id'], true),
'<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$map['id_tgis_map'].'">' . print_image ("images/eye.png", true).'</a>', '<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$map['id_tgis_map'].'">' . print_image ("images/eye.png", true).'</a>',
print_radio_button_extended('default_map', $map['id_tgis_map'], '', $checked, false, "setDefault(" . $map['id_tgis_map'] . ");", '', true), print_radio_button_extended('default_map', $map['id_tgis_map'], '', $checked, false, "setDefault(" . $map['id_tgis_map'] . ");", '', true),

View File

@ -348,6 +348,10 @@ function getMapConf($idMap) {
return $mapConfs; return $mapConfs;
} }
function getMapConnection($idMapConnection) {
return get_db_row('tgis_map_connection', 'id_tmap_connection', $idMapConnection);
}
function getLayers($idMap) { function getLayers($idMap) {
$layers = get_db_all_rows_sql('SELECT * FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap); $layers = get_db_all_rows_sql('SELECT * FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap);
@ -591,6 +595,72 @@ function saveMap($map_name, $map_initial_longitude, $map_initial_latitude,
} }
} }
function updateMap($idMap, $map_name, $map_initial_longitude, $map_initial_latitude,
$map_initial_altitude, $map_zoom_level, $map_background,
$map_default_longitude, $map_default_latitude, $map_default_altitude,
$map_group_id, $map_connection_list, $arrayLayers) {
process_sql_update('tgis_map',
array('map_name' => $map_name,
'initial_longitude' => $map_initial_longitude,
'initial_latitude' => $map_initial_latitude,
'initial_altitude' => $map_initial_altitude,
'zoom_level' => $map_zoom_level,
'map_background' => $map_background,
'default_longitude' => $map_default_longitude,
'default_latitude' => $map_default_latitude,
'default_altitude' => $map_default_altitude,
'group_id' => $map_group_id
),
array('id_tgis_map' => $idMap));
process_sql_delete('tgis_map_has_tgis_map_connection', array('tgis_map_id_tgis_map' => $idMap));
foreach ($map_connection_list as $map_connection) {
process_sql_insert('tgis_map_has_tgis_map_connection',
array(
'tgis_map_id_tgis_map' => $idMap,
'tgis_map_connection_id_tmap_connection' => $map_connection['id_conection'],
'default_map_connection' => $map_connection['default']
)
);
}
$listOldIdLayers = get_db_all_rows_sql('SELECT id_tmap_layer FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $idMap);
if ($listOldIdLayers == false)
$listOldIdLayers = array();
foreach($listOldIdLayers as $idLayer) {
process_sql_delete('tgis_map_layer_has_tagente', array('tgis_map_layer_id_tmap_layer' => $idLayer['id_tmap_layer']));
}
process_sql_delete('tgis_map_layer', array('tgis_map_id_tgis_map' => $idMap));
foreach ($arrayLayers as $index => $layer) {
$idLayer = process_sql_insert('tgis_map_layer',
array(
'layer_name' => $layer['layer_name'],
'view_layer' => $layer['layer_visible'],
'layer_stack_order' => $index,
'tgis_map_id_tgis_map' => $idMap,
'tgrupo_id_grupo' => $layer['layer_group']
)
);
if (array_key_exists('layer_agent_list', $layer)) {
if (count($layer['layer_agent_list']) > 0) {
foreach ($layer['layer_agent_list'] as $agent_name) {
process_sql_insert('tgis_map_layer_has_tagente',
array(
'tgis_map_layer_id_tmap_layer' => $idLayer,
'tagente_id_agente' => get_agent_id($agent_name)
)
);
}
}
}
}
}
/** /**
* Get the configuration parameters of a map connection * Get the configuration parameters of a map connection
* *
@ -723,4 +793,196 @@ function getArrayListIcons($fullpath = true) {
return $return; return $return;
} }
function validateMapData($map_name, $map_zoom_level,
$map_initial_longitude, $map_initial_latitude, $map_initial_altitude,
$map_default_longitude, $map_default_latitude, $map_default_altitude,
$map_connection_list) {
$invalidFields = array();
echo "<style type='text/css'>";
//validateMap
if ($map_name == '') {
echo "input[name=map_name] {background: #FF5050;}";
$invalidFields['map_name'] = true;
}
//validate zoom level
if ($map_zoom_level == '') {
echo "input[name=map_zoom_level] {background: #FF5050;}";
$invalidFields['map_zoom_level'] = true;
}
//validate map_initial_longitude
if ($map_initial_longitude == '') {
echo "input[name=map_initial_longitude] {background: #FF5050;}";
$invalidFields['map_initial_longitude'] = true;
}
//validate map_initial_latitude
if ($map_initial_latitude == '') {
echo "input[name=map_initial_latitude] {background: #FF5050;}";
$invalidFields['map_initial_latitude'] = true;
}
//validate map_initial_altitude
if ($map_initial_altitude == '') {
echo "input[name=map_initial_altitude] {background: #FF5050;}";
$invalidFields['map_initial_altitude'] = true;
}
//validate map_default_longitude
if ($map_default_longitude == '') {
echo "input[name=map_default_longitude] {background: #FF5050;}";
$invalidFields['map_default_longitude'] = true;
}
//validate map_default_latitude
if ($map_default_latitude == '') {
echo "input[name=map_default_latitude] {background: #FF5050;}";
$invalidFields['map_default_latitude'] = true;
}
//validate map_default_altitude
if ($map_default_altitude == '') {
echo "input[name=map_default_altitude] {background: #FF5050;}";
$invalidFields['map_default_altitude'] = true;
}
//validate map_default_altitude
if ($map_connection_list == '') {
$invalidFields['map_connection_list'] = true;
}
echo "</style>";
return $invalidFields;
}
/**
* Get all data (connections, layers with agents) of a map passed as id.
*
* @param integer $idMap The id of map in database.
*
* @return Array Return a asociative array whith the items 'map', 'connections' and 'layers'. And in 'layers' has data and item 'agents'.
*/
function getMapData($idMap) {
$returnVar = array();
$map = get_db_row('tgis_map', 'id_tgis_map', $idMap);
$connections = get_db_all_rows_sql('SELECT tgis_map_connection_id_tmap_connection AS id_conection,
default_map_connection AS `default`
FROM tgis_map_has_tgis_map_connection WHERE tgis_map_id_tgis_map = '. $map['id_tgis_map']);
$layers = get_db_all_rows_sql('SELECT id_tmap_layer, layer_name, tgrupo_id_grupo AS layer_group, view_layer AS layer_visible FROM tgis_map_layer WHERE tgis_map_id_tgis_map = ' . $map['id_tgis_map']);
if ($layers === false) $layers = array();
foreach ($layers as $index => $layer) {
$agents = get_db_all_rows_sql('SELECT nombre
FROM tagente
WHERE id_agente IN (SELECT tagente_id_agente FROM tgis_map_layer_has_tagente WHERE tgis_map_layer_id_tmap_layer = ' . $layer['id_tmap_layer'] . ')');
if ($agents !== false)
$layers[$index]['layer_agent_list'] = $agents;
else
$layers[$index]['layer_agent_list'] = array();
}
$returnVar['map'] = $map;
$returnVar['connections'] = $connections;
$returnVar['layers'] = $layers;
return $returnVar;
}
/**
* This function use in form the "pandora_console/godmode/gis_maps/configure_gis_map.php"
* in the case of edit a map or when there are any error in save new map. Because this function
* return a html code that it has the rows of connections.
*
* @param Array $map_connection_list The list of map connections for convert a html.
*
* @return String The html source code.
*/
function addConectionMapsInForm($map_connection_list) {
$returnVar = '';
foreach ($map_connection_list as $mapConnection) {
$mapConnectionRowDB = getMapConnection($mapConnection['id_conection']);
if ($mapConnection['default']) {
$radioButton = print_radio_button_extended('map_connection_default', $mapConnection['id_conection'], '', $mapConnection['id_conection'], false, 'changeDefaultConection(this.value)', '', true);
}
else
$radioButton = print_radio_button_extended('map_connection_default', $mapConnection['id_conection'], '', null, false, 'changeDefaultConection(this.value)', '', true);
$returnVar .= '
<tbody id="map_connection_' . $mapConnection['id_conection'] . '">
<tr class="row_0">
<td>' . print_input_text ('map_connection_name_' . $mapConnection['id_conection'], $mapConnectionRowDB['conection_name'], '', 20, 40, true, true) . '</td>
<td>' . $radioButton . '</td>
<td><a id="delete_row" href="javascript: deleteConnectionMap(\'' . $mapConnection['id_conection'] . '\')"><img src="images/cross.png" alt=""></a></td>
</tr>
</tbody>
<script type="text/javascript">
connectionMaps.push(' . $mapConnection['id_conection'] . ');
</script>
';
}
return $returnVar;
}
/**
* This function use in form the "pandora_console/godmode/gis_maps/configure_gis_map.php"
* in the case of edit a map or when there are any error in save new map. Because this function
* return a html code that it has the rows of layers of map.
*
* @param Array $layer_list The list of layers for convert a html.
*
* @return String The html source code.
*/
function addLayerList($layer_list) {
$returnVar = '';
$count = 0;
foreach ($layer_list as $layer) {
//Create the layer temp form as it was in the form
$layerTempForm = array();
$layerTempForm['layer_name'] = $layer['layer_name'];
$layerTempForm['layer_group'] = $layer['layer_group'];
$layerTempForm['layer_visible'] = $layer['layer_visible'];
if (array_key_exists('layer_agent_list', $layer)) {
foreach($layer['layer_agent_list'] as $agent) {
$layerTempForm['layer_agent_list'][] = $agent;
}
}
$layerDataJSON = json_encode($layerTempForm);
$returnVar .= '
<tbody id="layer_item_' . $count . '">
<tr>
<td class="col1">' . $layer['layer_name'] . '</td>
<td class="up_arrow"><a id="up_arrow" href="javascript: upLayer(' . $count . ');"><img src="images/up.png" alt=""></a></td>
<td class="down_arrow"><a id="down_arrow" href="javascript: downLayer(' . $count . ');"><img src="images/down.png" alt=""></a></td>
<td class="col3">
<a id="edit_layer" href="javascript: editLayer(' . $count . ');"><img src="images/config.png" alt="" /></a>
</td>
<td class="col4">
<input type="hidden" name="layer_values_' . $count . '" value=\'' . $layerDataJSON . '\' id="layer_values_' . $count . '" />
<a id="delete_row" href="javascript: deleteLayer(' . $count . ')"><img src="images/cross.png" alt=""></a>
</td>
</tr>
</tbody>
<script type="text/javascript">
layerList.push(countLayer);
countLayer++;
updateArrowLayers();
</script>';
$count ++;
}
return $returnVar;
}
?> ?>

View File

@ -64,7 +64,7 @@ if ($config["pure"] == 0) {
echo "&nbsp;"; echo "&nbsp;";
if (give_acl ($config["id_user"], $map['group_id'], "AW")) if (give_acl ($config["id_user"], $map['group_id'], "AW"))
echo '<a href="index.php?sec=gmap&amp;sec2=godmode/reporting/map_builder&amp;map_id='.$idMap.'">'.print_image ("images/setup.png", true, array ("title" => __('Setup'))).'</a>'; echo '<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='. $idMap.'">'.print_image ("images/setup.png", true, array ("title" => __('Setup'))).'</a>';
echo "</h2>"; echo "</h2>";
printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'], printMap('map', $map['zoom_level'], $numZoomLevels, $map['initial_latitude'],